Merge "Replace base::RandInt with std::uniform_int_distribution" into main am: d53b098097 am: 5232f86082

Original change: https://android-review.googlesource.com/c/platform/system/core/+/3272517

Change-Id: Ib9690fb4825c209552477a58a757d2bafb0f6c9f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2024-09-20 06:14:56 +00:00 committed by Automerger Merge Worker
commit 3420a1a4cc

View file

@ -16,10 +16,11 @@
#include <endian.h>
#include <random>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <base/files/file_util.h>
#include <base/rand_util.h>
#include <libavb/libavb.h>
#include "avb_util.h"
@ -727,7 +728,10 @@ void AvbUtilTest::ModifyFile(const base::FilePath& file_path, size_t offset, ssi
// Introduces a new modification.
if (length > 0) {
int modify_location = base::RandInt(offset, offset + length - 1);
// mersenne_twister_engine seeded with the default seed source.
static std::mt19937 gen(std::random_device{}());
std::uniform_int_distribution<> rand_distribution(offset, offset + length - 1);
int modify_location = rand_distribution(gen);
file_content[modify_location] ^= 0x80;
last_file_path = file_path.value();
last_modified_location = modify_location;