richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
594167
From f7660c55adcf3e6a7eec251c474edc0cbb19e26d Mon Sep 17 00:00:00 2001
594167
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
594167
Date: Wed, 23 Mar 2022 10:48:13 +0100
594167
Subject: [PATCH] strv: declare iterator of FOREACH_STRING() in the loop
594167
594167
Same idea as 03677889f0ef42cdc534bf3b31265a054b20a354.
594167
594167
No functional change intended. The type of the iterator is generally changed to
594167
be 'const char*' instead of 'char*'. Despite the type commonly used, modifying
594167
the string was not allowed.
594167
594167
I adjusted the naming of some short variables for clarity and reduced the scope
594167
of some variable declarations in code that was being touched anyway.
594167
594167
(cherry picked from commit 5980d463048f25411c55da2f6387cdc8eaeef4c8)
594167
594167
Related: #2082131
594167
---
594167
 src/activate/activate.c               |  1 -
594167
 src/basic/fs-util.c                   |  1 -
594167
 src/basic/os-util.c                   |  2 --
594167
 src/basic/strv.h                      |  2 +-
594167
 src/basic/unit-file.c                 |  1 -
594167
 src/boot/bootctl.c                    |  9 ++++-----
594167
 src/cgtop/cgtop.c                     |  1 -
594167
 src/core/apparmor-setup.c             |  1 -
594167
 src/core/efi-random.c                 | 11 +++++------
594167
 src/core/execute.c                    |  1 -
594167
 src/core/timer.c                      |  2 --
594167
 src/core/unit.c                       |  1 -
594167
 src/getty-generator/getty-generator.c |  4 +---
594167
 src/home/homectl.c                    | 17 +++--------------
594167
 src/home/homed-manager.c              |  1 -
594167
 src/libsystemd/sd-device/sd-device.c  |  6 +-----
594167
 src/locale/localed.c                  |  2 +-
594167
 src/login/logind-user.c               |  1 -
594167
 src/nspawn/nspawn-cgroup.c            |  1 -
594167
 src/nspawn/nspawn-mount.c             |  4 ++--
594167
 src/nspawn/nspawn.c                   |  5 ++---
594167
 src/partition/repart.c                |  3 +--
594167
 src/portable/portable.c               |  1 -
594167
 src/resolve/resolved-resolv-conf.c    |  2 --
594167
 src/resolve/test-resolved-etc-hosts.c |  1 -
594167
 src/run/run.c                         |  2 --
594167
 src/shared/bootspec.c                 |  3 ++-
594167
 src/shared/chown-recursive.c          |  1 -
594167
 src/shared/discover-image.c           |  2 +-
594167
 src/shared/dissect-image.c            |  1 -
594167
 src/shared/machine-id-setup.c         |  2 +-
594167
 src/shared/mount-setup.c              |  4 ----
594167
 src/shared/netif-util.c               |  7 ++++---
594167
 src/shared/pager.c                    |  2 +-
594167
 src/shared/psi-util.c                 |  2 --
594167
 src/shared/switch-root.c              | 11 +++++------
594167
 src/shared/tests.c                    | 11 +++++------
594167
 src/systemctl/systemctl-edit.c        |  8 ++++----
594167
 src/systemctl/systemctl-sysv-compat.c | 25 ++++++++++++-------------
594167
 src/test/test-bpf-devices.c           |  1 -
594167
 src/test/test-ellipsize.c             |  8 ++------
594167
 src/test/test-env-file.c              |  2 --
594167
 src/test/test-execute.c               | 16 ++++++----------
594167
 src/test/test-fileio.c                |  1 -
594167
 src/test/test-gpt.c                   |  6 +-----
594167
 src/test/test-libcrypt-util.c         |  2 --
594167
 src/test/test-loop-block.c            |  1 -
594167
 src/test/test-mount-util.c            |  1 -
594167
 src/test/test-stat-util.c             |  2 --
594167
 src/test/test-strv.c                  |  4 +---
594167
 src/test/test-utf8.c                  |  3 ---
594167
 src/tmpfiles/offline-passwd.c         |  2 --
594167
 52 files changed, 66 insertions(+), 145 deletions(-)
