diff options
author | Petr Písař <ppisar@redhat.com> | 2017-12-11 14:34:08 +0100 |
---|---|---|
committer | Marco d'Itri <md@linux.it> | 2017-12-27 03:09:58 +0100 |
commit | 50b57a6fb754b1c79167fef5aec5ca9bf59ed403 (patch) | |
tree | 0687061f9653b86cf9fc3e06be8c5dbb38f58bfc | |
parent | 888fa4654b18ee1b11394e5c1dfccbdc50a332da (diff) | |
download | whois-50b57a6fb754b1c79167fef5aec5ca9bf59ed403.tar.gz |
Remove unused variables in get_random_bytes()
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.
-rw-r--r-- | mkpasswd.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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 ")"); |