systemctl,networkctl,busctl,backlight: use STRPTR_IN_SET
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 25 Sep 2016 00:18:02 +0000 (20:18 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 25 Sep 2016 00:22:05 +0000 (20:22 -0400)
src/backlight/backlight.c
src/libsystemd/sd-bus/busctl.c
src/network/networkctl.c
src/systemctl/systemctl.c

index 45be135..7c59f60 100644 (file)
@@ -167,7 +167,7 @@ static bool validate_device(struct udev *udev, struct udev_device *device) {
                         continue;
 
                 v = udev_device_get_sysattr_value(other, "type");
-                if (!streq_ptr(v, "platform") && !streq_ptr(v, "firmware"))
+                if (!STRPTR_IN_SET(v, "platform", "firmware"))
                         continue;
 
                 /* OK, so there's another backlight device, and it's a
index eb042e9..2c3f591 100644 (file)
@@ -2003,8 +2003,7 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        if (streq_ptr(argv[optind], "monitor") ||
-            streq_ptr(argv[optind], "capture")) {
+        if (STRPTR_IN_SET(argv[optind], "monitor", "capture")) {
 
                 r = sd_bus_set_monitor(bus, true);
                 if (r < 0) {
index d2df9b7..6f7f41b 100644 (file)
@@ -122,7 +122,7 @@ static void setup_state_to_color(const char *state, const char **on, const char
         } else if (streq_ptr(state, "configuring")) {
                 *on = ansi_highlight_yellow();
                 *off = ansi_normal();
-        } else if (streq_ptr(state, "failed") || streq_ptr(state, "linger")) {
+        } else if (STRPTR_IN_SET(state, "failed", "linger")) {
                 *on = ansi_highlight_red();
                 *off = ansi_normal();
         } else
index dc8f61b..0222489 100644 (file)
@@ -3622,7 +3622,7 @@ static void print_status_info(
         if (streq_ptr(i->active_state, "failed")) {
                 active_on = ansi_highlight_red();
                 active_off = ansi_normal();
-        } else if (streq_ptr(i->active_state, "active") || streq_ptr(i->active_state, "reloading")) {
+        } else if (STRPTR_IN_SET(i->active_state, "active", "reloading")) {
                 active_on = ansi_highlight_green();
                 active_off = ansi_normal();
         } else
@@ -3703,12 +3703,10 @@ static void print_status_info(
         if (!isempty(i->result) && !streq(i->result, "success"))
                 printf(" (Result: %s)", i->result);
 
-        timestamp = (streq_ptr(i->active_state, "active")      ||
-                     streq_ptr(i->active_state, "reloading"))   ? i->active_enter_timestamp :
-                    (streq_ptr(i->active_state, "inactive")    ||
-                     streq_ptr(i->active_state, "failed"))      ? i->inactive_enter_timestamp :
-                    streq_ptr(i->active_state, "activating")    ? i->inactive_exit_timestamp :
-                                                                  i->active_exit_timestamp;
+        timestamp = STRPTR_IN_SET(i->active_state, "active", "reloading") ? i->active_enter_timestamp :
+                    STRPTR_IN_SET(i->active_state, "inactive", "failed")  ? i->inactive_enter_timestamp :
+                    STRPTR_IN_SET(i->active_state, "activating")          ? i->inactive_exit_timestamp :
+                                                                            i->active_exit_timestamp;
 
         s1 = format_timestamp_relative(since1, sizeof(since1), timestamp);
         s2 = format_timestamp(since2, sizeof(since2), timestamp);