mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
Transpose args in strv_fnmatch() to be more oo
This commit is contained in:
parent
d49dc81276
commit
2404701e67
@ -980,11 +980,11 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
|
||||
assert(prop);
|
||||
assert(color);
|
||||
|
||||
match_patterns = strv_fnmatch(u->id, patterns, 0);
|
||||
match_patterns = strv_fnmatch(patterns, u->id, 0);
|
||||
|
||||
if (!strv_isempty(arg_dot_from_patterns) &&
|
||||
!match_patterns &&
|
||||
!strv_fnmatch(u->id, arg_dot_from_patterns, 0))
|
||||
!strv_fnmatch(arg_dot_from_patterns, u->id, 0))
|
||||
return 0;
|
||||
|
||||
r = bus_get_unit_property_strv(bus, u->unit_path, prop, &units);
|
||||
@ -994,11 +994,11 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
|
||||
STRV_FOREACH(unit, units) {
|
||||
bool match_patterns2;
|
||||
|
||||
match_patterns2 = strv_fnmatch(*unit, patterns, 0);
|
||||
match_patterns2 = strv_fnmatch(patterns, *unit, 0);
|
||||
|
||||
if (!strv_isempty(arg_dot_to_patterns) &&
|
||||
!match_patterns2 &&
|
||||
!strv_fnmatch(*unit, arg_dot_to_patterns, 0))
|
||||
!strv_fnmatch(arg_dot_to_patterns, *unit, 0))
|
||||
continue;
|
||||
|
||||
if (!strv_isempty(patterns) && !match_patterns && !match_patterns2)
|
||||
|
@ -113,19 +113,19 @@ bool net_match_config(const struct ether_addr *match_mac,
|
||||
return false;
|
||||
|
||||
if (!strv_isempty(match_paths) &&
|
||||
(!dev_path || !strv_fnmatch(dev_path, match_paths, 0)))
|
||||
(!dev_path || !strv_fnmatch(match_paths, dev_path, 0)))
|
||||
return false;
|
||||
|
||||
if (!strv_isempty(match_drivers) &&
|
||||
(!dev_driver || !strv_fnmatch(dev_driver, match_drivers, 0)))
|
||||
(!dev_driver || !strv_fnmatch(match_drivers, dev_driver, 0)))
|
||||
return false;
|
||||
|
||||
if (!strv_isempty(match_types) &&
|
||||
(!dev_type || !strv_fnmatch_or_empty(dev_type, match_types, 0)))
|
||||
(!dev_type || !strv_fnmatch_or_empty(match_types, dev_type, 0)))
|
||||
return false;
|
||||
|
||||
if (!strv_isempty(match_names) &&
|
||||
(!dev_name || !strv_fnmatch_or_empty(dev_name, match_names, 0)))
|
||||
(!dev_name || !strv_fnmatch_or_empty(match_names, dev_name, 0)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -693,7 +693,7 @@ char **strv_reverse(char **l) {
|
||||
return l;
|
||||
}
|
||||
|
||||
bool strv_fnmatch(const char *s, char* const* patterns, int flags) {
|
||||
bool strv_fnmatch(char* const* patterns, const char *s, int flags) {
|
||||
char* const* p;
|
||||
|
||||
STRV_FOREACH(p, patterns)
|
||||
|
@ -146,10 +146,10 @@ void strv_print(char **l);
|
||||
|
||||
char **strv_reverse(char **l);
|
||||
|
||||
bool strv_fnmatch(const char *s, char* const* patterns, int flags);
|
||||
bool strv_fnmatch(char* const* patterns, const char *s, int flags);
|
||||
|
||||
static inline bool strv_fnmatch_or_empty(const char *s, char* const* patterns, int flags) {
|
||||
static inline bool strv_fnmatch_or_empty(char* const* patterns, const char *s, int flags) {
|
||||
assert(s);
|
||||
return strv_isempty(patterns) ||
|
||||
strv_fnmatch(s, patterns, flags);
|
||||
strv_fnmatch(patterns, s, flags);
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ static int compare_unit_info(const void *a, const void *b) {
|
||||
}
|
||||
|
||||
static bool output_show_unit(const UnitInfo *u, char **patterns) {
|
||||
if (!strv_fnmatch_or_empty(u->id, patterns, FNM_NOESCAPE))
|
||||
if (!strv_fnmatch_or_empty(patterns, u->id, FNM_NOESCAPE))
|
||||
return false;
|
||||
|
||||
if (arg_types) {
|
||||
@ -1247,7 +1247,7 @@ static int compare_unit_file_list(const void *a, const void *b) {
|
||||
}
|
||||
|
||||
static bool output_show_unit_file(const UnitFileList *u, char **patterns) {
|
||||
if (!strv_fnmatch_or_empty(basename(u->path), patterns, FNM_NOESCAPE))
|
||||
if (!strv_fnmatch_or_empty(patterns, basename(u->path), FNM_NOESCAPE))
|
||||
return false;
|
||||
|
||||
if (!strv_isempty(arg_types)) {
|
||||
@ -1720,7 +1720,7 @@ static int get_machine_properties(sd_bus *bus, struct machine_info *mi) {
|
||||
}
|
||||
|
||||
static bool output_show_machine(const char *name, char **patterns) {
|
||||
return strv_fnmatch_or_empty(name, patterns, FNM_NOESCAPE);
|
||||
return strv_fnmatch_or_empty(patterns, name, FNM_NOESCAPE);
|
||||
}
|
||||
|
||||
static int get_machine_list(
|
||||
@ -2073,7 +2073,7 @@ static void output_jobs_list(const struct job_info* jobs, unsigned n, bool skipp
|
||||
}
|
||||
|
||||
static bool output_show_job(struct job_info *job, char **patterns) {
|
||||
return strv_fnmatch_or_empty(job->name, patterns, FNM_NOESCAPE);
|
||||
return strv_fnmatch_or_empty(patterns, job->name, FNM_NOESCAPE);
|
||||
}
|
||||
|
||||
static int list_jobs(sd_bus *bus, char **args) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user