]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
random-util: actually encode our expectations on RAND_MAX
authorLennart Poettering <lennart@poettering.net>
Sun, 10 May 2020 09:13:49 +0000 (11:13 +0200)
committerLennart Poettering <lennart@poettering.net>
Sun, 10 May 2020 09:13:49 +0000 (11:13 +0200)
src/basic/random-util.c

index eae488ae5d921bb449d01b461cd7840815d1abef..363a1f71513c1189cce65f4e2008633e6be8cc68 100644 (file)
@@ -325,9 +325,11 @@ void initialize_srand(void) {
 
 /* INT_MAX gives us only 31 bits, so use 24 out of that. */
 #if RAND_MAX >= INT_MAX
+assert_cc(RAND_MAX >= 16777215);
 #  define RAND_STEP 3
 #else
-/* SHORT_INT_MAX or lower gives at most 15 bits, we just just 8 out of that. */
+/* SHORT_INT_MAX or lower gives at most 15 bits, we just use 8 out of that. */
+assert_cc(RAND_MAX >= 255);
 #  define RAND_STEP 1
 #endif