]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
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 45be135a231ba755450c17f63b992cc66cc8311d..7c59f60d5fa270c5aa138d5a250e0325728931f9 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 eb042e9c812bd8961e25bdda625de4b1e7481c77..2c3f591053d1f8219e65cfa3d7c9c89e3f6e9954 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 d2df9b7560286a09829d91b6ac7907f28aa3729b..6f7f41bf7d2c5e8f98249b013308e92936e39662 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 dc8f61b049e2ac176e0a5fd2f868f24426782bf2..02224896ff61591fd218821f42e19751b02f71c6 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);