]> granicus.if.org Git - sudo/commitdiff
When checking syslog facility or priority, move the string
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 26 Oct 2016 16:46:03 +0000 (10:46 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 26 Oct 2016 16:46:03 +0000 (10:46 -0600)
compare into the body of the loop and return if it matches.
If we finish the loop it means we didn't find a match.
This makes the code a little bit more readable.

plugins/sudoers/defaults.c

index d21b83f89817b398c88cae170a59694e29f7ea65..bab8343887563aceb6a565701eb6111b05d78ff0 100644 (file)
@@ -866,13 +866,13 @@ store_syslogfac(const char *val, struct sudo_defs_types *def)
        def->sd_un.ival = false;
        debug_return_bool(true);
     }
-    for (fac = facilities; fac->name && strcmp(val, fac->name); fac++)
-       continue;
-    if (fac->name == NULL)
-       debug_return_bool(false);               /* not found */
-
-    def->sd_un.ival = fac->num;
-    debug_return_bool(true);
+    for (fac = facilities; fac->name != NULL; fac++) {
+       if (strcmp(val, fac->name) != 0) {
+           def->sd_un.ival = fac->num;
+           debug_return_bool(true);
+       }
+    }
+    debug_return_bool(false);          /* not found */
 }
 
 static const char *
@@ -895,13 +895,13 @@ store_syslogpri(const char *val, struct sudo_defs_types *def)
     if (val == NULL)
        debug_return_bool(false);
 
-    for (pri = priorities; pri->name && strcmp(val, pri->name); pri++)
-       continue;
-    if (pri->name == NULL)
-       debug_return_bool(false);       /* not found */
-
-    def->sd_un.ival = pri->num;
-    debug_return_bool(true);
+    for (pri = priorities; pri->name != NULL; pri++) {
+       if (strcmp(val, pri->name) != 0) {
+           def->sd_un.ival = pri->num;
+           debug_return_bool(true);
+       }
+    }
+    debug_return_bool(false);  /* not found */
 }
 
 static const char *