]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: minor refactorings/modernizations
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Feb 2022 08:47:50 +0000 (09:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Feb 2022 09:17:17 +0000 (10:17 +0100)
src/shared/conf-parser.c

index 1de8eb9474848d931d107d0ce25333f2f8ec4c00..ebbfa0d6c26ab0e6e46377c879c668f7278b25dd 100644 (file)
@@ -160,7 +160,7 @@ static int parse_line(
                 char **section,
                 unsigned *section_line,
                 bool *section_ignored,
-                char *l,
+                char *l, /* is modified */
                 void *userdata) {
 
         char *e;
@@ -171,10 +171,10 @@ static int parse_line(
         assert(l);
 
         l = strstrip(l);
-        if (!*l)
+        if (isempty(l))
                 return 0;
 
-        if (*l == '\n')
+        if (l[0] == '\n')
                 return 0;
 
         if (!utf8_is_valid(l))
@@ -195,14 +195,14 @@ static int parse_line(
                         return log_oom();
 
                 if (sections && !nulstr_contains(sections, n)) {
-                        bool ignore = flags & CONFIG_PARSE_RELAXED;
+                        bool ignore;
                         const char *t;
 
-                        ignore = ignore || startswith(n, "X-");
+                        ignore = (flags & CONFIG_PARSE_RELAXED) || startswith(n, "X-");
 
                         if (!ignore)
                                 NULSTR_FOREACH(t, sections)
-                                        if (streq_ptr(n, startswith(t, "-"))) {
+                                        if (streq_ptr(n, startswith(t, "-"))) { /* Ignore sections prefixed with "-" in valid section list */
                                                 ignore = true;
                                                 break;
                                         }