[Olsr-dev] [PATCH v1 113/115] jsoninfo: helpers: use sizeof() for uuid size

Ferry Huberts (spam-protected)
Wed Dec 2 21:29:26 CET 2015


From: Ferry Huberts <(spam-protected)>

And make its size a bit less strange.
Plus an extra minor simplification.

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/jsoninfo/src/olsrd_jsoninfo_helpers.c | 6 +++---
 lib/jsoninfo/src/olsrd_jsoninfo_helpers.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/jsoninfo/src/olsrd_jsoninfo_helpers.c b/lib/jsoninfo/src/olsrd_jsoninfo_helpers.c
index e61c0c1..d8526a0 100644
--- a/lib/jsoninfo/src/olsrd_jsoninfo_helpers.c
+++ b/lib/jsoninfo/src/olsrd_jsoninfo_helpers.c
@@ -50,7 +50,7 @@
 #include <fcntl.h>
 #endif /* __linux__ */
 
-char uuid[UUIDLEN + 1];
+char uuid[UUIDLEN];
 
 /* JSON support functions */
 
@@ -196,11 +196,11 @@ int read_uuid_from_file(const char * name, const char *file) {
 
   f = fopen(file, "r");
   olsr_printf(1, "(%s) Reading UUID from '%s'\n", name, file);
-  if (f == NULL) {
+  if (!f) {
     olsr_printf(1, "(%s) Could not open '%s': %s\n", name, file, strerror(errno));
     return -1;
   }
-  chars = fread(uuid, 1, UUIDLEN, f);
+  chars = fread(uuid, 1, sizeof(uuid) - 1, f);
   if (chars > 0) {
     uuid[chars] = '\0'; /* null-terminate the string */
 
diff --git a/lib/jsoninfo/src/olsrd_jsoninfo_helpers.h b/lib/jsoninfo/src/olsrd_jsoninfo_helpers.h
index 1d154da..633cbcf 100644
--- a/lib/jsoninfo/src/olsrd_jsoninfo_helpers.h
+++ b/lib/jsoninfo/src/olsrd_jsoninfo_helpers.h
@@ -48,7 +48,7 @@
 #include "common/autobuf.h"
 
 #define UUIDLEN 256
-extern char uuid[UUIDLEN + 1];
+extern char uuid[UUIDLEN];
 
 void abuf_json_reset_entry_number_and_depth(void);
 
-- 
2.5.0




More information about the Olsr-dev mailing list