]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
install: skip later first_word() calls if one of earlier calls passes
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 25 Jul 2025 18:24:51 +0000 (03:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 25 Jul 2025 20:00:02 +0000 (05:00 +0900)
Prompted by CID#1587764, that is false-positive.

src/shared/install.c

index 8fc087fb78ca2af1ed0e2b862a78d69fe1e524c4..3522af67eca3508b9296f8eae51795252267b044 100644 (file)
@@ -3350,8 +3350,7 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
                         if (strchr(COMMENTS, line[0]))
                                 continue;
 
-                        parameter = first_word(line, "enable");
-                        if (parameter) {
+                        if ((parameter = first_word(line, "enable"))) {
                                 char *unit_name;
                                 char **instances = NULL;
 
@@ -3367,10 +3366,8 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
                                         .action = PRESET_ENABLE,
                                         .instances = instances,
                                 };
-                        }
 
-                        parameter = first_word(line, "disable");
-                        if (parameter) {
+                        } else if ((parameter = first_word(line, "disable"))) {
                                 char *pattern;
 
                                 pattern = strdup(parameter);
@@ -3381,10 +3378,8 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
                                         .pattern = pattern,
                                         .action = PRESET_DISABLE,
                                 };
-                        }
 
-                        parameter = first_word(line, "ignore");
-                        if (parameter) {
+                        } else if ((parameter = first_word(line, "ignore"))) {
                                 char *pattern;
 
                                 pattern = strdup(parameter);
@@ -3397,7 +3392,7 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
                                 };
                         }
 
-                        if (rule.action) {
+                        if (rule.action != 0) {
                                 if (!GREEDY_REALLOC(ps.rules, ps.n_rules + 1))
                                         return -ENOMEM;