Coverity says:
> Pointer to local outside scope (RETURN_LOCAL)9.
> use_invalid: Using dirs, which points to an out-of-scope temporary variable of type char const *[5].
And indeed, the switch statement forms a scope. Let's use an if to
avoid creating a scope.
assert(scope >= 0);
assert(scope < _UNIT_FILE_SCOPE_MAX);
- switch (scope) {
- case UNIT_FILE_SYSTEM:
+ if (scope == UNIT_FILE_SYSTEM)
dirs = (const char* const*) CONF_PATHS_STRV("systemd/system-preset");
- break;
- case UNIT_FILE_GLOBAL:
- case UNIT_FILE_USER:
+ else if (IN_SET(scope, UNIT_FILE_GLOBAL, UNIT_FILE_USER))
dirs = (const char* const*) CONF_PATHS_USR_STRV("systemd/user-preset");
- break;
- default:
+ else
assert_not_reached("Invalid unit file scope");
- }
return conf_files_list_strv(files, ".preset", root_dir, 0, dirs);
}