From c679e12af1f2985c4ab4346db8e53ca14f4cc626 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 1 Sep 2018 23:13:54 +0900 Subject: [PATCH] tree-wide: drop unnecessary initializations --- src/login/logind-core.c | 2 +- src/login/logind-session-device.c | 11 ++++++----- src/login/sysfs-show.c | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/login/logind-core.c b/src/login/logind-core.c index d2351b93408..32e1c3435ad 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -305,7 +305,7 @@ int manager_process_button_device(Manager *m, sd_device *d) { button_free(b); } else { - const char *sn = NULL; + const char *sn; r = manager_add_button(m, sysname, &b); if (r < 0) diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index 0b798cf0a24..e1e3e8b4980 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -268,17 +268,18 @@ static DeviceType detect_device_type(sd_device *dev) { static int session_device_verify(SessionDevice *sd) { _cleanup_(sd_device_unrefp) sd_device *p = NULL; + const char *sp, *node; sd_device *dev; - const char *sp = NULL, *node; int r; - if (sd_device_new_from_devnum(&p, 'c', sd->dev) < 0) - return -ENODEV; + r = sd_device_new_from_devnum(&p, 'c', sd->dev); + if (r < 0) + return r; dev = p; - (void) sd_device_get_syspath(dev, &sp); - if (sd_device_get_devname(dev, &node) < 0) + if (sd_device_get_syspath(dev, &sp) < 0 || + sd_device_get_devname(dev, &node) < 0) return -EINVAL; /* detect device type so we can find the correct sysfs parent */ diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c index 758f9c2c1de..192c95107b7 100644 --- a/src/login/sysfs-show.c +++ b/src/login/sysfs-show.c @@ -40,7 +40,7 @@ static int show_sysfs_one( max_width = n_columns; while (*i_dev < n_dev) { - const char *sysfs, *sn, *name = NULL, *subsystem = NULL, *sysname = NULL; + const char *sysfs, *sn, *name = NULL, *subsystem, *sysname; _cleanup_free_ char *k = NULL, *l = NULL; size_t lookahead; bool is_master; @@ -53,7 +53,10 @@ static int show_sysfs_one( sn = "seat0"; /* Explicitly also check for tag 'seat' here */ - if (!streq(seat, sn) || sd_device_has_tag(dev_list[*i_dev], "seat") <= 0) { + if (!streq(seat, sn) || + sd_device_has_tag(dev_list[*i_dev], "seat") <= 0 || + sd_device_get_subsystem(dev_list[*i_dev], &subsystem) < 0 || + sd_device_get_sysname(dev_list[*i_dev], &sysname) < 0) { (*i_dev)++; continue; } @@ -63,9 +66,6 @@ static int show_sysfs_one( if (sd_device_get_sysattr_value(dev_list[*i_dev], "name", &name) < 0) (void) sd_device_get_sysattr_value(dev_list[*i_dev], "id", &name); - (void) sd_device_get_subsystem(dev_list[*i_dev], &subsystem); - (void) sd_device_get_sysname(dev_list[*i_dev], &sysname); - /* Look if there's more coming after this */ for (lookahead = *i_dev + 1; lookahead < n_dev; lookahead++) { const char *lookahead_sysfs; -- 2.47.3