richardphibel / rpms / systemd

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