mirror of
https://github.com/systemd/systemd
synced 2024-10-06 16:21:34 +00:00
shared/install: use FOREACH_ARRAY at one more place
This commit is contained in:
parent
3e02c8d87d
commit
521a7c9bb9
|
@ -3398,6 +3398,8 @@ static int pattern_match_multiple_instances(
|
|||
_cleanup_free_ char *templated_name = NULL;
|
||||
int r;
|
||||
|
||||
assert(unit_name);
|
||||
|
||||
/* If no ret is needed or the rule itself does not have instances
|
||||
* initialized, we return not matching */
|
||||
if (!ret || !rule.instances)
|
||||
|
@ -3444,20 +3446,25 @@ static int pattern_match_multiple_instances(
|
|||
static int query_presets(const char *name, const UnitFilePresets *presets, char ***instance_name_list) {
|
||||
PresetAction action = PRESET_UNKNOWN;
|
||||
|
||||
assert(name);
|
||||
assert(presets);
|
||||
|
||||
if (!unit_name_is_valid(name, UNIT_NAME_ANY))
|
||||
return -EINVAL;
|
||||
|
||||
for (size_t i = 0; i < presets->n_rules; i++)
|
||||
if (pattern_match_multiple_instances(presets->rules[i], name, instance_name_list) > 0 ||
|
||||
fnmatch(presets->rules[i].pattern, name, FNM_NOESCAPE) == 0) {
|
||||
action = presets->rules[i].action;
|
||||
FOREACH_ARRAY(i, presets->rules, presets->n_rules)
|
||||
if (pattern_match_multiple_instances(*i, name, instance_name_list) > 0 ||
|
||||
fnmatch(i->pattern, name, FNM_NOESCAPE) == 0) {
|
||||
action = i->action;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
|
||||
case PRESET_UNKNOWN:
|
||||
log_debug("Preset files don't specify rule for %s. Enabling.", name);
|
||||
return PRESET_ENABLE;
|
||||
|
||||
case PRESET_ENABLE:
|
||||
if (instance_name_list && *instance_name_list)
|
||||
STRV_FOREACH(s, *instance_name_list)
|
||||
|
@ -3465,12 +3472,15 @@ static int query_presets(const char *name, const UnitFilePresets *presets, char
|
|||
else
|
||||
log_debug("Preset files say enable %s.", name);
|
||||
return PRESET_ENABLE;
|
||||
|
||||
case PRESET_DISABLE:
|
||||
log_debug("Preset files say disable %s.", name);
|
||||
return PRESET_DISABLE;
|
||||
|
||||
case PRESET_IGNORE:
|
||||
log_debug("Preset files say ignore %s.", name);
|
||||
return PRESET_IGNORE;
|
||||
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue