chiark / gitweb /
basic: Fix build warning in random-util (#6284)
authorBenjamin Robin <benjarobin@users.noreply.github.com>
Tue, 4 Jul 2017 21:42:20 +0000 (23:42 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 25 Jul 2017 07:46:53 +0000 (09:46 +0200)
src/basic/random-util.c

index 490107ef41b85fe673f960143d62f8810b3c39f4..589575cf00fc2051488ae98409dfc2299cfeb4f6 100644 (file)
@@ -61,7 +61,7 @@ int acquire_random_bytes(void *p, size_t n, bool high_quality_required) {
                 r = getrandom(p, n, GRND_NONBLOCK);
                 if (r > 0) {
                         have_syscall = true;
                 r = getrandom(p, n, GRND_NONBLOCK);
                 if (r > 0) {
                         have_syscall = true;
-                        if (r == n)
+                        if (r == (int) n)
                                 return 0;
                         if (!high_quality_required) {
                                 /* Fill in the remaing bytes using pseudorandom values */
                                 return 0;
                         if (!high_quality_required) {
                                 /* Fill in the remaing bytes using pseudorandom values */
@@ -147,11 +147,11 @@ void pseudorandom_bytes(void *p, size_t n) {
                 rr = (unsigned) rand();
 
 #if RAND_STEP >= 3
                 rr = (unsigned) rand();
 
 #if RAND_STEP >= 3
-                if (q - (uint8_t*) p + 2 < n)
+                if (q - (uint8_t*) p + 2 < (ptrdiff_t) n)
                         q[2] = rr >> 16;
 #endif
 #if RAND_STEP >= 2
                         q[2] = rr >> 16;
 #endif
 #if RAND_STEP >= 2
-                if (q - (uint8_t*) p + 1 < n)
+                if (q - (uint8_t*) p + 1 < (ptrdiff_t) n)
                         q[1] = rr >> 8;
 #endif
                 q[0] = rr;
                         q[1] = rr >> 8;
 #endif
                 q[0] = rr;