chiark / gitweb /
Transpose args in strv_fnmatch() to be more oo
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 16 Feb 2015 19:04:36 +0000 (14:04 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 16 Feb 2015 19:04:36 +0000 (14:04 -0500)
src/analyze/analyze.c
src/libsystemd-network/network-internal.c
src/shared/strv.c
src/shared/strv.h
src/systemctl/systemctl.c

index 1e2a6bb..591b4ab 100644 (file)
@@ -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)
index 81f90aa..b8e4e21 100644 (file)
@@ -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;
index 2268bf6..e27ac68 100644 (file)
@@ -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)
index a899395..518c4c2 100644 (file)
@@ -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);
 }
index 66bfd0e..21cb898 100644 (file)
@@ -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) {