]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
device-util: Declare iterator variables inline
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 12 Jul 2023 06:52:12 +0000 (08:52 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 12 Jul 2023 18:05:18 +0000 (20:05 +0200)
37 files changed:
src/backlight/backlight.c
src/core/device.c
src/core/swap.c
src/dissect/dissect.c
src/home/homed-manager.c
src/journal/journald-kmsg.c
src/libsystemd/sd-device/device-enumerator.c
src/libsystemd/sd-device/device-monitor.c
src/libsystemd/sd-device/device-private.c
src/libsystemd/sd-device/device-util.h
src/libsystemd/sd-device/test-sd-device-monitor.c
src/libsystemd/sd-device/test-sd-device-thread.c
src/libsystemd/sd-device/test-sd-device.c
src/libudev/libudev-device.c
src/login/logind-core.c
src/login/logind-dbus.c
src/login/logind.c
src/mount/mount-tool.c
src/network/networkd-sriov.c
src/shared/battery-util.c
src/shared/blockdev-util.c
src/shared/devnode-acl.c
src/shared/sleep-util.c
src/shared/udev-util.c
src/shutdown/detach-dm.c
src/shutdown/detach-loopback.c
src/shutdown/detach-md.c
src/udev/udev-builtin-keyboard.c
src/udev/udev-builtin-net_id.c
src/udev/udev-event.c
src/udev/udev-node.c
src/udev/udev-rules.c
src/udev/udevadm-info.c
src/udev/udevadm-monitor.c
src/udev/udevadm-test.c
src/udev/udevadm-wait.c
src/udev/udevd.c

index e66477f3288b05438219dfd13be6127c51b62e0d..a3842088799af6deebddf351af6d4c693a84d0ca 100644 (file)
@@ -47,7 +47,6 @@ static int help(void) {
 
 static int has_multiple_graphics_cards(void) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *dev;
         bool found = false;
         int r;
 
@@ -173,7 +172,7 @@ static int same_device(sd_device *a, sd_device *b) {
 static int validate_device(sd_device *device) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *enumerate = NULL;
         const char *v, *sysname, *subsystem;
-        sd_device *parent, *other;
+        sd_device *parent;
         int r;
 
         assert(device);
index 60ab59c53b62178418de1df6f1bad52d85d9cb93..fd87b40306e3c3a733d94f2362043d725ef3479d 100644 (file)
@@ -800,7 +800,7 @@ static int device_setup_devlink_unit_one(Manager *m, const char *devlink, Set **
 
 static int device_setup_extra_units(Manager *m, sd_device *dev, Set **ready_units, Set **not_ready_units) {
         _cleanup_strv_free_ char **aliases = NULL;
-        const char *devlink, *syspath, *devname = NULL;
+        const char *syspath, *devname = NULL;
         Device *l;
         int r;
 
@@ -1017,7 +1017,6 @@ static void device_shutdown(Manager *m) {
 
 static void device_enumerate(Manager *m) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *dev;
         int r;
 
         assert(m);
index 73cf320bfd22062ad9e37e93e9075ea02c4c95c7..6fc5782bc8c690c85b1b83574cbcc60f2f44bc65 100644 (file)
@@ -491,7 +491,7 @@ fail:
 
 static void swap_process_new(Manager *m, const char *device, int prio, bool set_flags) {
         _cleanup_(sd_device_unrefp) sd_device *d = NULL;
-        const char *dn, *devlink;
+        const char *dn;
         struct stat st, st_link;
         int r;
 
@@ -1405,7 +1405,7 @@ fail:
 
 int swap_process_device_new(Manager *m, sd_device *dev) {
         _cleanup_free_ char *e = NULL;
-        const char *dn, *devlink;
+        const char *dn;
         Unit *u;
         int r;
 
index 253e732404b2226e9ef653e2b5309492208e348b..893fa4f03402e87df4311c81ae6d0aed144bada0 100644 (file)
@@ -1699,7 +1699,6 @@ static int action_detach(const char *path) {
 
         } else if (S_ISREG(st.st_mode)) {
                 _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-                sd_device *d;
 
                 /* If a regular file is specified, search for a loopback block device that is backed by it */
 
index 9db8b9ee068e4d0b377c7c8a83b36f66de3ab11d..addea113b4712949c70e09ea43a37d68c23229a0 100644 (file)
@@ -1337,7 +1337,6 @@ static int manager_watch_devices(Manager *m) {
 
 static int manager_enumerate_devices(Manager *m) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
         int r;
 
         assert(m);
index 83082c4e94f537473c0828450dc4ed77dc51076d..de94dc6041cb1f466d587ad26c0f4aa941758534 100644 (file)
@@ -237,12 +237,12 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
                         }
 
                         j = 0;
-                        FOREACH_DEVICE_DEVLINK(d, g) {
+                        FOREACH_DEVICE_DEVLINK(d, link) {
 
                                 if (j >= N_IOVEC_UDEV_FIELDS)
                                         break;
 
-                                b = strjoin("_UDEV_DEVLINK=", g);
+                                b = strjoin("_UDEV_DEVLINK=", link);
                                 if (b) {
                                         iovec[n++] = IOVEC_MAKE_STRING(b);
                                         z++;
index f3f59e2ac3f3a8c7b927f49eca2e20b3f26ed041..e072d976d3856928b580374d9aa28981501c9fe8 100644 (file)
@@ -471,9 +471,7 @@ static bool match_property(sd_device_enumerator *enumerator, sd_device *device)
         if (hashmap_isempty(enumerator->match_property))
                 return true;
 
-        HASHMAP_FOREACH_KEY(value_patterns, property_pattern, enumerator->match_property) {
-                const char *property, *value;
-
+        HASHMAP_FOREACH_KEY(value_patterns, property_pattern, enumerator->match_property)
                 FOREACH_DEVICE_PROPERTY(device, property, value) {
                         if (fnmatch(property_pattern, property, 0) != 0)
                                 continue;
@@ -481,7 +479,6 @@ static bool match_property(sd_device_enumerator *enumerator, sd_device *device)
                         if (strv_fnmatch(value_patterns, value))
                                 return true;
                 }
-        }
 
         return false;
 }
index a23b5e7847024c3298cb75f0586f2e778a722f8b..10d455888f64cc6b174be961f92b15cdde891df6 100644 (file)
@@ -681,8 +681,8 @@ int device_monitor_send_device(
 
         /* add tag bloom filter */
         tag_bloom_bits = 0;
-        FOREACH_DEVICE_TAG(device, val)
-                tag_bloom_bits |= string_bloom64(val);
+        FOREACH_DEVICE_TAG(device, tag)
+                tag_bloom_bits |= string_bloom64(tag);
 
         if (tag_bloom_bits > 0) {
                 nlh.filter_tag_bloom_hi = htobe32(tag_bloom_bits >> 32);
index 52cf9f2ab8c7b6299b73fcc4d26c0b23e6b44e9e..0edabfbfbb4ff63b0c00ae718511d6f64dbc755b 100644 (file)
@@ -525,7 +525,6 @@ int device_new_from_nulstr(sd_device **ret, char *nulstr, size_t len) {
 static int device_update_properties_bufs(sd_device *device) {
         _cleanup_free_ char **buf_strv = NULL, *buf_nulstr = NULL;
         size_t nulstr_len = 0, num = 0;
-        const char *val, *prop;
 
         assert(device);
 
@@ -728,7 +727,6 @@ static int device_tag(sd_device *device, const char *tag, bool add) {
 }
 
 int device_tag_index(sd_device *device, sd_device *device_old, bool add) {
-        const char *tag;
         int r = 0, k;
 
         if (add && device_old)
@@ -819,11 +817,9 @@ int device_update_db(sd_device *device) {
         }
 
         if (has_info) {
-                const char *property, *value, *tag;
+                const char *property, *value, *ct;
 
                 if (major(device->devnum) > 0) {
-                        const char *devlink;
-
                         FOREACH_DEVICE_DEVLINK(device, devlink)
                                 fprintf(f, "S:%s\n", devlink + STRLEN("/dev/"));
 
@@ -840,8 +836,8 @@ int device_update_db(sd_device *device) {
                 FOREACH_DEVICE_TAG(device, tag)
                         fprintf(f, "G:%s\n", tag); /* Any tag */
 
-                SET_FOREACH(tag, device->current_tags)
-                        fprintf(f, "Q:%s\n", tag); /* Current tag */
+                SET_FOREACH(ct, device->current_tags)
+                        fprintf(f, "Q:%s\n", ct); /* Current tag */
 
                 /* Always write the latest database version here, instead of the value stored in
                  * device->database_version, as which may be 0. */
index a1b5e91edf664276feef8634b3daf8be49e3f02c..0316a600332886788b8109f9cc2be689ad84983b 100644 (file)
         unref_and_replace_full(a, b, sd_device_ref, sd_device_unref)
 
 #define FOREACH_DEVICE_PROPERTY(device, key, value)                \
-        for (key = sd_device_get_property_first(device, &(value)); \
+        for (const char *value, *key = sd_device_get_property_first(device, &(value)); \
              key;                                                  \
              key = sd_device_get_property_next(device, &(value)))
 
 #define FOREACH_DEVICE_TAG(device, tag)             \
-        for (tag = sd_device_get_tag_first(device); \
+        for (const char *tag = sd_device_get_tag_first(device); \
              tag;                                   \
              tag = sd_device_get_tag_next(device))
 
 #define FOREACH_DEVICE_CURRENT_TAG(device, tag)             \
-        for (tag = sd_device_get_current_tag_first(device); \
+        for (const char *tag = sd_device_get_current_tag_first(device); \
              tag;                                   \
              tag = sd_device_get_current_tag_next(device))
 
 #define FOREACH_DEVICE_SYSATTR(device, attr)             \
-        for (attr = sd_device_get_sysattr_first(device); \
+        for (const char *attr = sd_device_get_sysattr_first(device); \
              attr;                                       \
              attr = sd_device_get_sysattr_next(device))
 
 #define FOREACH_DEVICE_DEVLINK(device, devlink)             \
-        for (devlink = sd_device_get_devlink_first(device); \
+        for (const char *devlink = sd_device_get_devlink_first(device); \
              devlink;                                   \
              devlink = sd_device_get_devlink_next(device))
 
 #define _FOREACH_DEVICE_CHILD(device, child, suffix_ptr)                \
-        for (child = sd_device_get_child_first(device, suffix_ptr);     \
+        for (sd_device *child = sd_device_get_child_first(device, suffix_ptr);     \
              child;                                                     \
              child = sd_device_get_child_next(device, suffix_ptr))
 
         _FOREACH_DEVICE_CHILD(device, child, &suffix)
 
 #define FOREACH_DEVICE(enumerator, device)                               \
-        for (device = sd_device_enumerator_get_device_first(enumerator); \
+        for (sd_device *device = sd_device_enumerator_get_device_first(enumerator); \
              device;                                                     \
              device = sd_device_enumerator_get_device_next(enumerator))
 
 #define FOREACH_SUBSYSTEM(enumerator, device)                               \
-        for (device = sd_device_enumerator_get_subsystem_first(enumerator); \
+        for (sd_device *device = sd_device_enumerator_get_subsystem_first(enumerator); \
              device;                                                        \
              device = sd_device_enumerator_get_subsystem_next(enumerator))
 
index 4654ef709d10a34e9547cdfac9f775da6b6dce31..e124e0021c352240641330001978c4b65c3087e0 100644 (file)
@@ -53,7 +53,7 @@ static void test_receive_device_fail(void) {
 
 static void test_send_receive_one(sd_device *device, bool subsystem_filter, bool tag_filter, bool use_bpf) {
         _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor_server = NULL, *monitor_client = NULL;
-        const char *syspath, *subsystem, *tag, *devtype = NULL;
+        const char *syspath, *subsystem, *devtype = NULL;
 
         log_device_info(device, "/* %s(subsystem_filter=%s, tag_filter=%s, use_bpf=%s) */", __func__,
                         true_false(subsystem_filter), true_false(tag_filter), true_false(use_bpf));
@@ -90,7 +90,6 @@ static void test_subsystem_filter(sd_device *device) {
         _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor_server = NULL, *monitor_client = NULL;
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         const char *syspath, *subsystem;
-        sd_device *d;
 
         log_device_info(device, "/* %s */", __func__);
 
@@ -131,7 +130,6 @@ static void test_tag_filter(sd_device *device) {
         _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor_server = NULL, *monitor_client = NULL;
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         const char *syspath;
-        sd_device *d;
 
         log_device_info(device, "/* %s */", __func__);
 
@@ -170,7 +168,6 @@ static void test_sysattr_filter(sd_device *device, const char *sysattr) {
         _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor_server = NULL, *monitor_client = NULL;
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         const char *syspath, *sysattr_value;
-        sd_device *d;
 
         log_device_info(device, "/* %s(%s) */", __func__, sysattr);
 
@@ -216,7 +213,7 @@ static void test_parent_filter(sd_device *device) {
         _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor_server = NULL, *monitor_client = NULL;
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         const char *syspath, *parent_syspath;
-        sd_device *parent, *d;
+        sd_device *parent;
         int r;
 
         log_device_info(device, "/* %s */", __func__);
index 644f3c2aeeec87c8411892863fe0a774d07a7063..c99d179b3351a079807106e7deebe9b20e837149 100644 (file)
@@ -27,7 +27,6 @@ static void* thread(void *p) {
 int main(int argc, char *argv[]) {
         sd_device *loopback;
         pthread_t t;
-        const char *key, *value;
         int r;
 
         r = sd_device_new_from_syspath(&loopback, "/sys/class/net/lo");
index fb3ae9f329cb4a39d9b309b37121f7779e7a0eac..43376a203602445ffa6a8fbefd4fb0d3e1e54770 100644 (file)
@@ -194,7 +194,6 @@ static void test_sd_device_one(sd_device *d) {
 
 TEST(sd_device_enumerator_devices) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
 
         assert_se(sd_device_enumerator_new(&e) >= 0);
         assert_se(sd_device_enumerator_allow_uninitialized(e) >= 0);
@@ -211,7 +210,6 @@ TEST(sd_device_enumerator_devices) {
 
 TEST(sd_device_enumerator_subsystems) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
 
         assert_se(sd_device_enumerator_new(&e) >= 0);
         assert_se(sd_device_enumerator_allow_uninitialized(e) >= 0);
@@ -227,7 +225,7 @@ static void test_sd_device_enumerator_filter_subsystem_one(
 
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         unsigned n_new_dev = 0, n_removed_dev = 0;
-        sd_device *d;
+        sd_device *dev;
 
         assert_se(sd_device_enumerator_new(&e) >= 0);
         assert_se(sd_device_enumerator_add_match_subsystem(e, subsystem, true) >= 0);
@@ -248,14 +246,14 @@ static void test_sd_device_enumerator_filter_subsystem_one(
                 assert_se(!sd_device_unref(t));
         }
 
-        HASHMAP_FOREACH(d, h) {
+        HASHMAP_FOREACH(dev, h) {
                 const char *syspath;
 
-                assert_se(sd_device_get_syspath(d, &syspath) >= 0);
+                assert_se(sd_device_get_syspath(dev, &syspath) >= 0);
                 log_warning("Device removed: subsystem:%s syspath:%s", subsystem, syspath);
                 n_removed_dev++;
 
-                assert_se(!sd_device_unref(d));
+                assert_se(!sd_device_unref(dev));
         }
 
         hashmap_free(h);
@@ -268,7 +266,6 @@ static bool test_sd_device_enumerator_filter_subsystem_trial(void) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         _cleanup_hashmap_free_ Hashmap *subsystems = NULL;
         unsigned n_new_dev = 0, n_removed_dev = 0;
-        sd_device *d;
         Hashmap *h;
         char *s;
 
@@ -405,7 +402,6 @@ TEST(sd_device_enumerator_add_match_property) {
 static void check_parent_match(sd_device_enumerator *e, sd_device *dev) {
         const char *syspath;
         bool found = false;
-        sd_device *d;
 
         assert_se(sd_device_get_syspath(dev, &syspath) >= 0);
 
@@ -429,7 +425,6 @@ static void check_parent_match(sd_device_enumerator *e, sd_device *dev) {
 
 TEST(sd_device_enumerator_add_match_parent) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *dev;
         int r;
 
         assert_se(sd_device_enumerator_new(&e) >= 0);
@@ -475,7 +470,6 @@ TEST(sd_device_enumerator_add_match_parent) {
 
 TEST(sd_device_get_child) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *dev;
         int r;
 
         assert_se(sd_device_enumerator_new(&e) >= 0);
@@ -490,7 +484,7 @@ TEST(sd_device_get_child) {
 
         FOREACH_DEVICE(e, dev) {
                 const char *syspath, *parent_syspath, *expected_suffix, *suffix;
-                sd_device *parent, *child;
+                sd_device *parent;
                 bool found = false;
 
                 assert_se(sd_device_get_syspath(dev, &syspath) >= 0);
@@ -580,7 +574,6 @@ TEST(sd_device_new_from_nulstr) {
 TEST(sd_device_new_from_path) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         _cleanup_(rm_rf_physical_and_freep) char *tmpdir = NULL;
-        sd_device *dev;
         int r;
 
         assert_se(mkdtemp_malloc("/tmp/test-sd-device.XXXXXXX", &tmpdir) >= 0);
index 8091ff1d618c9aaf0eca26fd6f0ed82ddcad0675..7b9f54c976bf6caf4b73477c48e912f176049c58 100644 (file)
@@ -635,8 +635,6 @@ _public_ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev
 
         if (device_get_devlinks_generation(udev_device->device) != udev_device->devlinks_generation ||
             !udev_device->devlinks_read) {
-                const char *devlink;
-
                 udev_list_cleanup(udev_device->devlinks);
 
                 FOREACH_DEVICE_DEVLINK(udev_device->device, devlink)
@@ -667,8 +665,6 @@ _public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct ud
 
         if (device_get_properties_generation(udev_device->device) != udev_device->properties_generation ||
             !udev_device->properties_read) {
-                const char *key, *value;
-
                 udev_list_cleanup(udev_device->properties);
 
                 FOREACH_DEVICE_PROPERTY(udev_device->device, key, value)
@@ -787,8 +783,6 @@ _public_ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_
         assert_return_errno(udev_device, NULL, EINVAL);
 
         if (!udev_device->sysattrs_read) {
-                const char *sysattr;
-
                 udev_list_cleanup(udev_device->sysattrs);
 
                 FOREACH_DEVICE_SYSATTR(udev_device->device, sysattr)
@@ -842,8 +836,6 @@ _public_ struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_dev
 
         if (device_get_tags_generation(udev_device->device) != udev_device->all_tags_generation ||
             !udev_device->all_tags_read) {
-                const char *tag;
-
                 udev_list_cleanup(udev_device->all_tags);
 
                 FOREACH_DEVICE_TAG(udev_device->device, tag)
@@ -862,8 +854,6 @@ _public_ struct udev_list_entry *udev_device_get_current_tags_list_entry(struct
 
         if (device_get_tags_generation(udev_device->device) != udev_device->current_tags_generation ||
             !udev_device->current_tags_read) {
-                const char *tag;
-
                 udev_list_cleanup(udev_device->current_tags);
 
                 FOREACH_DEVICE_CURRENT_TAG(udev_device->device, tag)
index df67e5509bb24951c631786bad42ac97d7b9497f..af86e92c016ef9a6dd6b9cd3f2bbf798ef3c990e 100644 (file)
@@ -565,7 +565,6 @@ static bool manager_is_docked(Manager *m) {
 
 static int manager_count_external_displays(Manager *m) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
         int r, n = 0;
 
         r = sd_device_enumerator_new(&e);
index 0d4ab28b4d4eb215afc53469bb12aa673da8b091..b3a36d0d058df4682387d70e3eba5f8564b932be 100644 (file)
@@ -1296,7 +1296,7 @@ static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bu
         return sd_bus_reply_method_return(message, NULL);
 }
 
-static int trigger_device(Manager *m, sd_device *d) {
+static int trigger_device(Manager *m, sd_device *parent) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         int r;
 
@@ -1310,8 +1310,8 @@ static int trigger_device(Manager *m, sd_device *d) {
         if (r < 0)
                 return r;
 
-        if (d) {
-                r = sd_device_enumerator_add_match_parent(e, d);
+        if (parent) {
+                r = sd_device_enumerator_add_match_parent(e, parent);
                 if (r < 0)
                         return r;
         }
index 8323bcc0cb25553dab7948f05b2517728e1efc54..f30f7f9370485c42f92aaa02641a380d2366b34e 100644 (file)
@@ -190,7 +190,6 @@ static Manager* manager_free(Manager *m) {
 
 static int manager_enumerate_devices(Manager *m) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
         int r;
 
         assert(m);
@@ -219,7 +218,6 @@ static int manager_enumerate_devices(Manager *m) {
 
 static int manager_enumerate_buttons(Manager *m) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
         int r;
 
         assert(m);
index dd07e16c725645ba4bb9db8bbffd0a83f2ef4eb0..89bf7fd80d20751f97da19977d0bc1af19bb96d1 100644 (file)
@@ -779,7 +779,6 @@ static int find_mount_points(const char *what, char ***list) {
 
 static int find_loop_device(const char *backing_file, sd_device **ret) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *dev;
         int r;
 
         assert(backing_file);
@@ -1366,7 +1365,6 @@ enum {
 static int list_devices(void) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         _cleanup_(table_unrefp) Table *table = NULL;
-        sd_device *d;
         unsigned c;
         int r;
 
index 77ada236025a16d05e64d0458584b4a37b3dc99c..1f205b7468e7384de33ef883b867f31bb9c66132 100644 (file)
@@ -230,7 +230,7 @@ static int link_set_sr_iov_phys_port(Link *link) {
 
 static int link_set_sr_iov_virt_ports(Link *link) {
         const char *dev_port, *name;
-        sd_device *pci_dev, *child;
+        sd_device *pci_dev;
         int r;
 
         assert(link);
index 43d72f9db751303b928109d80d5a8fa5d35ff4e4..71ee89a5498d295c9827f8af9c9c9f0da8ec28a5 100644 (file)
@@ -12,7 +12,7 @@
 static int device_is_power_sink(sd_device *device) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         bool found_source = false, found_sink = false;
-        sd_device *parent, *d;
+        sd_device *parent;
         int r;
 
         assert(device);
@@ -109,7 +109,6 @@ static bool battery_is_discharging(sd_device *d) {
 int on_ac_power(void) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         bool found_ac_online = false, found_discharging_battery = false;
-        sd_device *d;
         int r;
 
         r = sd_device_enumerator_new(&e);
@@ -234,7 +233,6 @@ int battery_read_capacity_percentage(sd_device *dev) {
 int battery_is_discharging_and_low(void) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         bool unsure = false, found_low = false;
-        sd_device *dev;
         int r;
 
          /* We have not used battery capacity_level since value is set to full
index 3d03eedcf0316865a6267ce1cec7c7a6b4525b39..c6ccab081e338af9afb1797538bf0e5c1e4b4efc 100644 (file)
@@ -107,7 +107,6 @@ int block_device_get_whole_disk(sd_device *dev, sd_device **ret) {
 static int block_device_get_originating(sd_device *dev, sd_device **ret) {
         _cleanup_(sd_device_unrefp) sd_device *first_found = NULL;
         const char *suffix;
-        sd_device *child;
         dev_t devnum = 0;  /* avoid false maybe-uninitialized warning */
 
         /* For the specified block device tries to chase it through the layers, in case LUKS-style DM
@@ -665,7 +664,6 @@ int block_device_remove_all_partitions(sd_device *dev, int fd) {
         _cleanup_(sd_device_unrefp) sd_device *dev_unref = NULL;
         _cleanup_close_ int fd_close = -EBADF;
         bool has_partitions = false;
-        sd_device *part;
         int r, k = 0;
 
         assert(dev || fd >= 0);
index 5911c2f84d6c93c3c4865a4631567e4f868b9457..92a2aff3dc29f3527da5399982cb8b095b830d91 100644 (file)
@@ -143,7 +143,6 @@ int devnode_acl_all(const char *seat,
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         _cleanup_set_free_ Set *nodes = NULL;
         _cleanup_closedir_ DIR *dir = NULL;
-        sd_device *d;
         char *n;
         int r;
 
index 1027ecce05cac9b1f9b1655d38b3a4db2dd89aab..d7277399fba17734a8f09b75d82489245a2462ee 100644 (file)
@@ -143,7 +143,6 @@ int get_capacity_by_name(Hashmap *capacities_by_name, const char *name) {
 int fetch_batteries_capacity_by_name(Hashmap **ret) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         _cleanup_hashmap_free_ Hashmap *batteries_capacity_by_name = NULL;
-        sd_device *dev;
         int r;
 
         assert(ret);
@@ -334,7 +333,6 @@ int estimate_battery_discharge_rate_per_hour(
                 usec_t after_timestamp) {
 
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *dev;
         bool trunc = true;
         int r;
 
@@ -394,7 +392,6 @@ int estimate_battery_discharge_rate_per_hour(
 int get_total_suspend_interval(Hashmap *last_capacity, usec_t *ret) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         usec_t total_suspend_interval = 0;
-        sd_device *dev;
         int r;
 
         assert(last_capacity);
@@ -450,7 +447,6 @@ int get_total_suspend_interval(Hashmap *last_capacity, usec_t *ret) {
 /* Return true if all batteries have acpi_btp support */
 int battery_trip_point_alarm_exists(void) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *dev;
         int r;
 
         r = battery_enumerator_new(&e);
index 088eb0fe9ab1b843397b46159179ddbb70071340..3e81234dc1f3d7e8815141f6070b1b374cdeedaf 100644 (file)
@@ -165,8 +165,8 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
         if (data->devlink) {
                 const char *devlink;
 
-                FOREACH_DEVICE_DEVLINK(device, devlink)
-                        if (path_equal(devlink, data->devlink))
+                FOREACH_DEVICE_DEVLINK(device, link)
+                        if (path_equal(link, data->devlink))
                                 goto found;
 
                 if (sd_device_get_devname(device, &devlink) >= 0 && path_equal(devlink, data->devlink))
index 71be74377d536bc8e949dac43bc5351e21f82f5e..8b8f72d678b1ac26fbbccdaad5140f7dcdeb14b6 100644 (file)
@@ -42,7 +42,6 @@ static void device_mapper_list_free(DeviceMapper **head) {
 
 static int dm_list_get(DeviceMapper **head) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
         int r;
 
         assert(head);
index f45960856bcd9372121c586dd3ce403ae926b195..267509f7d02eb96f7b140906b9f1a881f94e3373 100644 (file)
@@ -44,7 +44,6 @@ static void loopback_device_list_free(LoopbackDevice **head) {
 
 static int loopback_list_get(LoopbackDevice **head) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
         int r;
 
         assert(head);
index ae592f6f31ddd13236e0a782571b48307c8b3588..2dbb866902d2bd9a508fb71e1d08d9ec36591c5a 100644 (file)
@@ -44,7 +44,6 @@ static void raid_device_list_free(RaidDevice **head) {
 
 static int md_list_get(RaidDevice **head) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        sd_device *d;
         int r;
 
         assert(head);
index da67c2be1c866ce117d2fb16c624ef05b7e928db..3903bc463f3661c29a718f516b41d18793f91bb3 100644 (file)
@@ -164,7 +164,7 @@ static int builtin_keyboard(UdevEvent *event, int argc, char *argv[], bool test)
         unsigned release[1024];
         unsigned release_count = 0;
         _cleanup_close_ int fd = -EBADF;
-        const char *node, *key, *value;
+        const char *node;
         int has_abs = -1, r;
 
         r = sd_device_get_devname(dev, &node);
index 000839cac95c1104e07db9849ace8df32a6553f3..0028fb39f4f18f60b0d01f153c8a786163950cd0 100644 (file)
@@ -110,7 +110,6 @@ static sd_device *skip_virtio(sd_device *dev) {
 static int get_virtfn_info(sd_device *pcidev, sd_device **ret_physfn_pcidev, char **ret_suffix) {
         _cleanup_(sd_device_unrefp) sd_device *physfn_pcidev = NULL;
         const char *syspath, *name;
-        sd_device *child;
         int r;
 
         assert(pcidev);
@@ -619,7 +618,7 @@ static int names_platform(sd_device *dev, NetNames *names, bool test) {
 
 static int dev_devicetree_onboard(sd_device *dev, NetNames *names) {
         _cleanup_(sd_device_unrefp) sd_device *aliases_dev = NULL, *ofnode_dev = NULL, *devicetree_dev = NULL;
-        const char *alias, *ofnode_path, *ofnode_syspath, *devicetree_syspath;
+        const char *ofnode_path, *ofnode_syspath, *devicetree_syspath;
         sd_device *parent;
         int r;
 
index 296c0e344c1a7fadef7beeb5f4cc1df9e77c9e14..31547b76794a363f412dd8a1e5584df8f05f5c95 100644 (file)
@@ -411,11 +411,11 @@ static ssize_t udev_event_subst_format(
                 }
                 break;
         case FORMAT_SUBST_LINKS:
-                FOREACH_DEVICE_DEVLINK(dev, val) {
+                FOREACH_DEVICE_DEVLINK(dev, link) {
                         if (s == dest)
-                                strpcpy_full(&s, l, val + STRLEN("/dev/"), &truncated);
+                                strpcpy_full(&s, l, link + STRLEN("/dev/"), &truncated);
                         else
-                                strpcpyl_full(&s, l, &truncated, " ", val + STRLEN("/dev/"), NULL);
+                                strpcpyl_full(&s, l, &truncated, " ", link + STRLEN("/dev/"), NULL);
                         if (truncated)
                                 break;
                 }
@@ -1107,7 +1107,6 @@ static int event_execute_rules_on_remove(
 }
 
 static int copy_all_tags(sd_device *d, sd_device *s) {
-        const char *tag;
         int r;
 
         assert(d);
index 1bc2eda76490ddf416b866fe209559ac06e758b1..75845413cf0281b85ad23ae64fa83743a02783b8 100644 (file)
@@ -531,7 +531,6 @@ static int device_get_devpath_by_devnum(sd_device *dev, char **ret) {
 
 int udev_node_update(sd_device *dev, sd_device *dev_old) {
         _cleanup_free_ char *filename = NULL;
-        const char *devlink;
         int r;
 
         assert(dev);
@@ -577,7 +576,6 @@ int udev_node_update(sd_device *dev, sd_device *dev_old) {
 
 int udev_node_remove(sd_device *dev) {
         _cleanup_free_ char *filename = NULL;
-        const char *devlink;
         int r;
 
         assert(dev);
index 265d328cd37df361014aa14b463f9d209ad06086..88846ae275a056e9ef7d955289024d03dd393f94 100644 (file)
@@ -1780,7 +1780,6 @@ static int get_property_from_string(char *line, char **ret_key, char **ret_value
 }
 
 static int import_parent_into_properties(sd_device *dev, const char *filter) {
-        const char *key, *val;
         sd_device *parent;
         int r;
 
@@ -1896,14 +1895,11 @@ static int udev_rule_apply_token_to_event(
 
                 return token_match_string(token, val);
         }
-        case TK_M_DEVLINK: {
-                const char *val;
-
+        case TK_M_DEVLINK:
                 FOREACH_DEVICE_DEVLINK(dev, val)
                         if (token_match_string(token, strempty(startswith(val, "/dev/"))) == (token->op == OP_MATCH))
                                 return token->op == OP_MATCH;
                 return token->op == OP_NOMATCH;
-        }
         case TK_M_NAME:
                 return token_match_string(token, event->name);
         case TK_M_ENV: {
@@ -1928,14 +1924,11 @@ static int udev_rule_apply_token_to_event(
                 return token_match_string(token, val);
         }
         case TK_M_TAG:
-        case TK_M_PARENTS_TAG: {
-                const char *val;
-
+        case TK_M_PARENTS_TAG:
                 FOREACH_DEVICE_CURRENT_TAG(dev, val)
                         if (token_match_string(token, val) == (token->op == OP_MATCH))
                                 return token->op == OP_MATCH;
                 return token->op == OP_NOMATCH;
-        }
         case TK_M_SUBSYSTEM:
         case TK_M_PARENTS_SUBSYSTEM: {
                 const char *val;
index fccc967a47b0fdc77478fb34a1a856072294275a..ae7251cbcc1a0748f17d2d269791af5db192f862 100644 (file)
@@ -86,7 +86,7 @@ static int sysattr_compare(const SysAttr *a, const SysAttr *b) {
 
 static int print_all_attributes(sd_device *device, bool is_parent) {
         _cleanup_free_ SysAttr *sysattrs = NULL;
-        const char *name, *value;
+        const char *value;
         size_t n_items = 0;
         int r;
 
@@ -180,7 +180,7 @@ static int print_device_chain(sd_device *device) {
 }
 
 static int print_record(sd_device *device, const char *prefix) {
-        const char *str, *val, *subsys;
+        const char *str, *subsys;
         dev_t devnum;
         uint64_t q;
         int i, ifi;
@@ -232,14 +232,16 @@ static int print_record(sd_device *device, const char *prefix) {
                 printf("%sI: %s%i%s\n", prefix, ansi_highlight_cyan(), ifi, ansi_normal());
 
         if (sd_device_get_devname(device, &str) >= 0) {
+                const char *val;
+
                 assert_se(val = path_startswith(str, "/dev/"));
                 printf("%sN: %s%s%s\n", prefix, ansi_highlight_cyan(), val, ansi_normal());
 
                 if (device_get_devlink_priority(device, &i) >= 0)
                         printf("%sL: %s%i%s\n", prefix, ansi_highlight_cyan(), i, ansi_normal());
 
-                FOREACH_DEVICE_DEVLINK(device, str) {
-                        assert_se(val = path_startswith(str, "/dev/"));
+                FOREACH_DEVICE_DEVLINK(device, link) {
+                        assert_se(val = path_startswith(link, "/dev/"));
                         printf("%sS: %s%s%s\n", prefix, ansi_highlight_cyan(), val, ansi_normal());
                 }
         }
@@ -250,8 +252,8 @@ static int print_record(sd_device *device, const char *prefix) {
         if (sd_device_get_driver(device, &str) >= 0)
                 printf("%sV: %s%s%s\n", prefix, ansi_highlight_yellow4(), str, ansi_normal());
 
-        FOREACH_DEVICE_PROPERTY(device, str, val)
-                printf("%sE: %s=%s\n", prefix, str, val);
+        FOREACH_DEVICE_PROPERTY(device, key, val)
+                printf("%sE: %s=%s\n", prefix, key, val);
 
         if (isempty(prefix))
                 puts("");
@@ -425,7 +427,7 @@ static int query_device(QueryType query, sd_device* device) {
         }
 
         case QUERY_SYMLINK: {
-                const char *devlink, *prefix = "";
+                const char *prefix = "";
 
                 FOREACH_DEVICE_DEVLINK(device, devlink) {
                         if (!arg_root)
@@ -448,9 +450,7 @@ static int query_device(QueryType query, sd_device* device) {
                 return 0;
         }
 
-        case QUERY_PROPERTY: {
-                const char *key, *value;
-
+        case QUERY_PROPERTY:
                 FOREACH_DEVICE_PROPERTY(device, key, value) {
                         if (arg_properties && !strv_contains(arg_properties, key))
                                 continue;
@@ -464,7 +464,6 @@ static int query_device(QueryType query, sd_device* device) {
                 }
 
                 return 0;
-        }
 
         case QUERY_ALL:
                 return print_record(device, NULL);
index 99ad22a759e936a4a6d2cdcd478e1f32bb753808..dbe13a8d3b7ab57f58c44bae2b5028f3b5ae6636 100644 (file)
@@ -48,8 +48,6 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
                devpath, subsystem);
 
         if (arg_show_property) {
-                const char *key, *value;
-
                 FOREACH_DEVICE_PROPERTY(device, key, value)
                         printf("%s=%s\n", key, value);
 
index 8adebbc83e2375acfe85ecce01e858f70abf7c56..682ff5672062ed51ccbedac15fe7d2460882f079 100644 (file)
@@ -88,7 +88,7 @@ int test_main(int argc, char *argv[], void *userdata) {
         _cleanup_(udev_rules_freep) UdevRules *rules = NULL;
         _cleanup_(udev_event_freep) UdevEvent *event = NULL;
         _cleanup_(sd_device_unrefp) sd_device *dev = NULL;
-        const char *cmd, *key, *value;
+        const char *cmd;
         sigset_t mask, sigmask_orig;
         void *val;
         int r;
index 0ec7099eb0197e0b0cd65bdd571ff13bb69af0b8..7fa9b862634a05b954c6ce2dd0aec05a85472658 100644 (file)
@@ -166,8 +166,8 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
         if (path_strv_contains(arg_devices, name))
                 return check_and_exit(sd_device_monitor_get_event(monitor));
 
-        FOREACH_DEVICE_DEVLINK(device, name)
-                if (path_strv_contains(arg_devices, name))
+        FOREACH_DEVICE_DEVLINK(device, link)
+                if (path_strv_contains(arg_devices, link))
                         return check_and_exit(sd_device_monitor_get_event(monitor));
 
         return 0;
index 8cf359733851eb1fc5a53e5531302f953d4c2716..bd22dedf33a653cd111af1789589133557f87318 100644 (file)
@@ -1381,7 +1381,6 @@ static int synthesize_change(sd_device *dev) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         bool part_table_read;
         const char *sysname;
-        sd_device *d;
         int r, k;
 
         r = sd_device_get_sysname(dev, &sysname);