From ce67a85d392cafd8b5078a1daeb855001fc637c5 Mon Sep 17 00:00:00 2001 From: Dustin Laurence Date: Sat, 20 Dec 2014 10:57:38 -0800 Subject: [PATCH] Add finalize_rand() to prove we have no leaks --- rand.c | 6 ++++-- rand.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rand.c b/rand.c index 7c80c13af8..7251826c89 100644 --- a/rand.c +++ b/rand.c @@ -33,10 +33,12 @@ void init_rand(void) f = fopen("/dev/urandom", "r"); } -void finalize_rand(void) +int finalize_rand(void) { - fclose(f); + int err = fclose(f); f = NULL; + + return err; } uint32_t random32(void) diff --git a/rand.h b/rand.h index cd281aa533..e626d7816c 100644 --- a/rand.h +++ b/rand.h @@ -27,7 +27,7 @@ #include void init_rand(void); -void finalize_rand(void); +int finalize_rand(void); uint32_t random32(void); void random_buffer(uint8_t *buf, size_t len);