594167
594167
diff --git a/src/activate/activate.c b/src/activate/activate.c
594167
index 0c32152671..b625d97f2e 100644
594167
--- a/src/activate/activate.c
594167
+++ b/src/activate/activate.c
594167
@@ -124,7 +124,6 @@ static int open_sockets(int *epoll_fd, bool accept) {
594167
 
594167
 static int exec_process(const char *name, char **argv, int start_fd, size_t n_fds) {
594167
         _cleanup_strv_free_ char **envp = NULL;
594167
-        const char *var;
594167
         char **s;
594167
         int r;
594167
 
594167
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
594167
index 552986f546..2ee7c23f68 100644
594167
--- a/src/basic/fs-util.c
594167
+++ b/src/basic/fs-util.c
594167
@@ -570,7 +570,6 @@ int get_files_in_directory(const char *path, char ***list) {
594167
 }
594167
 
594167
 static int getenv_tmp_dir(const char **ret_path) {
594167
-        const char *n;
594167
         int r, ret = 0;
594167
 
594167
         assert(ret_path);
594167
diff --git a/src/basic/os-util.c b/src/basic/os-util.c
594167
index 75c8500e51..a6e4d09473 100644
594167
--- a/src/basic/os-util.c
594167
+++ b/src/basic/os-util.c
594167
@@ -170,8 +170,6 @@ int open_extension_release(const char *root, const char *extension, char **ret_p
594167
                         }
594167
                 }
594167
         } else {
594167
-                const char *p;
594167
-
594167
                 FOREACH_STRING(p, "/etc/os-release", "/usr/lib/os-release") {
594167
                         r = chase_symlinks(p, root, CHASE_PREFIX_ROOT,
594167
                                            ret_path ? &q : NULL,
594167
diff --git a/src/basic/strv.h b/src/basic/strv.h
594167
index 092d40c84b..27d4450468 100644
594167
--- a/src/basic/strv.h
594167
+++ b/src/basic/strv.h
594167
@@ -207,7 +207,7 @@ void strv_print(char * const *l);
594167
         })
594167
 
594167
 #define _FOREACH_STRING(uniq, x, y, ...)                                \
594167
-        for (char **UNIQ_T(l, uniq) = STRV_MAKE(({ x = y; }), ##__VA_ARGS__); \
594167
+        for (const char *x, * const*UNIQ_T(l, uniq) = STRV_MAKE_CONST(({ x = y; }), ##__VA_ARGS__); \
594167
              x;                                                         \
594167
              x = *(++UNIQ_T(l, uniq)))
594167
 
594167
diff --git a/src/basic/unit-file.c b/src/basic/unit-file.c
594167
index faea92f66d..96826e2940 100644
594167
--- a/src/basic/unit-file.c
594167
+++ b/src/basic/unit-file.c
594167
@@ -237,7 +237,6 @@ bool lookup_paths_timestamp_hash_same(const LookupPaths *lp, uint64_t timestamp_
594167
 }
594167
 
594167
 static int directory_name_is_valid(const char *name) {
594167
-        const char *suffix;
594167
 
594167
         /* Accept a directory whose name is a valid unit file name ending in .wants/, .requires/ or .d/ */
594167
 
594167
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
594167
index 1bcb4d1689..9427a0e4ce 100644
594167
--- a/src/boot/bootctl.c
594167
+++ b/src/boot/bootctl.c
594167
@@ -1044,12 +1044,11 @@ static int remove_variables(sd_id128_t uuid, const char *path, bool in_order) {
594167
 }
594167
 
594167
 static int remove_loader_variables(void) {
594167
-        const char *variable;
594167
         int r = 0;
594167
 
594167
         /* Remove all persistent loader variables we define */
594167
 
594167
-        FOREACH_STRING(variable,
594167
+        FOREACH_STRING(var,
594167
                        EFI_LOADER_VARIABLE(LoaderConfigTimeout),
594167
                        EFI_LOADER_VARIABLE(LoaderConfigTimeoutOneShot),
594167
                        EFI_LOADER_VARIABLE(LoaderEntryDefault),
594167
@@ -1058,15 +1057,15 @@ static int remove_loader_variables(void) {
594167
 
594167
                 int q;
594167
 
594167
-                q = efi_set_variable(variable, NULL, 0);
594167
+                q = efi_set_variable(var, NULL, 0);
594167
                 if (q == -ENOENT)
594167
                         continue;
594167
                 if (q < 0) {
594167
-                        log_warning_errno(q, "Failed to remove EFI variable %s: %m", variable);
594167
+                        log_warning_errno(q, "Failed to remove EFI variable %s: %m", var);
594167
                         if (r >= 0)
594167
                                 r = q;
594167
                 } else
594167
-                        log_info("Removed EFI variable %s.", variable);
594167
+                        log_info("Removed EFI variable %s.", var);
594167
         }
594167
 
594167
         return r;
594167
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
594167
index e5ab904c4f..b023e71757 100644
594167
--- a/src/cgtop/cgtop.c
594167
+++ b/src/cgtop/cgtop.c
594167
@@ -510,7 +510,6 @@ static int refresh_one(
594167
 }
594167
 
594167
 static int refresh(const char *root, Hashmap *a, Hashmap *b, unsigned iteration) {
594167
-        const char *c;
594167
         int r;
594167
 
594167
         FOREACH_STRING(c, SYSTEMD_CGROUP_CONTROLLER, "cpu", "cpuacct", "memory", "io", "blkio", "pids") {
594167
diff --git a/src/core/apparmor-setup.c b/src/core/apparmor-setup.c
594167
index 304a3e6aac..3426a10358 100644
594167
--- a/src/core/apparmor-setup.c
594167
+++ b/src/core/apparmor-setup.c
594167
@@ -24,7 +24,6 @@ int mac_apparmor_setup(void) {
594167
 #if HAVE_APPARMOR
594167
         _cleanup_(aa_policy_cache_unrefp) aa_policy_cache *policy_cache = NULL;
594167
         _cleanup_(aa_features_unrefp) aa_features *features = NULL;
594167
-        const char *current_file;
594167
         _cleanup_free_ char *current_profile = NULL, *cache_dir_path = NULL;
594167
         int r;
594167
 
594167
diff --git a/src/core/efi-random.c b/src/core/efi-random.c
594167
index a0b89d1379..e8d8ccd117 100644
594167
--- a/src/core/efi-random.c
594167
+++ b/src/core/efi-random.c
594167
@@ -20,24 +20,23 @@
594167
  * is suitably validated. */
594167
 
594167
 static void lock_down_efi_variables(void) {
594167
-        const char *p;
594167
         int r;
594167
 
594167
         /* Paranoia: let's restrict access modes of these a bit, so that unprivileged users can't use them to
594167
          * identify the system or gain too much insight into what we might have credited to the entropy
594167
          * pool. */
594167
-        FOREACH_STRING(p,
594167
+        FOREACH_STRING(path,
594167
                        EFIVAR_PATH(EFI_LOADER_VARIABLE(LoaderRandomSeed)),
594167
                        EFIVAR_PATH(EFI_LOADER_VARIABLE(LoaderSystemToken))) {
594167
 
594167
-                r = chattr_path(p, 0, FS_IMMUTABLE_FL, NULL);
594167
+                r = chattr_path(path, 0, FS_IMMUTABLE_FL, NULL);
594167
                 if (r == -ENOENT)
594167
                         continue;
594167
                 if (r < 0)
594167
-                        log_warning_errno(r, "Failed to drop FS_IMMUTABLE_FL from %s, ignoring: %m", p);
594167
+                        log_warning_errno(r, "Failed to drop FS_IMMUTABLE_FL from %s, ignoring: %m", path);
594167
 
594167
-                if (chmod(p, 0600) < 0)
594167
-                        log_warning_errno(errno, "Failed to reduce access mode of %s, ignoring: %m", p);
594167
+                if (chmod(path, 0600) < 0)
594167
+                        log_warning_errno(errno, "Failed to reduce access mode of %s, ignoring: %m", path);
594167
         }
594167
 }
594167
 
594167
diff --git a/src/core/execute.c b/src/core/execute.c
594167
index 8a1d070e26..3cafd0f17d 100644
594167
--- a/src/core/execute.c
594167
+++ b/src/core/execute.c
594167
@@ -2917,7 +2917,6 @@ static int setup_credentials(
594167
                 uid_t uid) {
594167
 
594167
         _cleanup_free_ char *p = NULL, *q = NULL;
594167
-        const char *i;
594167
         int r;
594167
 
594167
         assert(context);
594167
diff --git a/src/core/timer.c b/src/core/timer.c
594167
index b439802bc2..23f466c630 100644
594167
--- a/src/core/timer.c
594167
+++ b/src/core/timer.c
594167
@@ -100,8 +100,6 @@ static int timer_add_default_dependencies(Timer *t) {
594167
                         return r;
594167
 
594167
                 LIST_FOREACH(value, v, t->values) {
594167
-                        const char *target;
594167
-
594167
                         if (v->base != TIMER_CALENDAR)
594167
                                 continue;
594167
 
594167
diff --git a/src/core/unit.c b/src/core/unit.c
594167
index 0eade13ee9..3d30f3807c 100644
594167
--- a/src/core/unit.c
594167
+++ b/src/core/unit.c
594167
@@ -4104,7 +4104,6 @@ int unit_patch_contexts(Unit *u) {
594167
 
594167
                 if ((ec->root_image || !LIST_IS_EMPTY(ec->mount_images)) &&
594167
                     (cc->device_policy != CGROUP_DEVICE_POLICY_AUTO || cc->device_allow)) {
594167
-                        const char *p;
594167
 
594167
                         /* When RootImage= or MountImages= is specified, the following devices are touched. */
594167
                         FOREACH_STRING(p, "/dev/loop-control", "/dev/mapper/control") {
594167
diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c
594167
index 59bdfc496b..4e8162a319 100644
594167
--- a/src/getty-generator/getty-generator.c
594167
+++ b/src/getty-generator/getty-generator.c
594167
@@ -215,9 +215,7 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
594167
                         return r;
594167
         }
594167
 
594167
-        /* Automatically add in a serial getty on the first
594167
-         * virtualizer console */
594167
-        const char *j;
594167
+        /* Automatically add in a serial getty on the first virtualizer console */
594167
         FOREACH_STRING(j,
594167
                        "hvc0",
594167
                        "xvc0",
594167
diff --git a/src/home/homectl.c b/src/home/homectl.c
594167
index 1e3c96f5ad..ac7b00889d 100644
594167
--- a/src/home/homectl.c
594167
+++ b/src/home/homectl.c
594167
@@ -2961,8 +2961,6 @@ static int parse_argv(int argc, char *argv[]) {
594167
 
594167
                 case ARG_DISK_SIZE:
594167
                         if (isempty(optarg)) {
594167
-                                const char *prop;
594167
-
594167
                                 FOREACH_STRING(prop, "diskSize", "diskSizeRelative", "rebalanceWeight") {
594167
                                         r = drop_from_identity(prop);
594167
                                         if (r < 0)
594167
@@ -3464,9 +3462,7 @@ static int parse_argv(int argc, char *argv[]) {
594167
                         break;
594167
                 }
594167
 
594167
-                case ARG_PKCS11_TOKEN_URI: {
594167
-                        const char *p;
594167
-
594167
+                case ARG_PKCS11_TOKEN_URI:
594167
                         if (streq(optarg, "list"))
594167
                                 return pkcs11_list_tokens();
594167
 
594167
@@ -3500,11 +3496,8 @@ static int parse_argv(int argc, char *argv[]) {
594167
 
594167
                         strv_uniq(arg_pkcs11_token_uri);
594167
                         break;
594167
-                }
594167
-
594167
-                case ARG_FIDO2_DEVICE: {
594167
-                        const char *p;
594167
 
594167
+                case ARG_FIDO2_DEVICE:
594167
                         if (streq(optarg, "list"))
594167
                                 return fido2_list_devices();
594167
 
594167
@@ -3534,7 +3527,6 @@ static int parse_argv(int argc, char *argv[]) {
594167
 
594167
                         strv_uniq(arg_fido2_device);
594167
                         break;
594167
-                }
594167
 
594167
                 case ARG_FIDO2_WITH_PIN: {
594167
                         bool lock_with_pin;
594167
@@ -3569,9 +3561,7 @@ static int parse_argv(int argc, char *argv[]) {
594167
                         break;
594167
                 }
594167
 
594167
-                case ARG_RECOVERY_KEY: {
594167
-                        const char *p;
594167
-
594167
+                case ARG_RECOVERY_KEY:
594167
                         r = parse_boolean(optarg);
594167
                         if (r < 0)
594167
                                 return log_error_errno(r, "Failed to parse --recovery-key= argument: %s", optarg);
594167
@@ -3585,7 +3575,6 @@ static int parse_argv(int argc, char *argv[]) {
594167
                         }
594167
 
594167
                         break;
594167
-                }
594167
 
594167
                 case ARG_AUTO_RESIZE_MODE:
594167
                         if (isempty(optarg)) {
594167
diff --git a/src/home/homed-manager.c b/src/home/homed-manager.c
594167
index c1ec555cac..a02248a6de 100644
594167
--- a/src/home/homed-manager.c
594167
+++ b/src/home/homed-manager.c
594167
@@ -482,7 +482,6 @@ static int manager_enumerate_records(Manager *m) {
594167
 static int search_quota(uid_t uid, const char *exclude_quota_path) {
594167
         struct stat exclude_st = {};
594167
         dev_t previous_devno = 0;
594167
-        const char *where;
594167
         int r;
594167
 
594167
         /* Checks whether the specified UID owns any files on the files system, but ignore any file system
594167
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
594167
index b163a0fb6b..af11730f33 100644
594167
--- a/src/libsystemd/sd-device/sd-device.c
594167
+++ b/src/libsystemd/sd-device/sd-device.c
594167
@@ -322,7 +322,6 @@ _public_ int sd_device_new_from_subsystem_sysname(
594167
                 const char *subsystem,
594167
                 const char *sysname) {
594167
 
594167
-        const char *s;
594167
         char *name;
594167
         int r;
594167
 
594167
@@ -331,7 +330,6 @@ _public_ int sd_device_new_from_subsystem_sysname(
594167
         assert_return(path_is_normalized(sysname), -EINVAL);
594167
 
594167
         if (streq(subsystem, "subsystem")) {
594167
-
594167
                 FOREACH_STRING(s, "/sys/subsystem/", "/sys/bus/", "/sys/class/") {
594167
                         r = device_strjoin_new(s, sysname, NULL, NULL, ret);
594167
                         if (r < 0)
594167
@@ -341,7 +339,6 @@ _public_ int sd_device_new_from_subsystem_sysname(
594167
                 }
594167
 
594167
         } else  if (streq(subsystem, "module")) {
594167
-
594167
                 r = device_strjoin_new("/sys/module/", sysname, NULL, NULL, ret);
594167
                 if (r < 0)
594167
                         return r;
594167
@@ -353,9 +350,8 @@ _public_ int sd_device_new_from_subsystem_sysname(
594167
 
594167
                 sep = strchr(sysname, ':');
594167
                 if (sep && sep[1] != '\0') { /* Require ":" and something non-empty after that. */
594167
-                        const char *subsys;
594167
 
594167
-                        subsys = memdupa_suffix0(sysname, sep - sysname);
594167
+                        const char *subsys = memdupa_suffix0(sysname, sep - sysname);
594167
                         sep++;
594167
 
594167
                         FOREACH_STRING(s, "/sys/subsystem/", "/sys/bus/") {
594167
diff --git a/src/locale/localed.c b/src/locale/localed.c
594167
index c228385d0e..f3e6ef2db1 100644
594167
--- a/src/locale/localed.c
594167
+++ b/src/locale/localed.c
594167
@@ -475,7 +475,7 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
594167
 
594167
 static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_error *error) {
594167
         Context *c = userdata;
594167
-        const char *name, *keymap, *keymap_toggle;
594167
+        const char *keymap, *keymap_toggle;
594167
         int convert, interactive, r;
594167
 
594167
         assert(m);
594167
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
594167
index 6d250be321..74739b4242 100644
594167
--- a/src/login/logind-user.c
594167
+++ b/src/login/logind-user.c
594167
@@ -626,7 +626,6 @@ int user_check_linger_file(User *u) {
594167
 }
594167
 
594167
 static bool user_unit_active(User *u) {
594167
-        const char *i;
594167
         int r;
594167
 
594167
         assert(u->service);
594167
diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c
594167
index d472e80c03..d8e1fe0907 100644
594167
--- a/src/nspawn/nspawn-cgroup.c
594167
+++ b/src/nspawn/nspawn-cgroup.c
594167
@@ -22,7 +22,6 @@
594167
 
594167
 static int chown_cgroup_path(const char *path, uid_t uid_shift) {
594167
         _cleanup_close_ int fd = -1;
594167
-        const char *fn;
594167
 
594167
         fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY);
594167
         if (fd < 0)
594167
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c
594167
index 40773d90c1..678fde3669 100644
594167
--- a/src/nspawn/nspawn-mount.c
594167
+++ b/src/nspawn/nspawn-mount.c
594167
@@ -408,7 +408,7 @@ int tmpfs_patch_options(
594167
 }
594167
 
594167
 int mount_sysfs(const char *dest, MountSettingsMask mount_settings) {
594167
-        const char *full, *top, *x;
594167
+        const char *full, *top;
594167
         int r;
594167
         unsigned long extra_flags = 0;
594167
 
594167
@@ -468,7 +468,7 @@ int mount_sysfs(const char *dest, MountSettingsMask mount_settings) {
594167
         /* Create mountpoint for cgroups. Otherwise we are not allowed since we
594167
          * remount /sys read-only.
594167
          */
594167
-        x = prefix_roota(top, "/fs/cgroup");
594167
+        const char *x = prefix_roota(top, "/fs/cgroup");
594167
         (void) mkdir_p(x, 0755);
594167
 
594167
         return mount_nofollow_verbose(LOG_ERR, NULL, top, NULL,
594167
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
594167
index 9225c8f162..1333a8702a 100644
594167
--- a/src/nspawn/nspawn.c
594167
+++ b/src/nspawn/nspawn.c
594167
@@ -2564,7 +2564,7 @@ static int setup_hostname(void) {
594167
 
594167
 static int setup_journal(const char *directory) {
594167
         _cleanup_free_ char *d = NULL;
594167
-        const char *dirname, *p, *q;
594167
+        const char *p, *q;
594167
         sd_id128_t this_id;
594167
         bool try;
594167
         int r;
594167
@@ -3513,7 +3513,6 @@ static int inner_child(
594167
         (void) fdset_close_others(fds);
594167
 
594167
         if (arg_start_mode == START_BOOT) {
594167
-                const char *init;
594167
                 char **a;
594167
                 size_t m;
594167
 
594167
@@ -4604,7 +4603,7 @@ static int load_settings(void) {
594167
         _cleanup_(settings_freep) Settings *settings = NULL;
594167
         _cleanup_fclose_ FILE *f = NULL;
594167
         _cleanup_free_ char *p = NULL;
594167
-        const char *fn, *i;
594167
+        const char *fn;
594167
         int r;
594167
 
594167
         if (arg_oci_bundle)
594167
diff --git a/src/partition/repart.c b/src/partition/repart.c
594167
index 0862a37a8d..509cf69b5d 100644
594167
--- a/src/partition/repart.c
594167
+++ b/src/partition/repart.c
594167
@@ -4561,9 +4561,8 @@ static int acquire_root_devno(
594167
 }
594167
 
594167
 static int find_root(char **ret, int *ret_fd) {
594167
-        const char *p;
594167
-        int r;
594167
         _cleanup_free_ char *device = NULL;
594167
+        int r;
594167
 
594167
         assert(ret);
594167
         assert(ret_fd);
594167
diff --git a/src/portable/portable.c b/src/portable/portable.c
594167
index be311f94c4..bdc10da36f 100644
594167
--- a/src/portable/portable.c
594167
+++ b/src/portable/portable.c
594167
@@ -1568,7 +1568,6 @@ int portable_detach(
594167
 
594167
         SET_FOREACH(item, unit_files) {
594167
                 _cleanup_free_ char *md = NULL;
594167
-                const char *suffix;
594167
 
594167
                 if (unlinkat(dirfd(d), item, 0) < 0) {
594167
                         log_debug_errno(errno, "Can't remove unit file %s/%s: %m", where, item);
594167
diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c
594167
index e9785ab964..ee86cf75a0 100644
594167
--- a/src/resolve/resolved-resolv-conf.c
594167
+++ b/src/resolve/resolved-resolv-conf.c
594167
@@ -51,8 +51,6 @@ int manager_check_resolv_conf(const Manager *m) {
594167
 }
594167
 
594167
 static bool file_is_our_own(const struct stat *st) {
594167
-        const char *path;
594167
-
594167
         assert(st);
594167
 
594167
         FOREACH_STRING(path,
594167
diff --git a/src/resolve/test-resolved-etc-hosts.c b/src/resolve/test-resolved-etc-hosts.c
594167
index cc55a980ad..f15e025b7b 100644
594167
--- a/src/resolve/test-resolved-etc-hosts.c
594167
+++ b/src/resolve/test-resolved-etc-hosts.c
594167
@@ -45,7 +45,6 @@ static void test_parse_etc_hosts(void) {
594167
 
594167
         int fd;
594167
         _cleanup_fclose_ FILE *f;
594167
-        const char *s;
594167
 
594167
         fd = mkostemp_safe(t);
594167
         assert_se(fd >= 0);
594167
diff --git a/src/run/run.c b/src/run/run.c
594167
index e75b027542..2ae629f595 100644
594167
--- a/src/run/run.c
594167
+++ b/src/run/run.c
594167
@@ -1702,8 +1702,6 @@ static int start_transient_trigger(
594167
 }
594167
 
594167
 static bool shall_make_executable_absolute(void) {
594167
-        const char *f;
594167
-
594167
         if (strv_isempty(arg_cmdline))
594167
                 return false;
594167
         if (arg_transport != BUS_TRANSPORT_LOCAL)
594167
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
594167
index 0076092c2a..a17375eb4c 100644
594167
--- a/src/shared/bootspec.c
594167
+++ b/src/shared/bootspec.c
594167
@@ -1207,7 +1207,8 @@ int find_esp_and_warn(
594167
                 goto found;
594167
         }
594167
 
594167
-        FOREACH_STRING(path, "/efi", "/boot", "/boot/efi") {
594167
+        FOREACH_STRING(_path, "/efi", "/boot", "/boot/efi") {
594167
+                path = _path;
594167
 
594167
                 r = verify_esp(path, true, unprivileged_mode, ret_part, ret_pstart, ret_psize, ret_uuid);
594167
                 if (r >= 0)
594167
diff --git a/src/shared/chown-recursive.c b/src/shared/chown-recursive.c
594167
index 7c9a3050b4..05a7a10ce4 100644
594167
--- a/src/shared/chown-recursive.c
594167
+++ b/src/shared/chown-recursive.c
594167
@@ -21,7 +21,6 @@ static int chown_one(
594167
                 gid_t gid,
594167
                 mode_t mask) {
594167
 
594167
-        const char *n;
594167
         int r;
594167
 
594167
         assert(fd >= 0);
594167
diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c
594167
index 268d910214..1d432328e7 100644
594167
--- a/src/shared/discover-image.c
594167
+++ b/src/shared/discover-image.c
594167
@@ -85,7 +85,7 @@ DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(image_hash_ops, char, string_hash_func, st
594167
 
594167
 static char **image_settings_path(Image *image) {
594167
         _cleanup_strv_free_ char **l = NULL;
594167
-        const char *fn, *s;
594167
+        const char *fn;
594167
         unsigned i = 0;
594167
 
594167
         assert(image);
594167
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
594167
index 39a7f4c3f2..b38f16c37a 100644
594167
--- a/src/shared/dissect-image.c
594167
+++ b/src/shared/dissect-image.c
594167
@@ -3042,7 +3042,6 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
594167
 
594167
                         case META_HAS_INIT_SYSTEM: {
594167
                                 bool found = false;
594167
-                                const char *init;
594167
 
594167
                                 FOREACH_STRING(init,
594167
                                                "/usr/lib/systemd/systemd",  /* systemd on /usr merged system */
594167
diff --git a/src/shared/machine-id-setup.c b/src/shared/machine-id-setup.c
594167
index e483675a75..df4ac419cb 100644
594167
--- a/src/shared/machine-id-setup.c
594167
+++ b/src/shared/machine-id-setup.c
594167
@@ -197,7 +197,7 @@ finish:
594167
 
594167
 int machine_id_commit(const char *root) {
594167
         _cleanup_close_ int fd = -1, initial_mntns_fd = -1;
594167
-        const char *etc_machine_id, *sync_path;
594167
+        const char *etc_machine_id;
594167
         sd_id128_t id;
594167
         int r;
594167
 
594167
diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c
594167
index 7917968497..7eadff3ace 100644
594167
--- a/src/shared/mount-setup.c
594167
+++ b/src/shared/mount-setup.c
594167
@@ -126,9 +126,6 @@ bool mount_point_is_api(const char *path) {
594167
 }
594167
 
594167
 bool mount_point_ignore(const char *path) {
594167
-
594167
-        const char *i;
594167
-
594167
         /* These are API file systems that might be mounted by other software, we just list them here so that
594167
          * we know that we should ignore them. */
594167
         FOREACH_STRING(i,
594167
@@ -518,7 +515,6 @@ int mount_setup(bool loaded_policy, bool leave_propagation) {
594167
          * use the same label for all their files. */
594167
         if (loaded_policy) {
594167
                 usec_t before_relabel, after_relabel;
594167
-                const char *i;
594167
                 int n_extra;
594167
 
594167
                 before_relabel = now(CLOCK_MONOTONIC);
594167
diff --git a/src/shared/netif-util.c b/src/shared/netif-util.c
594167
index 603d4de109..7605427052 100644
594167
--- a/src/shared/netif-util.c
594167
+++ b/src/shared/netif-util.c
594167
@@ -39,14 +39,15 @@ int net_get_type_string(sd_device *device, uint16_t iftype, char **ret) {
594167
 }
594167
 
594167
 const char *net_get_persistent_name(sd_device *device) {
594167
-        const char *name, *field;
594167
-
594167
         assert(device);
594167
 
594167
         /* fetch some persistent data unique (on this machine) to this device */
594167
-        FOREACH_STRING(field, "ID_NET_NAME_ONBOARD", "ID_NET_NAME_SLOT", "ID_NET_NAME_PATH", "ID_NET_NAME_MAC")
594167
+        FOREACH_STRING(field, "ID_NET_NAME_ONBOARD", "ID_NET_NAME_SLOT", "ID_NET_NAME_PATH", "ID_NET_NAME_MAC") {
594167
+                const char *name;
594167
+
594167
                 if (sd_device_get_property_value(device, field, &name) >= 0)
594167
                         return name;
594167
+        }
594167
 
594167
         return NULL;
594167
 }
594167
diff --git a/src/shared/pager.c b/src/shared/pager.c
594167
index 9426d3ef98..1a93deb628 100644
594167
--- a/src/shared/pager.c
594167
+++ b/src/shared/pager.c
594167
@@ -144,7 +144,7 @@ void pager_open(PagerFlags flags) {
594167
         if (r < 0)
594167
                 return;
594167
         if (r == 0) {
594167
-                const char *less_charset, *exe;
594167
+                const char *less_charset;
594167
 
594167
                 /* In the child start the pager */
594167
 
594167
diff --git a/src/shared/psi-util.c b/src/shared/psi-util.c
594167
index 009095e8c3..8bdd0d4a85 100644
594167
--- a/src/shared/psi-util.c
594167
+++ b/src/shared/psi-util.c
594167
@@ -106,8 +106,6 @@ int read_resource_pressure(const char *path, PressureType type, ResourcePressure
594167
 }
594167
 
594167
 int is_pressure_supported(void) {
594167
-        const char *p;
594167
-
594167
         /* The pressure files, both under /proc and in cgroups, will exist
594167
          * even if the kernel has PSI support disabled; we have to read
594167
          * the file to make sure it doesn't return -EOPNOTSUPP */
594167
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c
594167
index 99cd574197..1a444841fa 100644
594167
--- a/src/shared/switch-root.c
594167
+++ b/src/shared/switch-root.c
594167
@@ -33,7 +33,6 @@ int switch_root(const char *new_root,
594167
         _cleanup_free_ char *resolved_old_root_after = NULL;
594167
         _cleanup_close_ int old_root_fd = -1;
594167
         bool old_root_remove;
594167
-        const char *i;
594167
         int r;
594167
 
594167
         assert(new_root);
594167
@@ -64,12 +63,12 @@ int switch_root(const char *new_root,
594167
         if (mount(NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL) < 0)
594167
                 return log_error_errno(errno, "Failed to set \"/\" mount propagation to private: %m");
594167
 
594167
-        FOREACH_STRING(i, "/sys", "/dev", "/run", "/proc") {
594167
+        FOREACH_STRING(path, "/sys", "/dev", "/run", "/proc") {
594167
                 _cleanup_free_ char *chased = NULL;
594167
 
594167
-                r = chase_symlinks(i, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &chased, NULL);
594167
+                r = chase_symlinks(path, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &chased, NULL);
594167
                 if (r < 0)
594167
-                        return log_error_errno(r, "Failed to resolve %s/%s: %m", new_root, i);
594167
+                        return log_error_errno(r, "Failed to resolve %s/%s: %m", new_root, path);
594167
                 if (r > 0) {
594167
                         /* Already exists. Let's see if it is a mount point already. */
594167
                         r = path_is_mount_point(chased, NULL, 0);
594167
@@ -81,8 +80,8 @@ int switch_root(const char *new_root,
594167
                          /* Doesn't exist yet? */
594167
                         (void) mkdir_p_label(chased, 0755);
594167
 
594167
-                if (mount(i, chased, NULL, mount_flags, NULL) < 0)
594167
-                        return log_error_errno(errno, "Failed to mount %s to %s: %m", i, chased);
594167
+                if (mount(path, chased, NULL, mount_flags, NULL) < 0)
594167
+                        return log_error_errno(errno, "Failed to mount %s to %s: %m", path, chased);
594167
         }
594167
 
594167
         /* Do not fail if base_filesystem_create() fails. Not all switch roots are like base_filesystem_create() wants
594167
diff --git a/src/shared/tests.c b/src/shared/tests.c
594167
index b00006b41a..f5d9536411 100644
594167
--- a/src/shared/tests.c
594167
+++ b/src/shared/tests.c
594167
@@ -307,16 +307,15 @@ const char *ci_environment(void) {
594167
          * just the general CI environment type, but also whether we're sanitizing or not, etc. The caller is
594167
          * expected to use strstr on the returned value. */
594167
         static const char *ans = POINTER_MAX;
594167
-        const char *p;
594167
         int r;
594167
 
594167
         if (ans != POINTER_MAX)
594167
                 return ans;
594167
 
594167
         /* We allow specifying the environment with $CITYPE. Nobody uses this so far, but we are ready. */
594167
-        p = getenv("CITYPE");
594167
-        if (!isempty(p))
594167
-                return (ans = p);
594167
+        const char *citype = getenv("CITYPE");
594167
+        if (!isempty(citype))
594167
+                return (ans = citype);
594167
 
594167
         if (getenv_bool("TRAVIS") > 0)
594167
                 return (ans = "travis");
594167
@@ -327,12 +326,12 @@ const char *ci_environment(void) {
594167
         if (getenv("AUTOPKGTEST_ARTIFACTS") || getenv("AUTOPKGTEST_TMP"))
594167
                 return (ans = "autopkgtest");
594167
 
594167
-        FOREACH_STRING(p, "CI", "CONTINOUS_INTEGRATION") {
594167
+        FOREACH_STRING(var, "CI", "CONTINOUS_INTEGRATION") {
594167
                 /* Those vars are booleans according to Semaphore and Travis docs:
594167
                  * https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
594167
                  * https://docs.semaphoreci.com/ci-cd-environment/environment-variables/#ci
594167
                  */
594167
-                r = getenv_bool(p);
594167
+                r = getenv_bool(var);
594167
                 if (r > 0)
594167
                         return (ans = "unknown"); /* Some other unknown thing */
594167
                 if (r == 0)
594167
diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c
594167
index b59a67ac22..a97aa7be4c 100644
594167
--- a/src/systemctl/systemctl-edit.c
594167
+++ b/src/systemctl/systemctl-edit.c
594167
@@ -320,7 +320,7 @@ static int run_editor(char **paths) {
594167
         if (r == 0) {
594167
                 char **editor_args = NULL, **tmp_path, **original_path;
594167
                 size_t n_editor_args = 0, i = 1, argc;
594167
-                const char **args, *editor, *p;
594167
+                const char **args, *editor;
594167
 
594167
                 argc = strv_length(paths)/2 + 1;
594167
 
594167
@@ -358,9 +358,9 @@ static int run_editor(char **paths) {
594167
                 if (n_editor_args > 0)
594167
                         execvp(args[0], (char* const*) args);
594167
 
594167
-                FOREACH_STRING(p, "editor", "nano", "vim", "vi") {
594167
-                        args[0] = p;
594167
-                        execvp(p, (char* const*) args);
594167
+                FOREACH_STRING(name, "editor", "nano", "vim", "vi") {
594167
+                        args[0] = name;
594167
+                        execvp(name, (char* const*) args);
594167
                         /* We do not fail if the editor doesn't exist because we want to try each one of them
594167
                          * before failing. */
594167
                         if (errno != ENOENT) {
594167
diff --git a/src/systemctl/systemctl-sysv-compat.c b/src/systemctl/systemctl-sysv-compat.c
594167
index a78fa1e04c..017dba2034 100644
594167
--- a/src/systemctl/systemctl-sysv-compat.c
594167
+++ b/src/systemctl/systemctl-sysv-compat.c
594167
@@ -18,9 +18,8 @@
594167
 
594167
 int talk_initctl(char rl) {
594167
 #if HAVE_SYSV_COMPAT
594167
-        struct init_request request;
594167
         _cleanup_close_ int fd = -1;
594167
-        const char *p;
594167
+        const char *path;
594167
         int r;
594167
 
594167
         /* Try to switch to the specified SysV runlevel. Returns == 0 if the operation does not apply on this
594167
@@ -29,19 +28,19 @@ int talk_initctl(char rl) {
594167
         if (rl == 0)
594167
                 return 0;
594167
 
594167
-        FOREACH_STRING(p, "/run/initctl", "/dev/initctl") {
594167
-                fd = open(p, O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY);
594167
-                if (fd >= 0 || errno != ENOENT)
594167
-                        break;
594167
-        }
594167
-        if (fd < 0) {
594167
-                if (errno == ENOENT)
594167
-                        return 0;
594167
+        FOREACH_STRING(_path, "/run/initctl", "/dev/initctl") {
594167
+                path = _path;
594167
 
594167
-                return log_error_errno(errno, "Failed to open initctl fifo: %m");
594167
+                fd = open(path, O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY);
594167
+                if (fd < 0 && errno != ENOENT)
594167
+                        return log_error_errno(errno, "Failed to open %s: %m", path);
594167
+                if (fd >= 0)
594167
+                        break;
594167
         }
594167
+        if (fd < 0)
594167
+                return 0;
594167
 
594167
-        request = (struct init_request) {
594167
+        struct init_request request = {
594167
                 .magic = INIT_MAGIC,
594167
                 .sleeptime = 0,
594167
                 .cmd = INIT_CMD_RUNLVL,
594167
@@ -50,7 +49,7 @@ int talk_initctl(char rl) {
594167
 
594167
         r = loop_write(fd, &request, sizeof(request), false);
594167
         if (r < 0)
594167
-                return log_error_errno(r, "Failed to write to %s: %m", p);
594167
+                return log_error_errno(r, "Failed to write to %s: %m", path);
594167
 
594167
         return 1;
594167
 #else
594167
diff --git a/src/test/test-bpf-devices.c b/src/test/test-bpf-devices.c
594167
index bbaa7b3605..587591cf04 100644
594167
--- a/src/test/test-bpf-devices.c
594167
+++ b/src/test/test-bpf-devices.c
594167
@@ -30,7 +30,6 @@ static void test_policy_closed(const char *cgroup_path, BPFProgram **installed_p
594167
         r = bpf_devices_apply_policy(&prog, CGROUP_DEVICE_POLICY_CLOSED, true, cgroup_path, installed_prog);
594167
         assert_se(r >= 0);
594167
 
594167
-        const char *s;
594167
         FOREACH_STRING(s, "/dev/null",
594167
                           "/dev/zero",
594167
                           "/dev/full",
594167
diff --git a/src/test/test-ellipsize.c b/src/test/test-ellipsize.c
594167
index b840355f5e..7317193363 100644
594167
--- a/src/test/test-ellipsize.c
594167
+++ b/src/test/test-ellipsize.c
594167
@@ -64,18 +64,14 @@ static void test_ellipsize_mem_one(const char *s, size_t old_length, size_t new_
594167
 }
594167
 
594167
 TEST(ellipsize_mem) {
594167
-        const char *s;
594167
-        ssize_t l, k;
594167
-
594167
         FOREACH_STRING(s,
594167
                        "_XXXXXXXXXXX_", /* ASCII */
594167
                        "_aąęółśćńżźć_", /* two-byte utf-8 */
594167
                        "გამარჯობა",     /* multi-byte utf-8 */
594167
                        "你好世界",       /* wide characters */
594167
                        "你გą世óoó界")    /* a mix */
594167
-
594167
-                for (l = strlen(s); l >= 0; l--)
594167
-                        for (k = strlen(s) + 1; k >= 0; k--)
594167
+                for (ssize_t l = strlen(s); l >= 0; l--)
594167
+                        for (ssize_t k = strlen(s) + 1; k >= 0; k--)
594167
                                 test_ellipsize_mem_one(s, l, k);
594167
 }
594167
 
594167
diff --git a/src/test/test-env-file.c b/src/test/test-env-file.c
594167
index 7b132447bf..f97206b4d6 100644
594167
--- a/src/test/test-env-file.c
594167
+++ b/src/test/test-env-file.c
594167
@@ -166,8 +166,6 @@ TEST(load_env_file_6) {
594167
 }
594167
 
594167
 TEST(write_and_load_env_file) {
594167
-        const char *v;
594167
-
594167
         /* Make sure that our writer, parser and the shell agree on what our env var files mean */
594167
 
594167
         FOREACH_STRING(v,
594167
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
594167
index 49629c6bc2..0760df6603 100644
594167
--- a/src/test/test-execute.c
594167
+++ b/src/test/test-execute.c
594167
@@ -190,19 +190,15 @@ static bool check_user_has_group_with_same_name(const char *name) {
594167
 }
594167
 
594167
 static bool is_inaccessible_available(void) {
594167
-        const char *p;
594167
-
594167
         FOREACH_STRING(p,
594167
-                "/run/systemd/inaccessible/reg",
594167
-                "/run/systemd/inaccessible/dir",
594167
-                "/run/systemd/inaccessible/chr",
594167
-                "/run/systemd/inaccessible/blk",
594167
-                "/run/systemd/inaccessible/fifo",
594167
-                "/run/systemd/inaccessible/sock"
594167
-        ) {
594167
+                       "/run/systemd/inaccessible/reg",
594167
+                       "/run/systemd/inaccessible/dir",
594167
+                       "/run/systemd/inaccessible/chr",
594167
+                       "/run/systemd/inaccessible/blk",
594167
+                       "/run/systemd/inaccessible/fifo",
594167
+                       "/run/systemd/inaccessible/sock")
594167
                 if (access(p, F_OK) < 0)
594167
                         return false;
594167
-        }
594167
 
594167
         return true;
594167
 }
594167
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
594167
index 087d76f760..4f91d94709 100644
594167
--- a/src/test/test-fileio.c
594167
+++ b/src/test/test-fileio.c
594167
@@ -1003,7 +1003,6 @@ TEST(read_full_file_offset_size) {
594167
 }
594167
 
594167
 static void test_read_virtual_file_one(size_t max_size) {
594167
-        const char *filename;
594167
         int r;
594167
 
594167
         log_info("/* %s (max_size=%zu) */", __func__, max_size);
594167
diff --git a/src/test/test-gpt.c b/src/test/test-gpt.c
594167
index ab26d5d096..05da7a9e48 100644
594167
--- a/src/test/test-gpt.c
594167
+++ b/src/test/test-gpt.c
594167
@@ -11,16 +11,13 @@
594167
 #include "util.h"
594167
 
594167
 TEST(gpt_types_against_architectures) {
594167
-        const char *prefix;
594167
         int r;
594167
 
594167
         /* Dumps a table indicating for which architectures we know we have matching GPT partition
594167
          * types. Also validates whether we can properly categorize the entries. */
594167
 
594167
         FOREACH_STRING(prefix, "root-", "usr-")
594167
-                for (int a = 0; a < _ARCHITECTURE_MAX; a++) {
594167
-                        const char *suffix;
594167
-
594167
+                for (int a = 0; a < _ARCHITECTURE_MAX; a++)
594167
                         FOREACH_STRING(suffix, "", "-verity", "-verity-sig") {
594167
                                 _cleanup_free_ char *joined = NULL;
594167
                                 sd_id128_t id;
594167
@@ -48,7 +45,6 @@ TEST(gpt_types_against_architectures) {
594167
 
594167
                                 assert_se(gpt_partition_type_uuid_to_arch(id) == a);
594167
                         }
594167
-                }
594167
 }
594167
 
594167
 DEFINE_TEST_MAIN(LOG_INFO);
594167
diff --git a/src/test/test-libcrypt-util.c b/src/test/test-libcrypt-util.c
594167
index ebd520f7ba..f88a9f9b24 100644
594167
--- a/src/test/test-libcrypt-util.c
594167
+++ b/src/test/test-libcrypt-util.c
594167
@@ -39,7 +39,6 @@ static int test_hash_password(void) {
594167
         /* As a warm-up exercise, check if we can hash passwords. */
594167
 
594167
         bool have_sane_hash = false;
594167
-        const char *hash;
594167
 
594167
         FOREACH_STRING(hash,
594167
                        "ew3bU1.hoKk4o",
594167
@@ -68,7 +67,6 @@ static void test_hash_password_full(void) {
594167
         log_info("/* %s */", __func__);
594167
 
594167
         _cleanup_free_ void *cd_data = NULL;
594167
-        const char *i;
594167
         int cd_size = 0;
594167
 
594167
         log_info("sizeof(struct crypt_data): %zu bytes", sizeof(struct crypt_data));
594167
diff --git a/src/test/test-loop-block.c b/src/test/test-loop-block.c
594167
index 1642f82e40..9c8c55bca2 100644
594167
--- a/src/test/test-loop-block.c
594167
+++ b/src/test/test-loop-block.c
594167
@@ -114,7 +114,6 @@ int main(int argc, char *argv[]) {
594167
         _cleanup_(dissected_image_unrefp) DissectedImage *dissected = NULL;
594167
         _cleanup_(umount_and_rmdir_and_freep) char *mounted = NULL;
594167
         pthread_t threads[N_THREADS];
594167
-        const char *fs;
594167
         sd_id128_t id;
594167
         int r;
594167
 
594167
diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c
594167
index 74d352268e..7e06fc419c 100644
594167
--- a/src/test/test-mount-util.c
594167
+++ b/src/test/test-mount-util.c
594167
@@ -128,7 +128,6 @@ TEST(mount_flags_to_string) {
594167
 TEST(bind_remount_recursive) {
594167
         _cleanup_(rm_rf_physical_and_freep) char *tmp = NULL;
594167
         _cleanup_free_ char *subdir = NULL;
594167
-        const char *p;
594167
 
594167
         if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0) {
594167
                 (void) log_tests_skipped("not running privileged");
594167
diff --git a/src/test/test-stat-util.c b/src/test/test-stat-util.c
594167
index 7f633ab259..5f744b0288 100644
594167
--- a/src/test/test-stat-util.c
594167
+++ b/src/test/test-stat-util.c
594167
@@ -67,7 +67,6 @@ TEST(path_is_fs_type) {
594167
 }
594167
 
594167
 TEST(path_is_temporary_fs) {
594167
-        const char *s;
594167
         int r;
594167
 
594167
         FOREACH_STRING(s, "/", "/run", "/sys", "/sys/", "/proc", "/i-dont-exist", "/var", "/var/lib") {
594167
@@ -85,7 +84,6 @@ TEST(path_is_temporary_fs) {
594167
 }
594167
 
594167
 TEST(path_is_read_only_fs) {
594167
-        const char *s;
594167
         int r;
594167
 
594167
         FOREACH_STRING(s, "/", "/run", "/sys", "/sys/", "/proc", "/i-dont-exist", "/var", "/var/lib") {
594167
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
594167
index 94581fc832..0ece342521 100644
594167
--- a/src/test/test-strv.c
594167
+++ b/src/test/test-strv.c
594167
@@ -924,12 +924,10 @@ TEST(foreach_string) {
594167
                 "waldo",
594167
                 NULL
594167
         };
594167
-        const char *x;
594167
-        unsigned i = 0;
594167
 
594167
+        unsigned i = 0;
594167
         FOREACH_STRING(x, "foo", "bar", "waldo")
594167
                 assert_se(streq_ptr(t[i++], x));
594167
-
594167
         assert_se(i == 3);
594167
 
594167
         FOREACH_STRING(x, "zzz")
594167
diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c
594167
index 7337b81227..f070c171fe 100644
594167
--- a/src/test/test-utf8.c
594167
+++ b/src/test/test-utf8.c
594167
@@ -144,7 +144,6 @@ TEST(utf8_escape_non_printable) {
594167
 }
594167
 
594167
 TEST(utf8_escape_non_printable_full) {
594167
-        const char *s;
594167
         FOREACH_STRING(s,
594167
                        "goo goo goo",       /* ASCII */
594167
                        "\001 \019\20\a",    /* control characters */
594167
@@ -210,8 +209,6 @@ TEST(utf8_console_width) {
594167
 }
594167
 
594167
 TEST(utf8_to_utf16) {
594167
-        const char *p;
594167
-
594167
         FOREACH_STRING(p,
594167
                        "abc",
594167
                        "zażółcić gęślą jaźń",
594167
diff --git a/src/tmpfiles/offline-passwd.c b/src/tmpfiles/offline-passwd.c
594167
index 8ba3fea984..c847266ed4 100644
594167
--- a/src/tmpfiles/offline-passwd.c
594167
+++ b/src/tmpfiles/offline-passwd.c
594167
@@ -39,7 +39,6 @@ static int populate_uid_cache(const char *root, Hashmap **ret) {
594167
         /* The directory list is hardcoded here: /etc is the standard, and rpm-ostree uses /usr/lib. This
594167
          * could be made configurable, but I don't see the point right now. */
594167
 
594167
-        const char *fname;
594167
         FOREACH_STRING(fname, "/etc/passwd", "/usr/lib/passwd") {
594167
                 _cleanup_fclose_ FILE *f = NULL;
594167
 
594167
@@ -78,7 +77,6 @@ static int populate_gid_cache(const char *root, Hashmap **ret) {
594167
         if (!cache)
594167
                 return -ENOMEM;
594167
 
594167
-        const char *fname;
594167
         FOREACH_STRING(fname, "/etc/group", "/usr/lib/group") {
594167
                 _cleanup_fclose_ FILE *f = NULL;
594167