Xinqi Bao's Git

entropy: Improve types
[slstatus.git] / components / entropy.c
index ac61679..4ca7110 100644 (file)
@@ -1,17 +1,21 @@
 /* See LICENSE file for copyright and license details. */
 #if defined(__linux__)
        #include <stdio.h>
+       #include <stdint.h>
 
        #include "../util.h"
 
        const char *
        entropy(void)
        {
-               int num;
+               uint64_t num;
 
-               return (pscanf("/proc/sys/kernel/random/entropy_avail",
-                              "%d", &num) == 1) ?
-                      bprintf("%d", num) : NULL;
+               if (pscanf("/proc/sys/kernel/random/entropy_avail",
+                          "%d", &num) != 1) {
+                       return NULL;
+               }
+
+               return bprintf("%d", num);
        }
 #elif defined(__OpenBSD__)
        const char *