]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: use return codes in xxx_from_string()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 10 Feb 2021 18:27:22 +0000 (03:27 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 11 Feb 2021 16:17:06 +0000 (01:17 +0900)
Follow-up for #11484.

src/shared/conf-parser.h

index 283d60a47326986115a9a4b8ead24c28dee83784..5a7dc7ff597885cd33f1b45bf8142d2989fd8662 100644 (file)
@@ -207,7 +207,7 @@ typedef enum Disabled {
                                                                         \
                 x = from_string(rvalue);                                \
                 if (x < 0) {                                            \
-                        log_syntax(unit, LOG_WARNING, filename, line, 0, \
+                        log_syntax(unit, LOG_WARNING, filename, line, x, \
                                    msg ", ignoring: %s", rvalue);       \
                         return 0;                                       \
                 }                                                       \
@@ -235,7 +235,7 @@ typedef enum Disabled {
                                                                         \
                 x = name##_from_string(rvalue);                         \
                 if (x < 0) {                                            \
-                        log_syntax(unit, LOG_WARNING, filename, line, 0, \
+                        log_syntax(unit, LOG_WARNING, filename, line, x, \
                                    msg ", ignoring: %s", rvalue);       \
                         return 0;                                       \
                 }                                                       \
@@ -269,14 +269,17 @@ typedef enum Disabled {
                         r = extract_first_word(&p, &en, NULL, 0);              \
                         if (r == -ENOMEM)                                      \
                                 return log_oom();                              \
-                        if (r < 0)                                             \
-                                return log_syntax(unit, LOG_ERR, filename, line, 0,   \
-                                                  msg ": %s", en);             \
+                        if (r < 0) {                                           \
+                                log_syntax(unit, LOG_WARNING, filename, line, r, \
+                                           msg ", ignoring: %s", en);          \
+                                return 0;                                      \
+                        }                                                      \
                         if (r == 0)                                            \
                                 break;                                         \
                                                                                \
-                        if ((x = name##_from_string(en)) < 0) {                \
-                                log_syntax(unit, LOG_WARNING, filename, line, 0,        \
+                        x = name##_from_string(en);                            \
+                        if (x < 0) {                                           \
+                                log_syntax(unit, LOG_WARNING, filename, line, x, \
                                            msg ", ignoring: %s", en);          \
                                 continue;                                      \
                         }                                                      \