Rename randomize to os_randomize

This commit is contained in:
Andrea Mazzoleni 2026-06-11 18:36:13 +02:00
parent 525d789f57
commit 130aaddbd0
6 changed files with 10 additions and 10 deletions

View file

@ -2831,7 +2831,7 @@ uint64_t os_tick_ms(void)
return GetTickCount64(); return GetTickCount64();
} }
int randomize(void* void_ptr, size_t size) int os_randomize(void* void_ptr, size_t size)
{ {
size_t i; size_t i;
unsigned char* ptr = void_ptr; unsigned char* ptr = void_ptr;

View file

@ -413,6 +413,11 @@ int os_pclose(OS_FILE* stream);
*/ */
int os_get_optimal_cpu(void); int os_get_optimal_cpu(void);
/**
* Fill memory with pseudo-random values
*/
int os_randomize(void* ptr, size_t size);
/****************************************************************************/ /****************************************************************************/
/* app */ /* app */
@ -602,11 +607,6 @@ extern int exit_sync_needed;
#define EXIT_FAILURE exit_failure #define EXIT_FAILURE exit_failure
#define EXIT_SYNC_NEEDED exit_sync_needed #define EXIT_SYNC_NEEDED exit_sync_needed
/**
* Fill memory with pseudo-random values.
*/
int randomize(void* ptr, size_t size);
/** /**
* Standard SMART attributes. * Standard SMART attributes.
*/ */

View file

@ -44,7 +44,7 @@ void state_rehash(struct snapraid_state* state)
/* set the new hash and seed */ /* set the new hash and seed */
state->hash = state->besthash; state->hash = state->besthash;
if (randomize(state->hashseed, HASH_MAX) != 0) { if (os_randomize(state->hashseed, HASH_MAX) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(errno, "Failed to get random values.\n"); log_fatal(errno, "Failed to get random values.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View file

@ -1470,7 +1470,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
state->hash = state->besthash; state->hash = state->besthash;
/* by default use a random hash seed */ /* by default use a random hash seed */
if (randomize(state->hashseed, HASH_MAX) != 0) { if (os_randomize(state->hashseed, HASH_MAX) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(errno, "Failed to retrieve random values.\n"); log_fatal(errno, "Failed to retrieve random values.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View file

@ -44,7 +44,7 @@ void state_touch(struct snapraid_state* state)
uint32_t nano; uint32_t nano;
/* get a random nanosecond value */ /* get a random nanosecond value */
if (randomize(&nano, sizeof(nano)) != 0) { if (os_randomize(&nano, sizeof(nano)) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(errno, "Failed to retrieve random values.\n"); log_fatal(errno, "Failed to retrieve random values.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View file

@ -3368,7 +3368,7 @@ uint64_t os_tick_ms(void)
return tv.tv_sec * 1000ULL + tv.tv_usec / 1000; return tv.tv_sec * 1000ULL + tv.tv_usec / 1000;
} }
int randomize(void* ptr, size_t size) int os_randomize(void* ptr, size_t size)
{ {
int f; int f;
ssize_t ret; ssize_t ret;