]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
randutils: Reduce function and macro visibility
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 28 Mar 2026 15:24:00 +0000 (16:24 +0100)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 15 Apr 2026 10:06:41 +0000 (12:06 +0200)
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 <tobias@stoeckmann.org>
include/randutils.h
lib/randutils.c

index fb24497962953a470f904624ad3b37ee95a6f8e9..bcea43df7e8831cfa721a48b569a12ae215f0737 100644 (file)
@@ -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);
 
index 3697bf70a78521ddc762fd2428e74927f458dfa5..155eded76f9cb90c29db8dd05908011b720b3cd3 100644 (file)
@@ -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;