From 50b57a6fb754b1c79167fef5aec5ca9bf59ed403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 11 Dec 2017 14:34:08 +0100 Subject: [PATCH] Remove unused variables in get_random_bytes() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If getentropy() is available, GCC warns about unsused variables: mkpasswd.c: In function ‘get_random_bytes’: mkpasswd.c:369:13: warning: unused variable ‘bytes_read’ [-Wunused-variable] ssize_t bytes_read; ^~~~~~~~~~ mkpasswd.c:368:9: warning: unused variable ‘fd’ [-Wunused-variable] int fd; ^~ This patch fixes it. --- mkpasswd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkpasswd.c b/mkpasswd.c index 32e719e..c419755 100644 --- a/mkpasswd.c +++ b/mkpasswd.c @@ -364,17 +364,17 @@ int main(int argc, char *argv[]) void* get_random_bytes(const unsigned int count) { - char *buf; - int fd; - ssize_t bytes_read; + char *buf = NOFAIL(malloc(count)); - buf = NOFAIL(malloc(count)); #if defined HAVE_ARC4RANDOM_BUF arc4random_buf(buf, count); #elif defined HAVE_GETENTROPY if (getentropy(buf, count) < 0) perror("getentropy"); #else + int fd; + ssize_t bytes_read; + fd = open(RANDOM_DEVICE, O_RDONLY); if (fd < 0) { perror("open(" RANDOM_DEVICE ")");