From: Tobias Stoeckmann Date: Sat, 28 Mar 2026 15:24:00 +0000 (+0100) Subject: randutils: Reduce function and macro visibility X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2a366d8074f62210e3056929366286eb265978db;p=thirdparty%2Futil-linux.git randutils: Reduce function and macro visibility srand and rand are no longer used in the tree. In fact, all randomness used in tree goes through ul_random_get_bytes. Reduce macro and function visibility to randutils.c where they are still used. While at it, update comment. Signed-off-by: Tobias Stoeckmann --- diff --git a/include/randutils.h b/include/randutils.h index fb2449796..bcea43df7 100644 --- a/include/randutils.h +++ b/include/randutils.h @@ -4,13 +4,7 @@ #ifndef UTIL_LINUX_RANDUTILS #define UTIL_LINUX_RANDUTILS -#ifdef HAVE_SRANDOM -#define srand(x) srandom(x) -#define rand() random() -#endif - -/* /dev/urandom based with fallback to rand() */ -extern int random_get_fd(void); +/* getrandom(2) based with fallback to /dev/(u)random and libc randomness */ extern int ul_random_get_bytes(void *buf, size_t nbytes); extern const char *random_tell_source(void); diff --git a/lib/randutils.c b/lib/randutils.c index 3697bf70a..155eded76 100644 --- a/lib/randutils.c +++ b/lib/randutils.c @@ -41,6 +41,11 @@ static int getrandom(void *buf, size_t buflen, unsigned int flags) # define HAVE_GETRANDOM #endif +#ifdef HAVE_SRANDOM +#define srand(x) srandom(x) +#define rand() random() +#endif + #if defined(__linux__) && defined(__NR_gettid) && defined(HAVE_JRAND48) #define DO_JRAND_MIX THREAD_LOCAL unsigned short ul_jrand_seed[3]; @@ -68,7 +73,7 @@ static void crank_random(void) rand(); } -int random_get_fd(void) +static int random_get_fd(void) { int fd;