1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

systemctl,networkctl,busctl,backlight: use STRPTR_IN_SET

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2016-09-24 20:18:02 -04:00
parent c7bf9d5183
commit 1cf03a4f8e
4 changed files with 8 additions and 11 deletions

View 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

View 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) {

View 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

View 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);