tree-wide: drop unnecessary initializations
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 1 Sep 2018 14:13:54 +0000 (23:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 23 Sep 2018 08:18:50 +0000 (17:18 +0900)
src/login/logind-core.c
src/login/logind-session-device.c
src/login/sysfs-show.c

index d2351b9..32e1c34 100644 (file)
@@ -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)
index 0b798cf..e1e3e8b 100644 (file)
@@ -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 */
index 758f9c2..192c951 100644 (file)
@@ -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;