Use ARRAY_SIZE() in log.c
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 25 Apr 2017 09:21:11 +0000 (11:21 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 25 Apr 2017 09:21:11 +0000 (11:21 +0200)
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
src/log.c

index fba373e4a8ecd65353cd7c46d17af878e63cd8d9..c0ec3c91e1d5a82a20b4b7a1992cccaaa109efd1 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -27,6 +27,7 @@
 #include <syslog.h>
 
 #include "log.h"
+#include "common.h"
 
 #define PROTECT_ERRNO __attribute__((cleanup(_reset_errno))) __attribute((unused)) int _saved_errno = errno
 
@@ -46,7 +47,7 @@ void log_set_max_level(int level) {
 }
 
 int log_parse_level_name(const char *name) {
-  int i;
+  unsigned i;
   static const char *levels[] = {
     [LOG_EMERG] = "emerg",
     [LOG_ALERT] = "alert",
@@ -58,7 +59,7 @@ int log_parse_level_name(const char *name) {
     [LOG_DEBUG] = "debug",
   };
 
-  for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
+  for (i = 0; i < ARRAY_SIZE(levels); i++)
     if (strcmp(levels[i], name) == 0)
       return i;
   return -EINVAL;