summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-21 10:52:03 +0100
committerGitHub <noreply@github.com>2022-03-21 10:52:03 +0100
commitb0a5e596224d04ae4d70bb864591152310efac0c (patch)
tree5d0a3fe4133ed1a1c8eeff83c3392f661f2cf363
parent59b8e67582f360fe82c69db9c322ef32c971eba5 (diff)
parentde010b0b2e50cf0b3837ce350b116bc92605f67a (diff)
downloadsystemd-b0a5e596224d04ae4d70bb864591152310efac0c.tar.gz
Merge pull request #22740 from yuwata/list
tree-wide: declare iterator of LIST_FOREACH() in the loop
-rw-r--r--src/activate/activate.c3
-rw-r--r--src/analyze/analyze-calendar.c1
-rw-r--r--src/analyze/analyze-cat-config.c2
-rw-r--r--src/analyze/analyze-condition.c2
-rw-r--r--src/analyze/analyze-critical-chain.c6
-rw-r--r--src/analyze/analyze-dot.c4
-rw-r--r--src/analyze/analyze-filesystems.c7
-rw-r--r--src/analyze/analyze-inspect-elf.c1
-rw-r--r--src/analyze/analyze-security.c7
-rw-r--r--src/analyze/analyze-syscall-filter.c7
-rw-r--r--src/analyze/analyze-timespan.c2
-rw-r--r--src/analyze/analyze-timestamp.c1
-rw-r--r--src/analyze/analyze-unit-files.c2
-rw-r--r--src/analyze/analyze-unit-paths.c1
-rw-r--r--src/analyze/analyze-verify-util.c6
-rw-r--r--src/analyze/analyze-verify.c1
-rw-r--r--src/ask-password/ask-password.c1
-rw-r--r--src/basic/conf-files.c9
-rw-r--r--src/basic/env-file.c1
-rw-r--r--src/basic/env-util.c19
-rw-r--r--src/basic/escape.c1
-rw-r--r--src/basic/fileio.c2
-rw-r--r--src/basic/hashmap.c1
-rw-r--r--src/basic/list.h46
-rw-r--r--src/basic/ordered-set.c1
-rw-r--r--src/basic/os-util.c1
-rw-r--r--src/basic/path-lookup.c1
-rw-r--r--src/basic/path-util.c20
-rw-r--r--src/basic/process-util.c1
-rw-r--r--src/basic/strv.c33
-rw-r--r--src/basic/strv.h35
-rw-r--r--src/basic/unit-file.c8
-rw-r--r--src/binfmt/binfmt.c1
-rw-r--r--src/boot/bless-boot.c2
-rw-r--r--src/boot/bootctl.c2
-rw-r--r--src/busctl/busctl.c5
-rw-r--r--src/cgls/cgls.c1
-rw-r--r--src/core/bpf-firewall.c2
-rw-r--r--src/core/bpf-foreign.c1
-rw-r--r--src/core/bpf-socket-bind.c2
-rw-r--r--src/core/cgroup.c35
-rw-r--r--src/core/core-varlink.c5
-rw-r--r--src/core/dbus-cgroup.c72
-rw-r--r--src/core/dbus-execute.c38
-rw-r--r--src/core/dbus-manager.c1
-rw-r--r--src/core/dbus-path.c1
-rw-r--r--src/core/dbus-socket.c5
-rw-r--r--src/core/dbus-timer.c2
-rw-r--r--src/core/dbus-unit.c7
-rw-r--r--src/core/device.c28
-rw-r--r--src/core/execute.c26
-rw-r--r--src/core/load-dropin.c2
-rw-r--r--src/core/load-fragment.c23
-rw-r--r--src/core/main.c1
-rw-r--r--src/core/manager.c2
-rw-r--r--src/core/mount.c1
-rw-r--r--src/core/namespace.c7
-rw-r--r--src/core/path.c25
-rw-r--r--src/core/service.c17
-rw-r--r--src/core/socket.c27
-rw-r--r--src/core/swap.c10
-rw-r--r--src/core/timer.c5
-rw-r--r--src/core/transaction.c42
-rw-r--r--src/core/unit-serialize.c2
-rw-r--r--src/core/unit.c8
-rw-r--r--src/coredump/coredumpctl.c1
-rw-r--r--src/creds/creds.c1
-rw-r--r--src/cryptenroll/cryptenroll.c1
-rw-r--r--src/cryptsetup/cryptsetup-keyfile.c1
-rw-r--r--src/cryptsetup/cryptsetup.c4
-rw-r--r--src/debug-generator/debug-generator.c2
-rw-r--r--src/delta/delta.c2
-rw-r--r--src/dissect/dissect.c3
-rw-r--r--src/environment-d-generator/environment-d-generator.c1
-rw-r--r--src/escape/escape.c1
-rw-r--r--src/fstab-generator/fstab-generator.c3
-rw-r--r--src/home/homectl.c11
-rw-r--r--src/home/homed-manager-bus.c1
-rw-r--r--src/home/homed-manager.c1
-rw-r--r--src/home/homed-varlink.c6
-rw-r--r--src/home/homework-cifs.c1
-rw-r--r--src/home/homework-fscrypt.c3
-rw-r--r--src/home/homework-luks.c3
-rw-r--r--src/home/homework-pkcs11.c1
-rw-r--r--src/home/homework.c13
-rw-r--r--src/home/user-record-pwquality.c3
-rw-r--r--src/home/user-record-util.c3
-rw-r--r--src/id128/id128.c1
-rw-r--r--src/journal-remote/journal-remote-main.c1
-rw-r--r--src/journal-remote/microhttpd-util.c5
-rw-r--r--src/journal/journalctl.c9
-rw-r--r--src/journal/journald-rate-limit.c20
-rw-r--r--src/libsystemd-network/dhcp-option.c1
-rw-r--r--src/libsystemd-network/dhcp6-option.c3
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c1
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c9
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c2
-rw-r--r--src/libsystemd-network/sd-dhcp6-lease.c5
-rw-r--r--src/libsystemd-network/sd-radv.c9
-rw-r--r--src/libsystemd/sd-bus/bus-dump.c4
-rw-r--r--src/libsystemd/sd-bus/bus-match.c6
-rw-r--r--src/libsystemd/sd-bus/bus-message.c1
-rw-r--r--src/libsystemd/sd-bus/bus-objects.c18
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-address.c1
-rw-r--r--src/libsystemd/sd-device/device-private.c1
-rw-r--r--src/libsystemd/sd-event/sd-event.c8
-rw-r--r--src/libsystemd/sd-journal/catalog.c2
-rw-r--r--src/libsystemd/sd-journal/mmap-cache.c19
-rw-r--r--src/libsystemd/sd-journal/sd-journal.c9
-rw-r--r--src/libsystemd/sd-netlink/netlink-message.c1
-rw-r--r--src/libsystemd/sd-netlink/sd-netlink.c1
-rw-r--r--src/libsystemd/sd-path/sd-path.c2
-rw-r--r--src/libudev/libudev-list.c4
-rw-r--r--src/locale/localectl.c2
-rw-r--r--src/locale/localed.c1
-rw-r--r--src/login/loginctl.c2
-rw-r--r--src/login/logind-dbus.c5
-rw-r--r--src/login/logind-device.c1
-rw-r--r--src/login/logind-seat-dbus.c1
-rw-r--r--src/login/logind-seat.c13
-rw-r--r--src/login/logind-user-dbus.c1
-rw-r--r--src/login/logind-user.c9
-rw-r--r--src/login/logind.c10
-rw-r--r--src/login/pam_systemd.c1
-rw-r--r--src/modules-load/modules-load.c1
-rw-r--r--src/network/generator/network-generator.c4
-rw-r--r--src/network/netdev/netdev.c1
-rw-r--r--src/network/netdev/wireguard.c25
-rw-r--r--src/network/networkctl.c1
-rw-r--r--src/network/networkd-dhcp-server.c2
-rw-r--r--src/network/networkd-json.c3
-rw-r--r--src/network/networkd-link-bus.c2
-rw-r--r--src/network/networkd-link.c3
-rw-r--r--src/network/networkd-ndisc.c1
-rw-r--r--src/network/networkd-network.c1
-rw-r--r--src/nspawn/nspawn-bind-user.c1
-rw-r--r--src/nspawn/nspawn-expose-ports.c13
-rw-r--r--src/nspawn/nspawn-mount.c4
-rw-r--r--src/nspawn/nspawn-network.c5
-rw-r--r--src/nspawn/nspawn-oci.c1
-rw-r--r--src/nspawn/nspawn-seccomp.c1
-rw-r--r--src/nspawn/nspawn.c1
-rw-r--r--src/nss-systemd/userdb-glue.c2
-rw-r--r--src/partition/repart.c39
-rw-r--r--src/portable/portable.c7
-rw-r--r--src/portable/portablectl.c2
-rw-r--r--src/resolve/resolvectl.c9
-rw-r--r--src/resolve/resolved-bus.c9
-rw-r--r--src/resolve/resolved-dns-cache.c24
-rw-r--r--src/resolve/resolved-dns-packet.c5
-rw-r--r--src/resolve/resolved-dns-query.c8
-rw-r--r--src/resolve/resolved-dns-rr.c5
-rw-r--r--src/resolve/resolved-dns-scope.c11
-rw-r--r--src/resolve/resolved-dns-search-domain.c1
-rw-r--r--src/resolve/resolved-dns-server.c4
-rw-r--r--src/resolve/resolved-dns-transaction.c8
-rw-r--r--src/resolve/resolved-dns-trust-anchor.c1
-rw-r--r--src/resolve/resolved-dns-zone.c30
-rw-r--r--src/resolve/resolved-dnssd-bus.c1
-rw-r--r--src/resolve/resolved-dnssd.c2
-rw-r--r--src/resolve/resolved-etc-hosts.c3
-rw-r--r--src/resolve/resolved-link-bus.c3
-rw-r--r--src/resolve/resolved-link.c11
-rw-r--r--src/resolve/resolved-manager.c8
-rw-r--r--src/resolve/resolved-mdns.c2
-rw-r--r--src/rfkill/rfkill.c5
-rw-r--r--src/run-generator/run-generator.c1
-rw-r--r--src/shared/acl-util.c1
-rw-r--r--src/shared/bootspec.c4
-rw-r--r--src/shared/bus-polkit.c1
-rw-r--r--src/shared/bus-unit-procs.c8
-rw-r--r--src/shared/bus-unit-util.c3
-rw-r--r--src/shared/bus-util.c2
-rw-r--r--src/shared/cgroup-setup.c1
-rw-r--r--src/shared/condition.c8
-rw-r--r--src/shared/conf-parser.c1
-rw-r--r--src/shared/discover-image.c6
-rw-r--r--src/shared/dissect-image.c3
-rw-r--r--src/shared/dropin.c1
-rw-r--r--src/shared/exec-util.c4
-rw-r--r--src/shared/format-table.c1
-rw-r--r--src/shared/hwdb-util.c3
-rw-r--r--src/shared/install.c28
-rw-r--r--src/shared/libcrypt-util.c1
-rw-r--r--src/shared/libfido2-util.c3
-rw-r--r--src/shared/mount-setup.c3
-rw-r--r--src/shared/mount-util.c1
-rw-r--r--src/shared/net-condition.c4
-rw-r--r--src/shared/nscd-flush.c1
-rw-r--r--src/shared/pkcs11-util.c1
-rw-r--r--src/shared/pretty-print.c4
-rw-r--r--src/shared/seccomp-util.c1
-rw-r--r--src/shared/serialize.c1
-rw-r--r--src/shared/tests.c1
-rw-r--r--src/shared/user-record-show.c13
-rw-r--r--src/shared/varlink.c3
-rw-r--r--src/shutdown/test-umount.c2
-rw-r--r--src/shutdown/umount.c13
-rw-r--r--src/sleep/sleep.c2
-rw-r--r--src/sysctl/sysctl.c4
-rw-r--r--src/sysext/sysext.c6
-rw-r--r--src/systemctl/systemctl-cancel-job.c1
-rw-r--r--src/systemctl/systemctl-clean-or-freeze.c1
-rw-r--r--src/systemctl/systemctl-edit.c6
-rw-r--r--src/systemctl/systemctl-enable.c3
-rw-r--r--src/systemctl/systemctl-is-active.c1
-rw-r--r--src/systemctl/systemctl-is-enabled.c1
-rw-r--r--src/systemctl/systemctl-kill.c2
-rw-r--r--src/systemctl/systemctl-list-dependencies.c3
-rw-r--r--src/systemctl/systemctl-list-machines.c1
-rw-r--r--src/systemctl/systemctl-list-units.c1
-rw-r--r--src/systemctl/systemctl-logind.c2
-rw-r--r--src/systemctl/systemctl-reset-failed.c1
-rw-r--r--src/systemctl/systemctl-set-environment.c3
-rw-r--r--src/systemctl/systemctl-set-property.c1
-rw-r--r--src/systemctl/systemctl-show.c9
-rw-r--r--src/systemctl/systemctl-start-unit.c6
-rw-r--r--src/systemctl/systemctl-util.c7
-rw-r--r--src/sysusers/sysusers.c6
-rw-r--r--src/sysv-generator/sysv-generator.c3
-rw-r--r--src/test/test-bpf-foreign-programs.c2
-rw-r--r--src/test/test-bpf-lsm.c1
-rw-r--r--src/test/test-copy.c1
-rw-r--r--src/test/test-env-util.c1
-rw-r--r--src/test/test-exec-util.c3
-rw-r--r--src/test/test-execute.c2
-rw-r--r--src/test/test-fileio.c5
-rw-r--r--src/test/test-fs-util.c1
-rw-r--r--src/test/test-kbd-util.c1
-rw-r--r--src/test/test-list.c2
-rw-r--r--src/test/test-locale-util.c2
-rw-r--r--src/test/test-nss-hosts.c5
-rw-r--r--src/test/test-nss-users.c2
-rw-r--r--src/test/test-path-lookup.c3
-rw-r--r--src/test/test-path-util.c1
-rw-r--r--src/test/test-path.c1
-rw-r--r--src/test/test-sd-path.c1
-rw-r--r--src/test/test-socket-bind.c4
-rw-r--r--src/test/test-string-util.c1
-rw-r--r--src/test/test-strv.c5
-rw-r--r--src/test/test-sysctl-util.c1
-rw-r--r--src/test/test-time-util.c1
-rw-r--r--src/test/test-unit-file.c1
-rw-r--r--src/timedate/timedated.c7
-rw-r--r--src/timesync/timesyncd-bus.c2
-rw-r--r--src/timesync/timesyncd-conf.c1
-rw-r--r--src/timesync/timesyncd-manager.c4
-rw-r--r--src/tmpfiles/tmpfiles.c14
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c5
-rw-r--r--src/udev/net/link-config.c7
-rw-r--r--src/udev/udev-event.c1
-rw-r--r--src/udev/udev-rules.c40
-rw-r--r--src/udev/udevadm-info.c1
-rw-r--r--src/udev/udevd.c17
-rw-r--r--src/userdb/userdbctl.c24
-rw-r--r--src/xdg-autostart-generator/xdg-autostart-condition.c1
-rw-r--r--src/xdg-autostart-generator/xdg-autostart-generator.c1
258 files changed, 346 insertions, 1191 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c
index 0c32152671..d39a8b4415 100644
--- a/src/activate/activate.c
+++ b/src/activate/activate.c
@@ -49,7 +49,6 @@ static int add_epoll(int epoll_fd, int fd) {
}
static int open_sockets(int *epoll_fd, bool accept) {
- char **address;
int n, fd, r, count = 0;
n = sd_listen_fds(true);
@@ -125,7 +124,6 @@ static int open_sockets(int *epoll_fd, bool accept) {
static int exec_process(const char *name, char **argv, int start_fd, size_t n_fds) {
_cleanup_strv_free_ char **envp = NULL;
const char *var;
- char **s;
int r;
if (arg_inetd && n_fds != 1)
@@ -390,7 +388,6 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_FDNAME: {
_cleanup_strv_free_ char **names = NULL;
- char **s;
names = strv_split(optarg, ":");
if (!names)
diff --git a/src/analyze/analyze-calendar.c b/src/analyze/analyze-calendar.c
index ed4697f865..8f6517fa8e 100644
--- a/src/analyze/analyze-calendar.c
+++ b/src/analyze/analyze-calendar.c
@@ -124,7 +124,6 @@ static int test_calendar_one(usec_t n, const char *p) {
int verb_calendar(int argc, char *argv[], void *userdata) {
int ret = 0, r;
- char **p;
usec_t n;
if (arg_base_time != USEC_INFINITY)
diff --git a/src/analyze/analyze-cat-config.c b/src/analyze/analyze-cat-config.c
index 079cad311b..85ed8b01e0 100644
--- a/src/analyze/analyze-cat-config.c
+++ b/src/analyze/analyze-cat-config.c
@@ -10,7 +10,7 @@
#include "strv.h"
int verb_cat_config(int argc, char *argv[], void *userdata) {
- char **arg, **list;
+ char **list;
int r;
pager_open(arg_pager_flags);
diff --git a/src/analyze/analyze-condition.c b/src/analyze/analyze-condition.c
index a382c356dc..58986bc406 100644
--- a/src/analyze/analyze-condition.c
+++ b/src/analyze/analyze-condition.c
@@ -114,8 +114,6 @@ static int verify_conditions(char **lines, UnitFileScope scope, const char *unit
if (r < 0)
return r;
} else {
- char **line;
-
r = unit_new_for_name(m, sizeof(Service), "test.service", &u);
if (r < 0)
return log_error_errno(r, "Failed to create test.service: %m");
diff --git a/src/analyze/analyze-critical-chain.c b/src/analyze/analyze-critical-chain.c
index d3169791d9..3a6b777053 100644
--- a/src/analyze/analyze-critical-chain.c
+++ b/src/analyze/analyze-critical-chain.c
@@ -76,7 +76,6 @@ static bool times_in_range(const UnitTimes *times, const BootTimes *boot) {
static int list_dependencies_one(sd_bus *bus, const char *name, unsigned level, char ***units, unsigned branches) {
_cleanup_strv_free_ char **deps = NULL;
- char **c;
int r;
usec_t service_longest = 0;
int to_print = 0;
@@ -225,11 +224,10 @@ int verb_critical_chain(int argc, char *argv[], void *userdata) {
puts("The time when unit became active or started is printed after the \"@\" character.\n"
"The time the unit took to start is printed after the \"+\" character.\n");
- if (argc > 1) {
- char **name;
+ if (argc > 1)
STRV_FOREACH(name, strv_skip(argv, 1))
list_dependencies(bus, *name);
- } else
+ else
list_dependencies(bus, SPECIAL_DEFAULT_TARGET);
h = hashmap_free(h);
diff --git a/src/analyze/analyze-dot.c b/src/analyze/analyze-dot.c
index 3a1fe043fc..13bea4598f 100644
--- a/src/analyze/analyze-dot.c
+++ b/src/analyze/analyze-dot.c
@@ -18,9 +18,8 @@ static int graph_one_property(
char *to_patterns[]) {
_cleanup_strv_free_ char **units = NULL;
- char **unit;
- int r;
bool match_patterns;
+ int r;
assert(u);
assert(prop);
@@ -84,7 +83,6 @@ static int graph_one(sd_bus *bus, const UnitInfo *u, char *patterns[], char *fro
static int expand_patterns(sd_bus *bus, char **patterns, char ***ret) {
_cleanup_strv_free_ char **expanded_patterns = NULL;
- char **pattern;
int r;
STRV_FOREACH(pattern, patterns) {
diff --git a/src/analyze/analyze-filesystems.c b/src/analyze/analyze-filesystems.c
index 28b2fc1339..66d8397e31 100644
--- a/src/analyze/analyze-filesystems.c
+++ b/src/analyze/analyze-filesystems.c
@@ -145,7 +145,6 @@ int verb_filesystems(int argc, char *argv[], void *userdata) {
if (!set_isempty(known)) {
_cleanup_free_ char **l = NULL;
- char **filesystem;
printf("\n"
"# %sUngrouped filesystems%s (known but not included in any of the groups except @known):\n",
@@ -188,7 +187,6 @@ int verb_filesystems(int argc, char *argv[], void *userdata) {
log_notice_errno(k, "# Not showing unlisted filesystems, couldn't retrieve kernel filesystem list: %m");
} else if (!set_isempty(kernel)) {
_cleanup_free_ char **l = NULL;
- char **filesystem;
printf("\n"
"# %sUnlisted filesystems%s (available to the local kernel, but not included in any of the groups listed above):\n",
@@ -203,9 +201,7 @@ int verb_filesystems(int argc, char *argv[], void *userdata) {
STRV_FOREACH(filesystem, l)
printf("# %s\n", *filesystem);
}
- } else {
- char **name;
-
+ } else
STRV_FOREACH(name, strv_skip(argv, 1)) {
const FilesystemSet *set;
@@ -224,7 +220,6 @@ int verb_filesystems(int argc, char *argv[], void *userdata) {
dump_filesystem_set(set);
first = false;
}
- }
return 0;
}
diff --git a/src/analyze/analyze-inspect-elf.c b/src/analyze/analyze-inspect-elf.c
index cf953cd37b..155c611c71 100644
--- a/src/analyze/analyze-inspect-elf.c
+++ b/src/analyze/analyze-inspect-elf.c
@@ -12,7 +12,6 @@
#include "strv.h"
static int analyze_elf(char **filenames, JsonFormatFlags json_flags) {
- char **filename;
int r;
STRV_FOREACH(filename, filenames) {
diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c
index f1d3ff7480..458b681143 100644
--- a/src/analyze/analyze-security.c
+++ b/src/analyze/analyze-security.c
@@ -2666,7 +2666,6 @@ static int offline_security_checks(char **filenames,
_cleanup_free_ char *var = NULL;
int r, k;
size_t count = 0;
- char **filename;
if (strv_isempty(filenames))
return 0;
@@ -2789,7 +2788,6 @@ static int analyze_security(sd_bus *bus,
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_strv_free_ char **list = NULL;
size_t n = 0;
- char **i;
r = sd_bus_call_method(
bus,
@@ -2841,9 +2839,7 @@ static int analyze_security(sd_bus *bus,
ret = r;
}
- } else {
- char **i;
-
+ } else
STRV_FOREACH(i, units) {
_cleanup_free_ char *mangled = NULL, *instance = NULL;
const char *name;
@@ -2875,7 +2871,6 @@ static int analyze_security(sd_bus *bus,
if (r < 0 && ret >= 0)
ret = r;
}
- }
if (overview_table) {
if (!FLAGS_SET(flags, ANALYZE_SECURITY_SHORT)) {
diff --git a/src/analyze/analyze-syscall-filter.c b/src/analyze/analyze-syscall-filter.c
index 50cd62a71c..582a043088 100644
--- a/src/analyze/analyze-syscall-filter.c
+++ b/src/analyze/analyze-syscall-filter.c
@@ -120,7 +120,6 @@ int verb_syscall_filters(int argc, char *argv[], void *userdata) {
if (!set_isempty(known)) {
_cleanup_free_ char **l = NULL;
- char **syscall;
printf("\n"
"# %sUngrouped System Calls%s (known but not included in any of the groups except @known):\n",
@@ -143,7 +142,6 @@ int verb_syscall_filters(int argc, char *argv[], void *userdata) {
log_notice_errno(k, "# Not showing unlisted system calls, couldn't retrieve kernel system call list: %m");
} else if (!set_isempty(kernel)) {
_cleanup_free_ char **l = NULL;
- char **syscall;
printf("\n"
"# %sUnlisted System Calls%s (supported by the local kernel, but not included in any of the groups listed above):\n",
@@ -158,9 +156,7 @@ int verb_syscall_filters(int argc, char *argv[], void *userdata) {
STRV_FOREACH(syscall, l)
printf("# %s\n", *syscall);
}
- } else {
- char **name;
-
+ } else
STRV_FOREACH(name, strv_skip(argv, 1)) {
const SyscallFilterSet *set;
@@ -179,7 +175,6 @@ int verb_syscall_filters(int argc, char *argv[], void *userdata) {
dump_syscall_filter(set);
first = false;
}
- }
return 0;
}
diff --git a/src/analyze/analyze-timespan.c b/src/analyze/analyze-timespan.c
index 8d7cd2ddd5..f244ace04a 100644
--- a/src/analyze/analyze-timespan.c
+++ b/src/analyze/analyze-timespan.c
@@ -9,8 +9,6 @@
#include "terminal-util.h"
int verb_timespan(int argc, char *argv[], void *userdata) {
- char **input_timespan;
-
STRV_FOREACH(input_timespan, strv_skip(argv, 1)) {
_cleanup_(table_unrefp) Table *table = NULL;
usec_t output_usecs;
diff --git a/src/analyze/analyze-timestamp.c b/src/analyze/analyze-timestamp.c
index 9128207338..ddf34ab75f 100644
--- a/src/analyze/analyze-timestamp.c
+++ b/src/analyze/analyze-timestamp.c
@@ -80,7 +80,6 @@ static int test_timestamp_one(const char *p) {
int verb_timestamp(int argc, char *argv[], void *userdata) {
int ret = 0, r;
- char **p;
STRV_FOREACH(p, strv_skip(argv, 1)) {
r = test_timestamp_one(*p);
diff --git a/src/analyze/analyze-unit-files.c b/src/analyze/analyze-unit-files.c
index 81714914e3..60fbdcb230 100644
--- a/src/analyze/analyze-unit-files.c
+++ b/src/analyze/analyze-unit-files.c
@@ -6,8 +6,6 @@
#include "strv.h"
static bool strv_fnmatch_strv_or_empty(char* const* patterns, char **strv, int flags) {
- char **s;
-
STRV_FOREACH(s, strv)
if (strv_fnmatch_or_empty(patterns, *s, flags))
return true;
diff --git a/src/analyze/analyze-unit-paths.c b/src/analyze/analyze-unit-paths.c
index e2e8c66b7e..32c97b2e52 100644
--- a/src/analyze/analyze-unit-paths.c
+++ b/src/analyze/analyze-unit-paths.c
@@ -8,7 +8,6 @@
int verb_unit_paths(int argc, char *argv[], void *userdata) {
_cleanup_(lookup_paths_free) LookupPaths paths = {};
int r;
- char **p;
r = lookup_paths_init(&paths, arg_scope, 0, NULL);
if (r < 0)
diff --git a/src/analyze/analyze-verify-util.c b/src/analyze/analyze-verify-util.c
index 6c28cc0ca9..7702d83ddc 100644
--- a/src/analyze/analyze-verify-util.c
+++ b/src/analyze/analyze-verify-util.c
@@ -74,10 +74,8 @@ int verify_prepare_filename(const char *filename, char **ret) {
}
int verify_generate_path(char **var, char **filenames) {
- const char *old;
- char **filename;
-
_cleanup_strv_free_ char **ans = NULL;
+ const char *old;
int r;
STRV_FOREACH(filename, filenames) {
@@ -184,7 +182,6 @@ static int verify_executables(Unit *u, const char *root) {
}
static int verify_documentation(Unit *u, bool check_man) {
- char **p;
int r = 0, k;
STRV_FOREACH(p, u->documentation) {
@@ -258,7 +255,6 @@ int verify_units(char **filenames, UnitFileScope scope, bool check_man, bool run
Unit *units[strv_length(filenames)];
_cleanup_free_ char *var = NULL;
int r, k, i, count = 0;
- char **filename;
if (strv_isempty(filenames))
return 0;
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c
index d97b6ed9c8..35e4e1eb31 100644
--- a/src/analyze/analyze-verify.c
+++ b/src/analyze/analyze-verify.c
@@ -9,7 +9,6 @@
static int process_aliases(char *argv[], char *tempdir, char ***ret) {
_cleanup_strv_free_ char **filenames = NULL;
- char **filename;
int r;
assert(argv);
diff --git a/src/ask-password/ask-password.c b/src/ask-password/ask-password.c
index a100679af2..093533182f 100644
--- a/src/ask-password/ask-password.c
+++ b/src/ask-password/ask-password.c
@@ -223,7 +223,6 @@ static int parse_argv(int argc, char *argv[]) {
static int run(int argc, char *argv[]) {
_cleanup_strv_free_erase_ char **l = NULL;
usec_t timeout;
- char **p;
int r;
log_show_color(true);
diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c
index 287428b561..82c6dc5677 100644
--- a/src/basic/conf-files.c
+++ b/src/basic/conf-files.c
@@ -145,7 +145,7 @@ static int conf_files_list_strv_internal(
_cleanup_hashmap_free_ Hashmap *fh = NULL;
_cleanup_set_free_free_ Set *masked = NULL;
- char **files, **p;
+ char **files;
int r;
assert(ret);
@@ -202,11 +202,8 @@ int conf_files_insert(char ***strv, const char *root, char **dirs, const char *p
int c;
c = base_cmp((char* const*) *strv + i, (char* const*) &path);
- if (c == 0) {
- char **dir;
-
+ if (c == 0)
/* Oh, there already is an entry with a matching name (the last component). */
-
STRV_FOREACH(dir, dirs) {
_cleanup_free_ char *rdir = NULL;
char *p1, *p2;
@@ -233,7 +230,7 @@ int conf_files_insert(char ***strv, const char *root, char **dirs, const char *p
}
}
- } else if (c > 0)
+ else if (c > 0)
/* Following files have lower priority, let's go insert our
* new entry. */
break;
diff --git a/src/basic/env-file.c b/src/basic/env-file.c
index e268c5c644..3efd77909c 100644
--- a/src/basic/env-file.c
+++ b/src/basic/env-file.c
@@ -537,7 +537,6 @@ static void write_env_var(FILE *f, const char *v) {
int write_env_file(const char *fname, char **l) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ char *p = NULL;
- char **i;
int r;
assert(fname);
diff --git a/src/basic/env-util.c b/src/basic/env-util.c
index 96b9613d24..b60c9f9fdc 100644
--- a/src/basic/env-util.c
+++ b/src/basic/env-util.c
@@ -96,8 +96,6 @@ bool env_assignment_is_valid(const char *e) {
}
bool strv_env_is_valid(char **e) {
- char **p, **q;
-
STRV_FOREACH(p, e) {
size_t k;
@@ -115,8 +113,6 @@ bool strv_env_is_valid(char **e) {
}
bool strv_env_name_is_valid(char **l) {
- char **p;
-
STRV_FOREACH(p, l) {
if (!env_name_is_valid(*p))
return false;
@@ -129,8 +125,6 @@ bool strv_env_name_is_valid(char **l) {
}
bool strv_env_name_or_assignment_is_valid(char **l) {
- char **p;
-
STRV_FOREACH(p, l) {
if (!env_assignment_is_valid(*p) && !env_name_is_valid(*p))
return false;
@@ -272,7 +266,7 @@ static bool env_entry_has_name(const char *entry, const char *name) {
char **strv_env_delete(char **x, size_t n_lists, ...) {
size_t n, i = 0;
- char **k, **r;
+ char **r;
va_list ap;
/* Deletes every entry from x that is mentioned in the other
@@ -287,7 +281,7 @@ char **strv_env_delete(char **x, size_t n_lists, ...) {
STRV_FOREACH(k, x) {
va_start(ap, n_lists);
for (size_t v = 0; v < n_lists; v++) {
- char **l, **j;
+ char **l;
l = va_arg(ap, char**);
STRV_FOREACH(j, l)
@@ -379,7 +373,6 @@ char **strv_env_unset_many(char **l, ...) {
int strv_env_replace_consume(char ***l, char *p) {
const char *t, *name;
- char **f;
int r;
assert(p);
@@ -467,8 +460,6 @@ int strv_env_assign(char ***l, const char *key, const char *value) {
}
char *strv_env_get_n(char **l, const char *name, size_t k, unsigned flags) {
- char **i;
-
assert(name);
if (k <= 0)
@@ -496,7 +487,7 @@ char *strv_env_get(char **l, const char *name) {
}
char *strv_env_pairs_get(char **l, const char *name) {
- char **key, **value, *result = NULL;
+ char *result = NULL;
assert(name);
@@ -508,7 +499,6 @@ char *strv_env_pairs_get(char **l, const char *name) {
}
char **strv_env_clean_with_callback(char **e, void (*invalid_callback)(const char *p, void *userdata), void *userdata) {
- char **p, **q;
int k = 0;
STRV_FOREACH(p, e) {
@@ -702,7 +692,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
}
char **replace_env_argv(char **argv, char **env) {
- char **ret, **i;
+ char **ret;
size_t k = 0, l = 0;
l = strv_length(argv);
@@ -832,7 +822,6 @@ int setenv_systemd_exec_pid(bool update_only) {
int getenv_path_list(const char *name, char ***ret_paths) {
_cleanup_strv_free_ char **l = NULL;
const char *e;
- char **p;
int r;
assert(name);
diff --git a/src/basic/escape.c b/src/basic/escape.c
index ce57fcc762..1cb7ced545 100644
--- a/src/basic/escape.c
+++ b/src/basic/escape.c
@@ -549,7 +549,6 @@ char* quote_command_line(char **argv, ShellEscapeFlags flags) {
assert(argv);
- char **a;
STRV_FOREACH(a, argv) {
_cleanup_free_ char *t = NULL;
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index cac5479491..e7b670ab2e 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -1042,8 +1042,6 @@ static int search_and_fopen_internal(
FILE **ret,
char **ret_path) {
- char **i;
-
assert(path);
assert(mode);
assert(ret);
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c
index b51d70bc87..bd7a6b0d6e 100644
--- a/src/basic/hashmap.c
+++ b/src/basic/hashmap.c
@@ -1864,7 +1864,6 @@ int _set_put_strdup_full(Set **s, const struct hash_ops *hash_ops, const char *p
int _set_put_strdupv_full(Set **s, const struct hash_ops *hash_ops, char **l HASHMAP_DEBUG_PARAMS) {
int n = 0, r;
- char **i;
assert(s);
diff --git a/src/basic/list.h b/src/basic/list.h
index f827e721eb..58e83a6cb2 100644
--- a/src/basic/list.h
+++ b/src/basic/list.h
@@ -136,33 +136,39 @@
#define LIST_JUST_US(name,item) \
(!(item)->name##_prev && !(item)->name##_next)
+/* The type of the iterator 'i' is automatically determined by the type of 'head', and declared in the
+ * loop. Hence, do not declare the same variable in the outer scope. Sometimes, we set 'head' through
+ * hashmap_get(). In that case, you need to explicitly cast the result. */
+#define LIST_FOREACH_WITH_NEXT(name,i,n,head) \
+ for (typeof(*(head)) *n, *i = (head); i && (n = i->name##_next, true); i = n)
+
#define LIST_FOREACH(name,i,head) \
- for ((i) = (head); (i); (i) = (i)->name##_next)
+ LIST_FOREACH_WITH_NEXT(name, i, UNIQ_T(n, UNIQ), head)
-#define LIST_FOREACH_SAFE(name,i,n,head) \
- for ((i) = (head); (i) && (((n) = (i)->name##_next), 1); (i) = (n))
+#define _LIST_FOREACH_WITH_PREV(name,i,p,start) \
+ for (typeof(*(start)) *p, *i = (start); i && (p = i->name##_prev, true); i = p)
-#define LIST_FOREACH_BACKWARDS(name,i,p) \
- for ((i) = (p); (i); (i) = (i)->name##_prev)
+#define LIST_FOREACH_BACKWARDS(name,i,start) \
+ _LIST_FOREACH_WITH_PREV(name, i, UNIQ_T(p, UNIQ), start)
/* Iterate through all the members of the list p is included in, but skip over p */
#define LIST_FOREACH_OTHERS(name,i,p) \
- for (({ \
- (i) = (p); \
- while ((i) && (i)->name##_prev) \
- (i) = (i)->name##_prev; \
- if ((i) == (p)) \
- (i) = (p)->name##_next; \
- }); \
- (i); \
- (i) = (i)->name##_next == (p) ? (p)->name##_next : (i)->name##_next)
-
-/* Loop starting from p->next until p->prev.
- p can be adjusted meanwhile. */
+ for (typeof(*(p)) *_p = (p), *i = ({ \
+ typeof(*_p) *_j = _p; \
+ while (_j && _j->name##_prev) \
+ _j = _j->name##_prev; \
+ if (_j == _p) \
+ _j = _p->name##_next; \
+ _j; \
+ }); \
+ i; \
+ i = i->name##_next == _p ? _p->name##_next : i->name##_next)
+
+/* Loop starting from p->next until p->prev. p can be adjusted meanwhile. */
#define LIST_LOOP_BUT_ONE(name,i,head,p) \
- for ((i) = (p)->name##_next ? (p)->name##_next : (head); \
- (i) != (p); \
- (i) = (i)->name##_next ? (i)->name##_next : (head))
+ for (typeof(*(p)) *i = (p)->name##_next ? (p)->name##_next : (head); \
+ i != (p); \
+ i = i->name##_next ? i->name##_next : (head))
#define LIST_IS_EMPTY(head) \
(!(head))
diff --git a/src/basic/ordered-set.c b/src/basic/ordered-set.c
index 0a76f04561..b4c2588395 100644
--- a/src/basic/ordered-set.c
+++ b/src/basic/ordered-set.c
@@ -58,7 +58,6 @@ int _ordered_set_put_strdup(OrderedSet **s, const char *p HASHMAP_DEBUG_PARAMS)
int _ordered_set_put_strdupv(OrderedSet **s, char **l HASHMAP_DEBUG_PARAMS) {
int n = 0, r;
- char **i;
STRV_FOREACH(i, l) {
r = _ordered_set_put_strdup(s, *i HASHMAP_DEBUG_PASS_ARGS);
diff --git a/src/basic/os-util.c b/src/basic/os-util.c
index 75c8500e51..ee3a211499 100644
--- a/src/basic/os-util.c
+++ b/src/basic/os-util.c
@@ -273,7 +273,6 @@ int load_os_release_pairs(const char *root, char ***ret) {
int load_os_release_pairs_with_prefix(const char *root, const char *prefix, char ***ret) {
_cleanup_strv_free_ char **os_release_pairs = NULL, **os_release_pairs_prefixed = NULL;
- char **p, **q;
int r;
r = load_os_release_pairs(root, &os_release_pairs);
diff --git a/src/basic/path-lookup.c b/src/basic/path-lookup.c
index 921a30cef7..2dd587fd8a 100644
--- a/src/basic/path-lookup.c
+++ b/src/basic/path-lookup.c
@@ -463,7 +463,6 @@ static int patch_root_prefix(char **p, const char *root_dir) {
}
static int patch_root_prefix_strv(char **l, const char *root_dir) {
- char **i;
int r;
if (!root_dir)
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
index 42fae3d992..7e81f06650 100644
--- a/src/basic/path-util.c
+++ b/src/basic/path-util.c
@@ -202,9 +202,9 @@ int path_make_relative(const char *from, const char *to, char **ret) {
}
char* path_startswith_strv(const char *p, char **set) {
- char **s, *t;
-
STRV_FOREACH(s, set) {
+ char *t;
+
t = path_startswith(p, *s);
if (t)
return t;
@@ -214,7 +214,6 @@ char* path_startswith_strv(const char *p, char **set) {
}
int path_strv_make_absolute_cwd(char **l) {
- char **s;
int r;
/* Goes through every item in the string list and makes it
@@ -236,7 +235,6 @@ int path_strv_make_absolute_cwd(char **l) {
}
char **path_strv_resolve(char **l, const char *root) {
- char **s;
unsigned k = 0;
bool enomem = false;
int r;
@@ -700,12 +698,12 @@ int find_executable_full(const char *name, const char *root, char **exec_search_
p = DEFAULT_PATH;
if (exec_search_path) {
- char **element;
-
STRV_FOREACH(element, exec_search_path) {
_cleanup_free_ char *full_path = NULL;
+
if (!path_is_absolute(*element))
continue;
+
full_path = path_join(*element, name);
if (!full_path)
return -ENOMEM;
@@ -754,7 +752,6 @@ int find_executable_full(const char *name, const char *root, char **exec_search_
bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool update) {
bool changed = false, originally_unset;
- const char* const* i;
assert(timestamp);
@@ -1339,7 +1336,7 @@ int systemd_installation_has_version(const char *root, unsigned minimal_version)
_cleanup_strv_free_ char **names = NULL;
_cleanup_free_ char *path = NULL;
- char *c, **name;
+ char *c;
path = path_join(root, pattern);
if (!path)
@@ -1411,8 +1408,6 @@ bool empty_or_root(const char *path) {
}
bool path_strv_contains(char **l, const char *path) {
- char **i;
-
STRV_FOREACH(i, l)
if (path_equal(*i, path))
return true;
@@ -1421,10 +1416,9 @@ bool path_strv_contains(char **l, const char *path) {
}
bool prefixed_path_strv_contains(char **l, const char *path) {
- char **i, *j;
-
STRV_FOREACH(i, l) {
- j = *i;
+ const char *j = *i;
+
if (*j == '-')
j++;
if (*j == '+')
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 680900c731..72807d039c 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -215,7 +215,6 @@ int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags
assert(!(flags & PROCESS_CMDLINE_USE_LOCALE));
_cleanup_strv_free_ char **args = NULL;
- char **p;
args = strv_parse_nulstr(t, k);
if (!args)
diff --git a/src/basic/strv.c b/src/basic/strv.c
index eb2913a2e8..c4e3dad446 100644
--- a/src/basic/strv.c
+++ b/src/basic/strv.c
@@ -17,8 +17,6 @@
#include "strv.h"
char* strv_find(char * const *l, const char *name) {
- char * const *i;
-
assert(name);
STRV_FOREACH(i, l)
@@ -29,8 +27,6 @@ char* strv_find(char * const *l, const char *name) {
}
char* strv_find_case(char * const *l, const char *name) {
- char * const *i;
-
assert(name);
STRV_FOREACH(i, l)
@@ -41,8 +37,6 @@ char* strv_find_case(char * const *l, const char *name) {
}
char* strv_find_prefix(char * const *l, const char *name) {
- char * const *i;
-
assert(name);
STRV_FOREACH(i, l)
@@ -53,14 +47,14 @@ char* strv_find_prefix(char * const *l, const char *name) {
}
char* strv_find_startswith(char * const *l, const char *name) {
- char * const *i, *e;
-
assert(name);
/* Like strv_find_prefix, but actually returns only the
* suffix, not the whole item */
STRV_FOREACH(i, l) {
+ char *e;
+
e = startswith(*i, name);
if (e)
return e;
@@ -70,8 +64,6 @@ char* strv_find_startswith(char * const *l, const char *name) {
}
char** strv_free(char **l) {
- char **k;
-
STRV_FOREACH(k, l)
free(*k);
@@ -79,8 +71,6 @@ char** strv_free(char **l) {
}
char** strv_free_erase(char **l) {
- char **i;
-
STRV_FOREACH(i, l)
erase_and_freep(i);
@@ -89,7 +79,7 @@ char** strv_free_erase(char **l) {
char** strv_copy(char * const *l) {
_cleanup_strv_free_ char **result = NULL;
- char **k, * const *i;
+ char **k;
result = new(char*, strv_length(l) + 1);
if (!result)
@@ -108,7 +98,6 @@ char** strv_copy(char * const *l) {
}
size_t strv_length(char * const *l) {
- char * const *i;
size_t n = 0;
STRV_FOREACH(i, l)
@@ -168,8 +157,8 @@ char** strv_new_internal(const char *x, ...) {
}
int strv_extend_strv(char ***a, char * const *b, bool filter_duplicates) {
- char * const *s, **t;
size_t p, q, i = 0;
+ char **t;
assert(a);
@@ -214,7 +203,6 @@ rollback:
}
int strv_extend_strv_concat(char ***a, char * const *b, const char *suffix) {
- char * const *s;
int r;
STRV_FOREACH(s, b) {
@@ -364,7 +352,6 @@ int strv_split_colon_pairs(char ***t, const char *s) {
}
char* strv_join_full(char * const *l, const char *separator, const char *prefix, bool unescape_separators) {
- char * const *s;
char *r, *e;
size_t n, k, m;
@@ -592,8 +579,6 @@ int strv_extend_front(char ***l, const char *value) {
}
char** strv_uniq(char **l) {
- char **i;
-
/* Drops duplicate entries. The first identical string will be
* kept, the others dropped */
@@ -604,8 +589,6 @@ char** strv_uniq(char **l) {
}
bool strv_is_uniq(char * const *l) {
- char * const *i;
-
STRV_FOREACH(i, l)
if (strv_contains(i+1, *i))
return false;
@@ -714,7 +697,6 @@ int strv_make_nulstr(char * const *l, char **ret, size_t *ret_size) {
*/
_cleanup_free_ char *m = NULL;
- char * const *i;
size_t n = 0;
assert(ret);
@@ -751,8 +733,6 @@ int strv_make_nulstr(char * const *l, char **ret, size_t *ret_size) {
}
bool strv_overlap(char * const *a, char * const *b) {
- char * const *i;
-
STRV_FOREACH(i, a)
if (strv_contains(b, *i))
return true;
@@ -792,8 +772,6 @@ int strv_compare(char * const *a, char * const *b) {
}
void strv_print(char * const *l) {
- char * const *s;
-
STRV_FOREACH(s, l)
puts(*s);
}
@@ -827,8 +805,6 @@ char** strv_reverse(char **l) {
}
char** strv_shell_escape(char **l, const char *bad) {
- char **s;
-
/* Escapes every character in every string in l that is in bad,
* edits in-place, does not roll-back on error. */
@@ -911,7 +887,6 @@ rollback:
int fputstrv(FILE *f, char * const *l, const char *separator, bool *space) {
bool b = false;
- char * const *s;
int r;
/* Like fputs(), but for strv, and with a less stupid argument order */
diff --git a/src/basic/strv.h b/src/basic/strv.h
index 092d40c84b..985499272f 100644
--- a/src/basic/strv.h
+++ b/src/basic/strv.h
@@ -122,19 +122,30 @@ static inline int strv_from_nulstr(char ***a, const char *nulstr) {
bool strv_overlap(char * const *a, char * const *b) _pure_;
+#define _STRV_FOREACH(s, l, i) \
+ for (typeof(*(l)) *s, *i = (l); (s = i) && *i; i++)
+
#define STRV_FOREACH(s, l) \
- for ((s) = (l); (s) && *(s); (s)++)
+ _STRV_FOREACH(s, l, UNIQ_T(i, UNIQ))
+
+#define _STRV_FOREACH_BACKWARDS(s, l, h, i) \
+ for (typeof(*(l)) *s, *h = (l), *i = ({ \
+ size_t _len = strv_length(h); \
+ _len > 0 ? h + _len - 1 : NULL; \
+ }); \
+ i && (s = i) >= h; \
+ i--)
+
+#define STRV_FOREACH_BACKWARDS(s, l) \
+ _STRV_FOREACH_BACKWARDS(s, l, UNIQ_T(h, UNIQ), UNIQ_T(i, UNIQ))
-#define STRV_FOREACH_BACKWARDS(s, l) \
- for (s = ({ \
- typeof(l) _l = l; \
- _l ? _l + strv_length(_l) - 1U : NULL; \
- }); \
- (l) && ((s) >= (l)); \
- (s)--)
+#define _STRV_FOREACH_PAIR(x, y, l, i) \
+ for (typeof(*l) *x, *y, *i = (l); \
+ i && *(x = i) && *(y = i + 1); \
+ i += 2)
-#define STRV_FOREACH_PAIR(x, y, l) \
- for ((x) = (l), (y) = (x) ? (x+1) : NULL; (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
+#define STRV_FOREACH_PAIR(x, y, l) \
+ _STRV_FOREACH_PAIR(x, y, l, UNIQ_T(i, UNIQ))
char** strv_sort(char **l);
void strv_print(char * const *l);
@@ -185,7 +196,7 @@ void strv_print(char * const *l);
#define STARTSWITH_SET(p, ...) \
({ \
const char *_p = (p); \
- char *_found = NULL, **_i; \
+ char *_found = NULL; \
STRV_FOREACH(_i, STRV_MAKE(__VA_ARGS__)) { \
_found = startswith(_p, *_i); \
if (_found) \
@@ -197,7 +208,7 @@ void strv_print(char * const *l);
#define ENDSWITH_SET(p, ...) \
({ \
const char *_p = (p); \
- char *_found = NULL, **_i; \
+ char *_found = NULL; \
STRV_FOREACH(_i, STRV_MAKE(__VA_ARGS__)) { \
_found = endswith(_p, *_i); \
if (_found) \
diff --git a/src/basic/unit-file.c b/src/basic/unit-file.c
index faea92f66d..c2512dc9ab 100644
--- a/src/basic/unit-file.c
+++ b/src/basic/unit-file.c
@@ -209,8 +209,7 @@ bool lookup_paths_timestamp_hash_same(const LookupPaths *lp, uint64_t timestamp_
siphash24_init(&state, HASH_KEY.bytes);
- char **dir;
- STRV_FOREACH(dir, (char**) lp->search_path) {
+ STRV_FOREACH(dir, lp->search_path) {
struct stat st;
if (lookup_paths_mtime_exclude(lp, *dir))
@@ -281,7 +280,6 @@ int unit_file_build_name_map(
_cleanup_hashmap_free_ Hashmap *ids = NULL, *names = NULL;
_cleanup_set_free_free_ Set *paths = NULL;
uint64_t timestamp_hash;
- char **dir;
int r;
/* Before doing anything, check if the timestamp hash that was passed is still valid.
@@ -299,7 +297,7 @@ int unit_file_build_name_map(
return log_oom();
}
- STRV_FOREACH(dir, (char**) lp->search_path) {
+ STRV_FOREACH(dir, lp->search_path) {
_cleanup_closedir_ DIR *d = NULL;
d = opendir(*dir);
@@ -550,7 +548,7 @@ static int add_names(
Set **names,
const char *name) {
- char **aliases, **alias;
+ char **aliases;
int r;
assert(name_type == UNIT_NAME_PLAIN || instance);
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 18231c2618..817ee387ff 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -213,7 +213,6 @@ static int run(int argc, char *argv[]) {
}
else {
_cleanup_strv_free_ char **files = NULL;
- char **f;
r = conf_files_list_strv(&files, ".conf", NULL, 0, (const char**) CONF_PATHS_STRV("binfmt.d"));
if (r < 0)
diff --git a/src/boot/bless-boot.c b/src/boot/bless-boot.c
index 259085d5de..259ae33bb5 100644
--- a/src/boot/bless-boot.c
+++ b/src/boot/bless-boot.c
@@ -325,7 +325,6 @@ static const char *skip_slash(const char *path) {
static int verb_status(int argc, char *argv[], void *userdata) {
_cleanup_free_ char *path = NULL, *prefix = NULL, *suffix = NULL, *good = NULL, *bad = NULL;
uint64_t left, done;
- char **p;
int r;
r = acquire_boot_count_path(&path, &prefix, &left, &done, &suffix);
@@ -402,7 +401,6 @@ static int verb_set(int argc, char *argv[], void *userdata) {
_cleanup_free_ char *path = NULL, *prefix = NULL, *suffix = NULL, *good = NULL, *bad = NULL, *parent = NULL;
const char *target, *source1, *source2;
uint64_t done;
- char **p;
int r;
r = acquire_boot_count_path(&path, &prefix, NULL, &done, &suffix);
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 83ad499c53..a1d5af8c21 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -602,7 +602,6 @@ static int boot_entry_show(
if (e->kernel)
boot_entry_file_list("linux", e->root, e->kernel, &status);
- char **s;
STRV_FOREACH(s, e->initrd)
boot_entry_file_list(s == e->initrd ? "initrd" : NULL,
e->root,
@@ -843,7 +842,6 @@ static const char *const dollar_boot_subdirs[] = {
};
static int create_subdirs(const char *root, const char * const *subdirs) {
- const char *const *i;
int r;
STRV_FOREACH(i, subdirs) {
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index b532de4f9b..0f97015bd4 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -143,7 +143,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_hashmap_free_ Hashmap *names = NULL;
_cleanup_(table_unrefp) Table *table = NULL;
- char **i, *k;
+ char *k;
void *v;
int r;
@@ -504,7 +504,6 @@ static int tree_one(sd_bus *bus, const char *service) {
static int tree(int argc, char **argv, void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
- char **i;
int r;
/* Do superficial verification of arguments before even opening the bus */
@@ -1208,7 +1207,6 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
- char **i;
uint32_t flags = 0;
const char *unique_name;
bool is_monitor = false;
@@ -2124,7 +2122,6 @@ static int emit_signal(int argc, char **argv, void *userdata) {
static int get_property(int argc, char **argv, void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
- char **i;
int r;
r = acquire_bus(false, &bus);
diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c
index 936ea4d3af..6af95204e3 100644
--- a/src/cgls/cgls.c
+++ b/src/cgls/cgls.c
@@ -201,7 +201,6 @@ static int run(int argc, char *argv[]) {
if (arg_names) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_free_ char *root = NULL;
- char **name;
STRV_FOREACH(name, arg_names) {
int q;
diff --git a/src/core/bpf-firewall.c b/src/core/bpf-firewall.c
index 0297053add..edcfed1eb4 100644
--- a/src/core/bpf-firewall.c
+++ b/src/core/bpf-firewall.c
@@ -605,8 +605,6 @@ int bpf_firewall_compile(Unit *u) {
}
static int load_bpf_progs_from_fs_to_set(Unit *u, char **filter_paths, Set **set) {
- char **bpf_fs_path;
-
set_clear(*set);
STRV_FOREACH(bpf_fs_path, filter_paths) {
diff --git a/src/core/bpf-foreign.c b/src/core/bpf-foreign.c
index 8538792b60..7f50f57389 100644
--- a/src/core/bpf-foreign.c
+++ b/src/core/bpf-foreign.c
@@ -123,7 +123,6 @@ static int bpf_foreign_prepare(
int bpf_foreign_install(Unit *u) {
_cleanup_free_ char *cgroup_path = NULL;
- CGroupBPFForeignProgram *p;
CGroupContext *cc;
int r;
diff --git a/src/core/bpf-socket-bind.c b/src/core/bpf-socket-bind.c
index 806df84ea7..09f83dc667 100644
--- a/src/core/bpf-socket-bind.c
+++ b/src/core/bpf-socket-bind.c
@@ -27,7 +27,6 @@ static int update_rules_map(
int map_fd,
CGroupSocketBindItem *head) {
- CGroupSocketBindItem *item;
uint32_t i = 0;
assert(map_fd >= 0);
@@ -58,7 +57,6 @@ static int prepare_socket_bind_bpf(
_cleanup_(socket_bind_bpf_freep) struct socket_bind_bpf *obj = NULL;
size_t allow_count = 0, deny_count = 0;
int allow_map_fd, deny_map_fd, r;
- CGroupSocketBindItem *item;
assert(ret_obj);
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 98bf5e8db7..dda87db7e1 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -414,17 +414,8 @@ static char *format_cgroup_memory_limit_comparison(char *buf, size_t l, Unit *u,
void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
_cleanup_free_ char *disable_controllers_str = NULL, *cpuset_cpus = NULL, *cpuset_mems = NULL, *startup_cpuset_cpus = NULL, *startup_cpuset_mems = NULL;
- CGroupIODeviceLimit *il;
- CGroupIODeviceWeight *iw;
- CGroupIODeviceLatency *l;
- CGroupBlockIODeviceBandwidth *b;
- CGroupBlockIODeviceWeight *w;
- CGroupBPFForeignProgram *p;
- CGroupDeviceAllow *a;
CGroupContext *c;
- CGroupSocketBindItem *bi;
struct in_addr_prefix *iaai;
- char **path;
char cda[FORMAT_CGROUP_DIFF_MAX];
char cdb[FORMAT_CGROUP_DIFF_MAX];
@@ -1219,7 +1210,6 @@ static int cgroup_apply_devices(Unit *u) {
_cleanup_(bpf_program_freep) BPFProgram *prog = NULL;
const char *path;
CGroupContext *c;
- CGroupDeviceAllow *a;
CGroupDevicePolicy policy;
int r;
@@ -1440,10 +1430,6 @@ static void cgroup_context_apply(
set_io_weight(u, weight);
if (has_io) {
- CGroupIODeviceLatency *latency;
- CGroupIODeviceLimit *limit;
- CGroupIODeviceWeight *w;
-
LIST_FOREACH(device_weights, w, c->io_device_weights)
cgroup_apply_io_device_weight(u, w->path, w->weight);
@@ -1454,9 +1440,6 @@ static void cgroup_context_apply(
cgroup_apply_io_device_latency(u, latency->path, latency->target_usec);
} else if (has_blockio) {
- CGroupBlockIODeviceWeight *w;
- CGroupBlockIODeviceBandwidth *b;
-
LIST_FOREACH(device_weights, w, c->blockio_device_weights) {
weight = cgroup_weight_blkio_to_io(w->weight);
@@ -1509,9 +1492,7 @@ static void cgroup_context_apply(
set_blkio_weight(u, weight);
- if (has_io) {
- CGroupIODeviceWeight *w;
-
+ if (has_io)
LIST_FOREACH(device_weights, w, c->io_device_weights) {
weight = cgroup_weight_io_to_blkio(w->weight);
@@ -1520,32 +1501,24 @@ static void cgroup_context_apply(
cgroup_apply_blkio_device_weight(u, w->path, weight);
}
- } else if (has_blockio) {
- CGroupBlockIODeviceWeight *w;
-
+ else if (has_blockio)
LIST_FOREACH(device_weights, w, c->blockio_device_weights)
cgroup_apply_blkio_device_weight(u, w->path, w->weight);
- }
}
/* The bandwidth limits are something that make sense to be applied to the host's root but not container
* roots, as there we want the container manager to handle it */
if (is_host_root || !is_local_root) {
- if (has_io) {
- CGroupIODeviceLimit *l;
-
+ if (has_io)
LIST_FOREACH(device_limits, l, c->io_device_limits) {
log_cgroup_compat(u, "Applying IO{Read|Write}Bandwidth=%" PRIu64 " %" PRIu64 " as BlockIO{Read|Write}BandwidthMax= for %s",
l->limits[CGROUP_IO_RBPS_MAX], l->limits[CGROUP_IO_WBPS_MAX], l->path);
cgroup_apply_blkio_device_limit(u, l->path, l->limits[CGROUP_IO_RBPS_MAX], l->limits[CGROUP_IO_WBPS_MAX]);
}
- } else if (has_blockio) {
- CGroupBlockIODeviceBandwidth *b;
-
+ else if (has_blockio)
LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths)
cgroup_apply_blkio_device_limit(u, b->path, b->rbps, b->wbps);
- }
}
}
diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c
index a75f9fb66f..40cfd0cc7a 100644
--- a/src/core/core-varlink.c
+++ b/src/core/core-varlink.c
@@ -157,9 +157,7 @@ static int build_managed_oom_cgroups_json(Manager *m, JsonVariant **ret) {
if (r < 0)
return r;
- for (size_t i = 0; i < ELEMENTSOF(supported_unit_types); i++) {
- Unit *u;
-
+ for (size_t i = 0; i < ELEMENTSOF(supported_unit_types); i++)
LIST_FOREACH(units_by_type, u, m->units_by_type[supported_unit_types[i]]) {
CGroupContext *c;
@@ -188,7 +186,6 @@ static int build_managed_oom_cgroups_json(Manager *m, JsonVariant **ret) {
return r;
}
}
- }
r = json_build(&v, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("cgroups", JSON_BUILD_VARIANT(arr))));
if (r < 0)
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index f0d8759e85..9a31355a4d 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -112,7 +112,6 @@ static int property_get_io_device_weight(
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupIODeviceWeight *w;
int r;
assert(bus);
@@ -142,7 +141,6 @@ static int property_get_io_device_limits(
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupIODeviceLimit *l;
int r;
assert(bus);
@@ -178,7 +176,6 @@ static int property_get_io_device_latency(
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupIODeviceLatency *l;
int r;
assert(bus);
@@ -208,7 +205,6 @@ static int property_get_blockio_device_weight(
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupBlockIODeviceWeight *w;
int r;
assert(bus);
@@ -238,7 +234,6 @@ static int property_get_blockio_device_bandwidths(
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupBlockIODeviceBandwidth *b;
int r;
assert(bus);
@@ -278,7 +273,6 @@ static int property_get_device_allow(
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupDeviceAllow *a;
int r;
assert(bus);
@@ -364,7 +358,6 @@ static int property_get_bpf_foreign_program(
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupBPFForeignProgram *p;
int r;
r = sd_bus_message_open_container(reply, 'a', "(ss)");
@@ -390,7 +383,8 @@ static int property_get_socket_bind(
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
- CGroupSocketBindItem **items = userdata, *i;
+
+ CGroupSocketBindItem **items = userdata;
int r;
assert(items);
@@ -640,7 +634,6 @@ static int bus_cgroup_set_transient_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- char **entry;
size_t size = 0;
if (n == 0)
@@ -720,7 +713,6 @@ static int bus_cgroup_set_transient_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupBPFForeignProgram *fp;
size_t size = 0;
if (n == 0)
@@ -1228,14 +1220,13 @@ int bus_cgroup_set_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupIODeviceLimit *a = NULL, *b;
+ CGroupIODeviceLimit *a = NULL;
- LIST_FOREACH(device_limits, b, c->io_device_limits) {
+ LIST_FOREACH(device_limits, b, c->io_device_limits)
if (path_equal(path, b->path)) {
a = b;
break;
}
- }
if (!a) {
CGroupIOLimitType type;
@@ -1269,15 +1260,13 @@ int bus_cgroup_set_property(
return r;
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupIODeviceLimit *a;
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
LIST_FOREACH(device_limits, a, c->io_device_limits)
a->limits[iol_type] = cgroup_io_limit_defaults[iol_type];
- }
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
@@ -1287,8 +1276,8 @@ int bus_cgroup_set_property(
fprintf(f, "%s=\n", name);
LIST_FOREACH(device_limits, a, c->io_device_limits)
- if (a->limits[iol_type] != cgroup_io_limit_defaults[iol_type])
- fprintf(f, "%s=%s %" PRIu64 "\n", name, a->path, a->limits[iol_type]);
+ if (a->limits[iol_type] != cgroup_io_limit_defaults[iol_type])
+ fprintf(f, "%s=%s %" PRIu64 "\n", name, a->path, a->limits[iol_type]);
r = fflush_and_check(f);
if (r < 0)
@@ -1316,14 +1305,13 @@ int bus_cgroup_set_property(
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "IODeviceWeight= value out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupIODeviceWeight *a = NULL, *b;
+ CGroupIODeviceWeight *a = NULL;
- LIST_FOREACH(device_weights, b, c->io_device_weights) {
+ LIST_FOREACH(device_weights, b, c->io_device_weights)
if (path_equal(b->path, path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupIODeviceWeight, 1);
@@ -1351,13 +1339,11 @@ int bus_cgroup_set_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupIODeviceWeight *a;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
while (c->io_device_weights)
cgroup_context_free_io_device_weight(c, c->io_device_weights);
- }
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
@@ -1392,14 +1378,13 @@ int bus_cgroup_set_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupIODeviceLatency *a = NULL, *b;
+ CGroupIODeviceLatency *a = NULL;
- LIST_FOREACH(device_latencies, b, c->io_device_latencies) {
+ LIST_FOREACH(device_latencies, b, c->io_device_latencies)
if (path_equal(b->path, path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupIODeviceLatency, 1);
@@ -1427,13 +1412,11 @@ int bus_cgroup_set_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupIODeviceLatency *a;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
while (c->io_device_latencies)
cgroup_context_free_io_device_latency(c, c->io_device_latencies);
- }
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
@@ -1473,14 +1456,13 @@ int bus_cgroup_set_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupBlockIODeviceBandwidth *a = NULL, *b;
+ CGroupBlockIODeviceBandwidth *a = NULL;
- LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) {
+ LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths)
if (path_equal(path, b->path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupBlockIODeviceBandwidth, 1);
@@ -1514,19 +1496,17 @@ int bus_cgroup_set_property(
return r;
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupBlockIODeviceBandwidth *a;
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths) {
if (read)
a->rbps = CGROUP_LIMIT_MAX;
else
a->wbps = CGROUP_LIMIT_MAX;
}
- }
unit_invalidate_cgroup(u, CGROUP_MASK_BLKIO);
@@ -1573,14 +1553,13 @@ int bus_cgroup_set_property(
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "BlockIODeviceWeight= out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupBlockIODeviceWeight *a = NULL, *b;
+ CGroupBlockIODeviceWeight *a = NULL;
- LIST_FOREACH(device_weights, b, c->blockio_device_weights) {
+ LIST_FOREACH(device_weights, b, c->blockio_device_weights)
if (path_equal(b->path, path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupBlockIODeviceWeight, 1);
@@ -1608,13 +1587,11 @@ int bus_cgroup_set_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupBlockIODeviceWeight *a;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
while (c->blockio_device_weights)
cgroup_context_free_blockio_device_weight(c, c->blockio_device_weights);
- }
unit_invalidate_cgroup(u, CGROUP_MASK_BLKIO);
@@ -1674,14 +1651,13 @@ int bus_cgroup_set_property(
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "DeviceAllow= requires combination of rwm flags");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupDeviceAllow *a = NULL, *b;
+ CGroupDeviceAllow *a = NULL;
- LIST_FOREACH(device_allow, b, c->device_allow) {
+ LIST_FOREACH(device_allow, b, c->device_allow)
if (path_equal(b->path, path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupDeviceAllow, 1);
@@ -1714,13 +1690,11 @@ int bus_cgroup_set_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupDeviceAllow *a;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
while (c->device_allow)
cgroup_context_free_device_allow(c, c->device_allow);
- }
unit_invalidate_cgroup(u, CGROUP_MASK_DEVICES);
@@ -1995,7 +1969,6 @@ int bus_cgroup_set_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupSocketBindItem *item;
size_t size = 0;
if (n == 0)
@@ -2050,7 +2023,6 @@ int bus_cgroup_set_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *joined = NULL;
- char **s;
if (strv_isempty(l)) {
c->restrict_network_interfaces_is_allow_list = false;
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 8a8d9c9b2e..65eec8f6b7 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -74,7 +74,6 @@ static int property_get_environment_files(
sd_bus_error *error) {
ExecContext *c = userdata;
- char **j;
int r;
assert(bus);
@@ -960,7 +959,6 @@ static int property_get_root_image_options(
sd_bus_error *error) {
ExecContext *c = userdata;
- MountOptions *m;
int r;
assert(bus);
@@ -1005,8 +1003,6 @@ static int property_get_mount_images(
return r;
for (size_t i = 0; i < c->n_mount_images; i++) {
- MountOptions *m;
-
r = sd_bus_message_open_container(reply, SD_BUS_TYPE_STRUCT, "ssba(ss)");
if (r < 0)
return r;
@@ -1060,8 +1056,6 @@ static int property_get_extension_images(
return r;
for (size_t i = 0; i < c->n_extension_images; i++) {
- MountOptions *m;
-
r = sd_bus_message_open_container(reply, SD_BUS_TYPE_STRUCT, "sba(ss)");
if (r < 0)
return r;
@@ -1143,15 +1137,12 @@ static int bus_property_get_exec_dir_symlink(
if (r < 0)
return r;
- for (size_t i = 0; i < d->n_items; i++) {
- char **dst;
-
+ for (size_t i = 0; i < d->n_items; i++)
STRV_FOREACH(dst, d->items[i].symlinks) {
r = sd_bus_message_append(reply, "(sst)", d->items[i].path, *dst, 0 /* flags, unused for now */);
if (r < 0)
return r;
}
- }
return sd_bus_message_close_container(reply);
}
@@ -1449,7 +1440,7 @@ int bus_property_get_exec_command_list(
void *userdata,
sd_bus_error *ret_error) {
- ExecCommand *c = *(ExecCommand**) userdata;
+ ExecCommand *exec_command = *(ExecCommand**) userdata;
int r;
assert(bus);
@@ -1459,7 +1450,7 @@ int bus_property_get_exec_command_list(
if (r < 0)
return r;
- LIST_FOREACH(command, c, c) {
+ LIST_FOREACH(command, c, exec_command) {
r = append_exec_command(reply, c);
if (r < 0)
return r;
@@ -1477,7 +1468,7 @@ int bus_property_get_exec_ex_command_list(
void *userdata,
sd_bus_error *ret_error) {
- ExecCommand *c, *exec_command = *(ExecCommand**) userdata;
+ ExecCommand *exec_command = *(ExecCommand**) userdata;
int r;
assert(bus);
@@ -1587,7 +1578,6 @@ int bus_set_transient_exec_command(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- ExecCommand *c;
size_t size = 0;
if (n == 0)
@@ -2022,7 +2012,6 @@ int bus_exec_context_set_transient_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *joined = NULL;
FilesystemParseFlags invert_flag = allow_list ? 0 : FILESYSTEM_PARSE_INVERT;
- char **s;
if (strv_isempty(l)) {
c->restrict_filesystems_allow_list = false;
@@ -2068,7 +2057,6 @@ int bus_exec_context_set_transient_property(
if (streq(name, "SupplementaryGroups")) {
_cleanup_strv_free_ char **l = NULL;
- char **p;
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
@@ -2433,7 +2421,6 @@ int bus_exec_context_set_transient_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *joined = NULL;
SeccompParseFlags invert_flag = allow_list ? 0 : SECCOMP_PARSE_INVERT;
- char **s;
if (strv_isempty(l)) {
c->syscall_allow_list = false;
@@ -2518,7 +2505,6 @@ int bus_exec_context_set_transient_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *joined = NULL;
SeccompParseFlags invert_flag = allow_list ? 0 : SECCOMP_PARSE_INVERT;
- char **s;
if (strv_isempty(l)) {
c->syscall_log_allow_list = false;
@@ -2570,9 +2556,7 @@ int bus_exec_context_set_transient_property(
if (strv_isempty(l))
c->syscall_archs = set_free(c->syscall_archs);
- else {
- char **s;
-
+ else
STRV_FOREACH(s, l) {
uint32_t a;
@@ -2585,8 +2569,6 @@ int bus_exec_context_set_transient_property(
return r;
}
- }
-
joined = strv_join(l, " ");
if (!joined)
return -ENOMEM;
@@ -2618,7 +2600,6 @@ int bus_exec_context_set_transient_property(
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *joined = NULL;
- char **s;
if (strv_isempty(l)) {
c->address_families_allow_list = allow_list;
@@ -3147,7 +3128,6 @@ int bus_exec_context_set_transient_property(
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **l = NULL;
size_t size = 0;
- char **i;
r = sd_bus_message_enter_container(message, 'a', "(sb)");
if (r < 0)
@@ -3266,7 +3246,6 @@ int bus_exec_context_set_transient_property(
"ExtensionDirectories")) {
_cleanup_strv_free_ char **l = NULL;
char ***dirs;
- char **p;
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
@@ -3320,16 +3299,15 @@ int bus_exec_context_set_transient_property(
} else if (streq(name, "ExecSearchPath")) {
_cleanup_strv_free_ char **l = NULL;
- char **p;
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
return r;
- STRV_FOREACH(p, l) {
+ STRV_FOREACH(p, l)
if (!path_is_absolute(*p) || !path_is_normalized(*p) || strchr(*p, ':'))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid %s", name);
- }
+
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (strv_isempty(l)) {
c->exec_search_path = strv_free(c->exec_search_path);
@@ -3350,7 +3328,6 @@ int bus_exec_context_set_transient_property(
} else if (STR_IN_SET(name, "RuntimeDirectory", "StateDirectory", "CacheDirectory", "LogsDirectory", "ConfigurationDirectory")) {
_cleanup_strv_free_ char **l = NULL;
- char **p;
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
@@ -3379,7 +3356,6 @@ int bus_exec_context_set_transient_property(
unit_write_settingf(u, flags, name, "%s=", name);
} else {
_cleanup_free_ char *joined = NULL;
- char **source;
STRV_FOREACH(source, l) {
r = exec_directory_add(&d->items, &d->n_items, *source, NULL);
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 49982d0030..c78e9ef2b2 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -890,7 +890,6 @@ static int method_list_units_by_names(sd_bus_message *message, void *userdata, s
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
int r;
- char **unit;
_cleanup_strv_free_ char **units = NULL;
assert(message);
diff --git a/src/core/dbus-path.c b/src/core/dbus-path.c
index f143ad5d4a..09b353ba3f 100644
--- a/src/core/dbus-path.c
+++ b/src/core/dbus-path.c
@@ -22,7 +22,6 @@ static int property_get_paths(
sd_bus_error *error) {
Path *p = userdata;
- PathSpec *k;
int r;
assert(bus);
diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
index a3b1e0442f..d1e0509e55 100644
--- a/src/core/dbus-socket.c
+++ b/src/core/dbus-socket.c
@@ -32,7 +32,6 @@ static int property_get_listen(
sd_bus_error *error) {
Socket *s = SOCKET(userdata);
- SocketPort *p;
int r;
assert(bus);
@@ -326,16 +325,14 @@ static int bus_socket_set_transient_property(
if (streq(name, "Symlinks")) {
_cleanup_strv_free_ char **l = NULL;
- char **p;
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
return r;
- STRV_FOREACH(p, l) {
+ STRV_FOREACH(p, l)
if (!path_is_absolute(*p))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Symlink path is not absolute: %s", *p);
- }
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (strv_isempty(l)) {
diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c
index 9d823279dd..8110fb1fb7 100644
--- a/src/core/dbus-timer.c
+++ b/src/core/dbus-timer.c
@@ -20,7 +20,6 @@ static int property_get_monotonic_timers(
sd_bus_error *error) {
Timer *t = userdata;
- TimerValue *v;
int r;
assert(bus);
@@ -69,7 +68,6 @@ static int property_get_calendar_timers(
sd_bus_error *error) {
Timer *t = userdata;
- TimerValue *v;
int r;
assert(bus);
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 6542d50330..098ebed847 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -273,7 +273,7 @@ static int property_get_conditions(
sd_bus_error *error) {
const char *(*to_string)(ConditionType type) = NULL;
- Condition **list = userdata, *c;
+ Condition **list = userdata;
int r;
assert(bus);
@@ -2242,16 +2242,14 @@ static int bus_unit_set_transient_property(
if (streq(name, "Documentation")) {
_cleanup_strv_free_ char **l = NULL;
- char **p;
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
return r;
- STRV_FOREACH(p, l) {
+ STRV_FOREACH(p, l)
if (!documentation_url_is_valid(*p))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid URL in %s: %s", name, *p);
- }
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (strv_isempty(l)) {
@@ -2307,7 +2305,6 @@ static int bus_unit_set_transient_property(
} else if (streq(name, "RequiresMountsFor")) {
_cleanup_strv_free_ char **l = NULL;
- char **p;
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
diff --git a/src/core/device.c b/src/core/device.c
index 43f49573b9..21d1b50c42 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -307,13 +307,9 @@ static void device_dump(Unit *u, FILE *f, const char *prefix) {
prefix, strna(d->sysfs),
prefix, strna(s));
- if (!strv_isempty(d->wants_property)) {
- char **i;
-
- STRV_FOREACH(i, d->wants_property)
- fprintf(f, "%sudev SYSTEMD_WANTS: %s\n",
- prefix, *i);
- }
+ STRV_FOREACH(i, d->wants_property)
+ fprintf(f, "%sudev SYSTEMD_WANTS: %s\n",
+ prefix, *i);
}
_pure_ static UnitActiveState device_active_state(Unit *u) {
@@ -419,9 +415,7 @@ static int device_add_udev_wants(Unit *u, sd_device *dev) {
k = NULL;
}
- if (d->state != DEVICE_DEAD) {
- char **i;
-
+ if (d->state != DEVICE_DEAD)
/* So here's a special hack, to compensate for the fact that the udev database's reload cycles are not
* synchronized with our own reload cycles: when we detect that the SYSTEMD_WANTS property of a device
* changes while the device unit is already up, let's manually trigger any new units listed in it not
@@ -431,7 +425,6 @@ static int device_add_udev_wants(Unit *u, sd_device *dev) {
*
* We do this only if the device has been up already when we parse this, as otherwise the usual
* dependency logic that is run from the dead → plugged transition will trigger these deps. */
-
STRV_FOREACH(i, added) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -442,7 +435,6 @@ static int device_add_udev_wants(Unit *u, sd_device *dev) {
if (r < 0)
log_unit_warning_errno(u, r, "Failed to enqueue SYSTEMD_WANTS= job, ignoring: %s", bus_error_message(&error, r));
}
- }
return strv_free_and_replace(d->wants_property, added);
}
@@ -710,7 +702,7 @@ static void device_update_found_one(Device *d, DeviceFound found, DeviceFound ma
}
static void device_update_found_by_sysfs(Manager *m, const char *sysfs, DeviceFound found, DeviceFound mask) {
- Device *d, *l, *n;
+ Device *l;
assert(m);
assert(sysfs);
@@ -719,7 +711,7 @@ static void device_update_found_by_sysfs(Manager *m, const char *sysfs, DeviceFo
return;
l = hashmap_get(m->devices_by_sysfs, sysfs);
- LIST_FOREACH_SAFE(same_sysfs, d, n, l)
+ LIST_FOREACH(same_sysfs, d, l)
device_update_found_one(d, found, mask);
}
@@ -765,7 +757,7 @@ static bool device_is_ready(sd_device *dev) {
static Unit *device_following(Unit *u) {
Device *d = DEVICE(u);
- Device *other, *first = NULL;
+ Device *first = NULL;
assert(d);
@@ -788,7 +780,7 @@ static Unit *device_following(Unit *u) {
}
static int device_following_set(Unit *u, Set **_set) {
- Device *d = DEVICE(u), *other;
+ Device *d = DEVICE(u);
_cleanup_set_free_ Set *set = NULL;
int r;
@@ -898,14 +890,14 @@ fail:
}
static void device_propagate_reload_by_sysfs(Manager *m, const char *sysfs) {
- Device *d, *l, *n;
+ Device *l;
int r;
assert(m);
assert(sysfs);
l = hashmap_get(m->devices_by_sysfs, sysfs);
- LIST_FOREACH_SAFE(same_sysfs, d, n, l) {
+ LIST_FOREACH(same_sysfs, d, l) {
if (d->state == DEVICE_DEAD)
continue;
diff --git a/src/core/execute.c b/src/core/execute.c
index b6021397ce..8652e33923 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -995,7 +995,6 @@ static int get_fixed_group(const ExecContext *c, const char **group, gid_t *gid)
static int get_supplementary_groups(const ExecContext *c, const char *user,
const char *group, gid_t gid,
gid_t **supplementary_gids, int *ngids) {
- char **i;
int r, k = 0;
int ngroups_max;
bool keep_groups = false;
@@ -1187,7 +1186,6 @@ static int setup_pam(
pam_handle_t *handle = NULL;
sigset_t old_ss;
int pam_code = PAM_SUCCESS, r;
- char **nv;
bool close_session = false;
pid_t pam_pid = 0, parent_pid;
int flags = 0;
@@ -2005,7 +2003,6 @@ static int build_environment(
static int build_pass_environment(const ExecContext *c, char ***ret) {
_cleanup_strv_free_ char **pass_env = NULL;
size_t n_env = 0;
- char **i;
STRV_FOREACH(i, c->pass_environment) {
_cleanup_free_ char *x = NULL;
@@ -2281,7 +2278,6 @@ static bool exec_directory_is_private(const ExecContext *context, ExecDirectoryT
static int create_many_symlinks(const char *root, const char *source, char **symlinks) {
_cleanup_free_ char *src_abs = NULL;
- char **dst;
int r;
assert(source);
@@ -3352,7 +3348,6 @@ static int compile_symlinks(
for (ExecDirectoryType dt = 0; dt < _EXEC_DIRECTORY_TYPE_MAX; dt++) {
for (size_t i = 0; i < context->directories[dt].n_items; i++) {
_cleanup_free_ char *private_path = NULL, *path = NULL;
- char **symlink;
STRV_FOREACH(symlink, context->directories[dt].items[i].symlinks) {
_cleanup_free_ char *src_abs = NULL, *dst_abs = NULL;
@@ -5349,7 +5344,6 @@ int exec_context_destroy_runtime_directory(const ExecContext *c, const char *run
* service next. */
(void) rm_rf(p, REMOVE_ROOT);
- char **symlink;
STRV_FOREACH(symlink, c->directories[EXEC_DIRECTORY_RUNTIME].items[i].symlinks) {
_cleanup_free_ char *symlink_abs = NULL;
@@ -5423,12 +5417,9 @@ void exec_command_reset_status_array(ExecCommand *c, size_t n) {
}
void exec_command_reset_status_list_array(ExecCommand **c, size_t n) {
- for (size_t i = 0; i < n; i++) {
- ExecCommand *z;
-
+ for (size_t i = 0; i < n; i++)
LIST_FOREACH(command, z, c[i])
exec_status_reset(&z->exec_status);
- }
}
typedef struct InvalidEnvInfo {
@@ -5523,7 +5514,6 @@ static int exec_context_named_iofds(
static int exec_context_load_environment(const Unit *unit, const ExecContext *c, char ***ret) {
_cleanup_strv_free_ char **v = NULL;
- char **i;
int r;
assert(c);
@@ -5630,8 +5620,6 @@ bool exec_context_may_touch_console(const ExecContext *ec) {
}
static void strv_fprintf(FILE *f, char **l) {
- char **g;
-
assert(f);
STRV_FOREACH(g, l)
@@ -5651,7 +5639,6 @@ static void strv_dump(FILE* f, const char *prefix, const char *name, char **strv
}
void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
- char **e, **d;
int r;
assert(c);
@@ -5713,8 +5700,6 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
fprintf(f, "%sRootImage: %s\n", prefix, c->root_image);
if (c->root_image_options) {
- MountOptions *o;
-
fprintf(f, "%sRootImageOptions:", prefix);
LIST_FOREACH(mount_options, o, c->root_image_options)
if (!isempty(o->options))
@@ -6113,8 +6098,6 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
}
for (size_t i = 0; i < c->n_mount_images; i++) {
- MountOptions *o;
-
fprintf(f, "%sMountImages: %s%s:%s", prefix,
c->mount_images[i].ignore_enoent ? "-": "",
c->mount_images[i].source,
@@ -6127,8 +6110,6 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
}
for (size_t i = 0; i < c->n_extension_images; i++) {
- MountOptions *o;
-
fprintf(f, "%sExtensionImages: %s%s", prefix,
c->extension_images[i].ignore_enoent ? "-": "",
c->extension_images[i].source);
@@ -6280,7 +6261,6 @@ int exec_context_get_clean_directories(
return r;
}
- char **symlink;
STRV_FOREACH(symlink, c->directories[t].items[i].symlinks) {
j = path_join(prefix[t], *symlink);
if (!j)
@@ -6395,8 +6375,8 @@ void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix) {
prefix = strempty(prefix);
- LIST_FOREACH(command, c, c)
- exec_command_dump(c, f, prefix);
+ LIST_FOREACH(command, i, c)
+ exec_command_dump(i, f, prefix);
}
void exec_command_append_list(ExecCommand **l, ExecCommand *e) {
diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c
index 080a63bc7e..53d2a3daa1 100644
--- a/src/core/load-dropin.c
+++ b/src/core/load-dropin.c
@@ -13,7 +13,6 @@
static int process_deps(Unit *u, UnitDependency dependency, const char *dir_suffix) {
_cleanup_strv_free_ char **paths = NULL;
- char **p;
int r;
r = unit_file_find_dropin_paths(NULL,
@@ -85,7 +84,6 @@ static int process_deps(Unit *u, UnitDependency dependency, const char *dir_suff
int unit_load_dropin(Unit *u) {
_cleanup_strv_free_ char **l = NULL;
- char **f;
int r;
assert(u);
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 92a52819e2..e0dc47ecd8 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -1634,7 +1634,6 @@ int config_parse_root_image_options(
_cleanup_(mount_options_free_allp) MountOptions *options = NULL;
_cleanup_strv_free_ char **l = NULL;
- char **first = NULL, **second = NULL;
ExecContext *c = data;
const Unit *u = userdata;
int r;
@@ -4328,7 +4327,7 @@ int config_parse_io_limit(
void *userdata) {
_cleanup_free_ char *path = NULL, *resolved = NULL;
- CGroupIODeviceLimit *l = NULL, *t;
+ CGroupIODeviceLimit *l = NULL;
CGroupContext *c = data;
CGroupIOLimitType type;
const char *p = rvalue;
@@ -4343,8 +4342,8 @@ int config_parse_io_limit(
assert(type >= 0);
if (isempty(rvalue)) {
- LIST_FOREACH(device_limits, l, c->io_device_limits)
- l->limits[type] = cgroup_io_limit_defaults[type];
+ LIST_FOREACH(device_limits, t, c->io_device_limits)
+ t->limits[type] = cgroup_io_limit_defaults[type];
return 0;
}
@@ -4378,12 +4377,11 @@ int config_parse_io_limit(
}
}
- LIST_FOREACH(device_limits, t, c->io_device_limits) {
+ LIST_FOREACH(device_limits, t, c->io_device_limits)
if (path_equal(resolved, t->path)) {
l = t;
break;
}
- }
if (!l) {
CGroupIOLimitType ttype;
@@ -4486,7 +4484,7 @@ int config_parse_blockio_bandwidth(
void *userdata) {
_cleanup_free_ char *path = NULL, *resolved = NULL;
- CGroupBlockIODeviceBandwidth *b = NULL, *t;
+ CGroupBlockIODeviceBandwidth *b = NULL;
CGroupContext *c = data;
const char *p = rvalue;
uint64_t bytes;
@@ -4500,9 +4498,9 @@ int config_parse_blockio_bandwidth(
read = streq("BlockIOReadBandwidth", lvalue);
if (isempty(rvalue)) {
- LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) {
- b->rbps = CGROUP_LIMIT_MAX;
- b->wbps = CGROUP_LIMIT_MAX;
+ LIST_FOREACH(device_bandwidths, t, c->blockio_device_bandwidths) {
+ t->rbps = CGROUP_LIMIT_MAX;
+ t->wbps = CGROUP_LIMIT_MAX;
}
return 0;
}
@@ -4533,14 +4531,13 @@ int config_parse_blockio_bandwidth(
return 0;
}
- LIST_FOREACH(device_bandwidths, t, c->blockio_device_bandwidths) {
+ LIST_FOREACH(device_bandwidths, t, c->blockio_device_bandwidths)
if (path_equal(resolved, t->path)) {
b = t;
break;
}
- }
- if (!t) {
+ if (!b) {
b = new0(CGroupBlockIODeviceBandwidth, 1);
if (!b)
return log_oom();
diff --git a/src/core/main.c b/src/core/main.c
index be403dee79..289a1ee01f 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -2319,7 +2319,6 @@ static void fallback_rlimit_memlock(const struct rlimit *saved_rlimit_memlock) {
}
static void setenv_manager_environment(void) {
- char **p;
int r;
STRV_FOREACH(p, arg_manager_environment) {
diff --git a/src/core/manager.c b/src/core/manager.c
index a4ff2c8355..a379bbefea 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1215,7 +1215,6 @@ static void unit_gc_sweep(Unit *u, unsigned gc_marker) {
is_bad = false;
}
- const UnitRef *ref;
LIST_FOREACH(refs_by_target, ref, u->refs_by_target) {
unit_gc_sweep(ref->source, gc_marker);
@@ -3626,7 +3625,6 @@ void manager_check_finished(Manager *m) {
}
static bool generator_path_any(const char* const* paths) {
- char **path;
bool found = false;
/* Optimize by skipping the whole process by not creating output directories
diff --git a/src/core/mount.c b/src/core/mount.c
index c650b5abe2..329abfdaa8 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1957,7 +1957,6 @@ static int drain_libmount(Manager *m) {
static int mount_process_proc_self_mountinfo(Manager *m) {
_cleanup_set_free_free_ Set *around = NULL, *gone = NULL;
const char *what;
- Unit *u;
int r;
assert(m);
diff --git a/src/core/namespace.c b/src/core/namespace.c
index e6293882fe..2d5bedbbcd 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -314,8 +314,6 @@ static void mount_entry_done(MountEntry *p) {
}
static int append_access_mounts(MountEntry **p, char **strv, MountMode mode, bool forcibly_require_prefix) {
- char **i;
-
assert(p);
/* Adds a list of user-supplied READWRITE/READWRITE_IMPLICIT/READONLY/INACCESSIBLE entries */
@@ -350,8 +348,6 @@ static int append_access_mounts(MountEntry **p, char **strv, MountMode mode, boo
}
static int append_empty_dir_mounts(MountEntry **p, char **strv) {
- char **i;
-
assert(p);
/* Adds tmpfs mounts to provide readable but empty directories. This is primarily used to implement the
@@ -419,7 +415,6 @@ static int append_extensions(
char **extension_directories) {
_cleanup_strv_free_ char **overlays = NULL;
- char **hierarchy, **extension_directory;
int r;
if (n == 0 && strv_isempty(extension_directories))
@@ -1709,7 +1704,6 @@ static void drop_unused_mounts(const char *root_directory, MountEntry *mounts, s
}
static int create_symlinks_from_tuples(const char *root, char **strv_symlinks) {
- char **src, **dst;
int r;
STRV_FOREACH_PAIR(src, dst, strv_symlinks) {
@@ -2562,7 +2556,6 @@ MountImage* mount_image_free_many(MountImage *m, size_t *n) {
int mount_image_add(MountImage **m, size_t *n, const MountImage *item) {
_cleanup_free_ char *s = NULL, *d = NULL;
_cleanup_(mount_options_free_allp) MountOptions *options = NULL;
- MountOptions *i;
MountImage *c;
assert(m);
diff --git a/src/core/path.c b/src/core/path.c
index 0b736f00bf..d9b136f10c 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -292,7 +292,6 @@ static void path_done(Unit *u) {
}
static int path_add_mount_dependencies(Path *p) {
- PathSpec *s;
int r;
assert(p);
@@ -401,7 +400,6 @@ static int path_load(Unit *u) {
static void path_dump(Unit *u, FILE *f, const char *prefix) {
Path *p = PATH(u);
Unit *trigger;
- PathSpec *s;
assert(p);
assert(f);
@@ -429,8 +427,6 @@ static void path_dump(Unit *u, FILE *f, const char *prefix) {
}
static void path_unwatch(Path *p) {
- PathSpec *s;
-
assert(p);
LIST_FOREACH(spec, s, p->specs)
@@ -439,7 +435,6 @@ static void path_unwatch(Path *p) {
static int path_watch(Path *p) {
int r;
- PathSpec *s;
assert(p);
@@ -539,8 +534,6 @@ fail:
}
static bool path_check_good(Path *p, bool initial, bool from_trigger_notify) {
- PathSpec *s;
-
assert(p);
LIST_FOREACH(spec, s, p->specs)
@@ -591,8 +584,6 @@ fail:
}
static void path_mkdir(Path *p) {
- PathSpec *s;
-
assert(p);
if (!p->make_directory)
@@ -637,7 +628,6 @@ static int path_stop(Unit *u) {
static int path_serialize(Unit *u, FILE *f, FDSet *fds) {
Path *p = PATH(u);
- PathSpec *s;
assert(u);
assert(f);
@@ -700,7 +690,6 @@ static int path_deserialize_item(Unit *u, const char *key, const char *value, FD
_cleanup_free_ char *unescaped = NULL;
ssize_t l;
PathType type;
- PathSpec *s;
type = path_type_from_string(type_str);
if (type < 0) {
@@ -742,7 +731,7 @@ _pure_ static const char *path_sub_state_to_string(Unit *u) {
}
static int path_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
- PathSpec *s = userdata;
+ PathSpec *s = userdata, *found = NULL;
Path *p;
int changed;
@@ -755,18 +744,18 @@ static int path_dispatch_io(sd_event_source *source, int fd, uint32_t revents, v
if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING))
return 0;
- /* log_debug("inotify wakeup on %s.", UNIT(p)->id); */
-
- LIST_FOREACH(spec, s, p->specs)
- if (path_spec_owns_inotify_fd(s, fd))
+ LIST_FOREACH(spec, i, p->specs)
+ if (path_spec_owns_inotify_fd(i, fd)) {
+ found = i;
break;
+ }
- if (!s) {
+ if (!found) {
log_error("Got event on unknown fd.");
goto fail;
}
- changed = path_spec_fd_event(s, revents);
+ changed = path_spec_fd_event(found, revents);
if (changed < 0)
goto fail;
diff --git a/src/core/service.c b/src/core/service.c
index 92485875f7..396c27956c 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -434,8 +434,8 @@ static int service_add_fd_store(Service *s, int fd, const char *name, bool do_po
* Use this errno rather than E[NM]FILE to distinguish from
* the case where systemd itself hits the file limit. */
- LIST_FOREACH(fd_store, fs, s->fd_store) {
- r = same_fd(fs->fd, fd);
+ LIST_FOREACH(fd_store, i, s->fd_store) {
+ r = same_fd(i->fd, fd);
if (r < 0)
return r;
if (r > 0) {
@@ -504,12 +504,10 @@ static int service_add_fd_store_set(Service *s, FDSet *fds, const char *name, bo
}
static void service_remove_fd_store(Service *s, const char *name) {
- ServiceFDStore *fs, *n;
-
assert(s);
assert(name);
- LIST_FOREACH_SAFE(fd_store, fs, n, s->fd_store) {
+ LIST_FOREACH(fd_store, fs, s->fd_store) {
if (!streq(fs->fdname, name))
continue;
@@ -567,9 +565,7 @@ static int service_verify(Service *s) {
assert(s);
assert(UNIT(s)->load_state == UNIT_LOADED);
- for (ServiceExecCommand c = 0; c < _SERVICE_EXEC_COMMAND_MAX; c++) {
- ExecCommand *command;
-
+ for (ServiceExecCommand c = 0; c < _SERVICE_EXEC_COMMAND_MAX; c++)
LIST_FOREACH(command, command, s->exec_command[c]) {
if (!path_is_absolute(command->path) && !filename_is_valid(command->path))
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC),
@@ -581,7 +577,6 @@ static int service_verify(Service *s) {
"Service has an empty argv in %s=. Refusing.",
service_exec_command_to_string(c));
}
- }
if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP] &&
UNIT(s)->success_action == EMERGENCY_ACTION_NONE)
@@ -1334,7 +1329,6 @@ static int service_collect_fds(
}
if (s->n_fd_store > 0) {
- ServiceFDStore *fs;
size_t n_fds;
char **nl;
int *t;
@@ -2656,7 +2650,6 @@ static int service_serialize_exec_command(Unit *u, FILE *f, ExecCommand *command
ServiceExecCommand id;
size_t length = 0;
unsigned idx;
- char **arg;
assert(s);
assert(f);
@@ -2712,7 +2705,6 @@ static int service_serialize_exec_command(Unit *u, FILE *f, ExecCommand *command
static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
Service *s = SERVICE(u);
- ServiceFDStore *fs;
int r;
assert(u);
@@ -4092,7 +4084,6 @@ static void service_notify_message(
Service *s = SERVICE(u);
bool notify_dbus = false;
const char *e;
- char * const *i;
int r;
assert(u);
diff --git a/src/core/socket.c b/src/core/socket.c
index 8a5c7fdd0a..802c6afde6 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -208,8 +208,6 @@ static int socket_arm_timer(Socket *s, usec_t usec) {
}
static bool have_non_accept_socket(Socket *s) {
- SocketPort *p;
-
assert(s);
if (!s->accept)
@@ -228,7 +226,6 @@ static bool have_non_accept_socket(Socket *s) {
}
static int socket_add_mount_dependencies(Socket *s) {
- SocketPort *p;
int r;
assert(s);
@@ -368,7 +365,6 @@ static int socket_add_extras(Socket *s) {
static const char *socket_find_symlink_target(Socket *s) {
const char *found = NULL;
- SocketPort *p;
LIST_FOREACH(port, p, s->ports) {
const char *f = NULL;
@@ -565,7 +561,6 @@ _const_ static const char* listen_lookup(int family, int type) {
static void socket_dump(Unit *u, FILE *f, const char *prefix) {
Socket *s = SOCKET(u);
- SocketPort *p;
const char *prefix2, *str;
assert(s);
@@ -781,8 +776,6 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
fprintf(f, "%sSocketProtocol: %s\n", prefix, str);
if (!strv_isempty(s->symlinks)) {
- char **q;
-
fprintf(f, "%sSymlinks:", prefix);
STRV_FOREACH(q, s->symlinks)
fprintf(f, " %s", *q);
@@ -923,9 +916,6 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) {
}
static void socket_close_fds(Socket *s) {
- SocketPort *p;
- char **i;
-
assert(s);
LIST_FOREACH(port, p, s->ports) {
@@ -1271,7 +1261,6 @@ static int mq_address_create(
static int socket_symlink(Socket *s) {
const char *p;
- char **i;
int r;
assert(s);
@@ -1624,7 +1613,6 @@ static int socket_open_fds(Socket *orig_s) {
_cleanup_(socket_close_fdsp) Socket *s = orig_s;
_cleanup_(mac_selinux_freep) char *label = NULL;
bool know_label = false;
- SocketPort *p;
int r;
assert(s);
@@ -1734,7 +1722,6 @@ static int socket_open_fds(Socket *orig_s) {
}
static void socket_unwatch_fds(Socket *s) {
- SocketPort *p;
int r;
assert(s);
@@ -1753,7 +1740,6 @@ static void socket_unwatch_fds(Socket *s) {
}
static int socket_watch_fds(Socket *s) {
- SocketPort *p;
int r;
assert(s);
@@ -1791,7 +1777,6 @@ enum {
static int socket_check_open(Socket *s) {
bool have_open = false, have_closed = false;
- SocketPort *p;
assert(s);
@@ -1995,7 +1980,6 @@ static int socket_chown(Socket *s, pid_t *_pid) {
if (r == 0) {
uid_t uid = UID_INVALID;
gid_t gid = GID_INVALID;
- SocketPort *p;
/* Child */
@@ -2294,7 +2278,7 @@ fail:
}
static void flush_ports(Socket *s) {
- SocketPort *p;
+ assert(s);
/* Flush all incoming traffic, regardless if actual bytes or new connections, so that this socket isn't busy
* anymore */
@@ -2563,7 +2547,6 @@ static int socket_stop(Unit *u) {
static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
Socket *s = SOCKET(u);
- SocketPort *p;
int r;
assert(u);
@@ -2674,7 +2657,6 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
}
} else if (streq(key, "fifo")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse fifo value: %s", value);
@@ -2695,7 +2677,6 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
} else if (streq(key, "special")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse special value: %s", value);
@@ -2716,7 +2697,6 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
} else if (streq(key, "mqueue")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse mqueue value: %s", value);
@@ -2737,7 +2717,6 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
} else if (streq(key, "socket")) {
int fd, type, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %i %n", &fd, &type, &skip) < 2 || fd < 0 || type < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse socket value: %s", value);
@@ -2758,7 +2737,6 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
} else if (streq(key, "netlink")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse socket value: %s", value);
@@ -2778,7 +2756,6 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
} else if (streq(key, "ffs")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse ffs value: %s", value);
@@ -2805,7 +2782,6 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
static void socket_distribute_fds(Unit *u, FDSet *fds) {
Socket *s = SOCKET(u);
- SocketPort *p;
assert(u);
@@ -3227,7 +3203,6 @@ static int socket_dispatch_timer(sd_event_source *source, usec_t usec, void *use
int socket_collect_fds(Socket *s, int **fds) {
size_t k = 0, n = 0;
- SocketPort *p;
int *rfds;
assert(s);
diff --git a/src/core/swap.c b/src/core/swap.c
index 9c0d4fb227..0de73970ad 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -537,7 +537,6 @@ static void swap_process_new(Manager *m, const char *device, int prio, bool set_
static void swap_set_state(Swap *s, SwapState state) {
SwapState old_state;
- Swap *other;
assert(s);
@@ -745,8 +744,6 @@ static void swap_enter_dead_or_active(Swap *s, SwapResult f) {
assert(s);
if (s->from_proc_swaps) {
- Swap *other;
-
swap_enter_active(s, f);
LIST_FOREACH_OTHERS(same_devnode, other, s)
@@ -902,7 +899,7 @@ static void swap_cycle_clear(Swap *s) {
}
static int swap_start(Unit *u) {
- Swap *s = SWAP(u), *other;
+ Swap *s = SWAP(u);
int r;
assert(s);
@@ -1207,7 +1204,6 @@ static int swap_load_proc_swaps(Manager *m, bool set_flags) {
}
static int swap_process_proc_swaps(Manager *m) {
- Unit *u;
int r;
assert(m);
@@ -1300,7 +1296,7 @@ static int swap_dispatch_io(sd_event_source *source, int fd, uint32_t revents, v
static Unit *swap_following(Unit *u) {
Swap *s = SWAP(u);
- Swap *other, *first = NULL;
+ Swap *first = NULL;
assert(s);
@@ -1336,7 +1332,7 @@ static Unit *swap_following(Unit *u) {
}
static int swap_following_set(Unit *u, Set **_set) {
- Swap *s = SWAP(u), *other;
+ Swap *s = SWAP(u);
_cleanup_set_free_ Set *set = NULL;
int r;
diff --git a/src/core/timer.c b/src/core/timer.c
index a13b864741..69a4ea652a 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -83,7 +83,6 @@ static int timer_verify(Timer *t) {
static int timer_add_default_dependencies(Timer *t) {
int r;
- TimerValue *v;
assert(t);
@@ -236,7 +235,6 @@ static int timer_load(Unit *u) {
static void timer_dump(Unit *u, FILE *f, const char *prefix) {
Timer *t = TIMER(u);
Unit *trigger;
- TimerValue *v;
trigger = UNIT_TRIGGER(u);
@@ -375,7 +373,6 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
bool found_monotonic = false, found_realtime = false;
bool leave_around = false;
triple_timestamp ts;
- TimerValue *v;
Unit *trigger;
int r;
@@ -617,7 +614,6 @@ fail:
static int timer_start(Unit *u) {
Timer *t = TIMER(u);
- TimerValue *v;
int r;
assert(t);
@@ -756,7 +752,6 @@ static int timer_dispatch(sd_event_source *s, uint64_t usec, void *userdata) {
static void timer_trigger_notify(Unit *u, Unit *other) {
Timer *t = TIMER(u);
- TimerValue *v;
assert(u);
assert(other);
diff --git a/src/core/transaction.c b/src/core/transaction.c
index ebe5f1910d..7bb8dfb0f4 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -46,7 +46,7 @@ void transaction_abort(Transaction *tr) {
}
static void transaction_find_jobs_that_matter_to_anchor(Job *j, unsigned generation) {
- JobDependency *l;
+ assert(j);
/* A recursive sweep through the graph that marks all units
* that matter to the anchor job, i.e. are directly or
@@ -71,7 +71,7 @@ static void transaction_find_jobs_that_matter_to_anchor(Job *j, unsigned generat
}
static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other, JobType t) {
- JobDependency *l, *last;
+ JobDependency *last;
assert(j);
assert(other);
@@ -124,8 +124,6 @@ static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other
}
_pure_ static bool job_is_conflicted_by(Job *j) {
- JobDependency *l;
-
assert(j);
/* Returns true if this job is pulled in by a least one
@@ -138,10 +136,8 @@ _pure_ static bool job_is_conflicted_by(Job *j) {
return false;
}
-static int delete_one_unmergeable_job(Transaction *tr, Job *j) {
- Job *k;
-
- assert(j);
+static int delete_one_unmergeable_job(Transaction *tr, Job *job) {
+ assert(job);
/* Tries to delete one item in the linked list
* j->transaction_next->transaction_next->... that conflicts
@@ -150,7 +146,7 @@ static int delete_one_unmergeable_job(Transaction *tr, Job *j) {
/* We rely here on the fact that if a merged with b does not
* merge with c, either a or b merge with c neither */
- LIST_FOREACH(transaction, j, j)
+ LIST_FOREACH(transaction, j, job)
LIST_FOREACH(transaction, k, j->transaction_next) {
Job *d;
@@ -226,7 +222,6 @@ static int transaction_merge_jobs(Transaction *tr, sd_bus_error *e) {
* task conflict. If so, try to drop one of them. */
HASHMAP_FOREACH(j, tr->jobs) {
JobType t;
- Job *k;
t = j->type;
LIST_FOREACH(transaction, k, j->transaction_next) {
@@ -257,12 +252,12 @@ static int transaction_merge_jobs(Transaction *tr, sd_bus_error *e) {
/* Second step, merge the jobs. */
HASHMAP_FOREACH(j, tr->jobs) {
JobType t = j->type;
- Job *k;
/* Merge all transaction jobs for j->unit */
LIST_FOREACH(transaction, k, j->transaction_next)
assert_se(job_type_merge_and_collapse(&t, k->type, j->unit) == 0);
+ Job *k;
while ((k = j->transaction_next)) {
if (tr->anchor_job == k) {
transaction_merge_and_delete_job(tr, k, j, t);
@@ -293,7 +288,6 @@ static void transaction_drop_redundant(Transaction *tr) {
HASHMAP_FOREACH(j, tr->jobs) {
bool keep = false;
- Job *k;
LIST_FOREACH(transaction, k, j)
if (tr->anchor_job == k ||
@@ -314,14 +308,15 @@ static void transaction_drop_redundant(Transaction *tr) {
} while (again);
}
-_pure_ static bool unit_matters_to_anchor(Unit *u, Job *j) {
+_pure_ static bool unit_matters_to_anchor(Unit *u, Job *job) {
assert(u);
- assert(!j->transaction_prev);
+ assert(job);
+ assert(!job->transaction_prev);
/* Checks whether at least one of the jobs for this unit
* matters to the anchor. */
- LIST_FOREACH(transaction, j, j)
+ LIST_FOREACH(transaction, j, job)
if (j->matters_to_anchor)
return true;
@@ -329,7 +324,7 @@ _pure_ static bool unit_matters_to_anchor(Unit *u, Job *j) {
}
static char* merge_unit_ids(const char* unit_log_field, char **pairs) {
- char **unit_id, **job_type, *ans = NULL;
+ char *ans = NULL;
size_t size = 0, next;
STRV_FOREACH_PAIR(unit_id, job_type, pairs) {
@@ -366,7 +361,6 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
if (j->generation == generation) {
Job *k, *delete = NULL;
_cleanup_free_ char **array = NULL, *unit_ids = NULL;
- char **unit_id, **job_type;
/* If the marker is NULL we have been here already and decided the job was loop-free from
* here. Hence shortcut things and return right-away. */
@@ -558,7 +552,7 @@ static int transaction_is_destructive(Transaction *tr, JobMode mode, sd_bus_erro
}
static void transaction_minimize_impact(Transaction *tr) {
- Job *j;
+ Job *head;
assert(tr);
@@ -566,8 +560,8 @@ static void transaction_minimize_impact(Transaction *tr) {
* or that stop a running service. */
rescan:
- HASHMAP_FOREACH(j, tr->jobs) {
- LIST_FOREACH(transaction, j, j) {
+ HASHMAP_FOREACH(head, tr->jobs) {
+ LIST_FOREACH(transaction, j, head) {
bool stops_running_service, changes_existing_job;
/* If it matters, we shouldn't drop it */
@@ -804,13 +798,13 @@ static Job* transaction_add_one_job(Transaction *tr, JobType type, Unit *unit, b
f = hashmap_get(tr->jobs, unit);
- LIST_FOREACH(transaction, j, f) {
- assert(j->unit == unit);
+ LIST_FOREACH(transaction, i, f) {
+ assert(i->unit == unit);
- if (j->type == type) {
+ if (i->type == type) {
if (is_new)
*is_new = false;
- return j;
+ return i;
}
}
diff --git a/src/core/unit-serialize.c b/src/core/unit-serialize.c
index 7d2e6bc130..65ed110ce6 100644
--- a/src/core/unit-serialize.c
+++ b/src/core/unit-serialize.c
@@ -623,7 +623,7 @@ static void print_unit_dependency_mask(FILE *f, const char *kind, UnitDependency
}
void unit_dump(Unit *u, FILE *f, const char *prefix) {
- char *t, **j;
+ char *t;
const char *prefix2;
Unit *following;
_cleanup_set_free_ Set *following_set = NULL;
diff --git a/src/core/unit.c b/src/core/unit.c
index bd11049c77..69ece07447 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -583,8 +583,6 @@ static void unit_clear_dependencies(Unit *u) {
}
static void unit_remove_transient(Unit *u) {
- char **i;
-
assert(u);
if (!u->transient)
@@ -3620,7 +3618,6 @@ int unit_add_blockdev_dependency(Unit *u, const char *what, UnitDependencyMask m
int unit_coldplug(Unit *u) {
int r = 0, q;
- char **i;
assert(u);
@@ -3693,7 +3690,6 @@ static bool fragment_mtime_newer(const char *path, usec_t mtime, bool path_maske
bool unit_need_daemon_reload(Unit *u) {
_cleanup_strv_free_ char **t = NULL;
- char **path;
assert(u);
@@ -4278,7 +4274,6 @@ char* unit_escape_setting(const char *s, UnitWriteFlags flags, char **buf) {
char* unit_concat_strv(char **l, UnitWriteFlags flags) {
_cleanup_free_ char *result = NULL;
size_t n = 0;
- char **i;
/* Takes a list of strings, escapes them, and concatenates them. This may be used to format command lines in a
* way suitable for ExecStart= stanzas */
@@ -5079,7 +5074,6 @@ int unit_fork_and_watch_rm_rf(Unit *u, char **paths, pid_t *ret_pid) {
return r;
if (r == 0) {
int ret = EXIT_SUCCESS;
- char **i;
STRV_FOREACH(i, paths) {
r = rm_rf(*i, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_MISSING_OK);
@@ -5869,7 +5863,7 @@ int unit_thaw_vtable_common(Unit *u) {
}
Condition *unit_find_failed_condition(Unit *u) {
- Condition *c, *failed_trigger = NULL;
+ Condition *failed_trigger = NULL;
bool has_succeeded_trigger = false;
if (u->condition_result)
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index 2904de3728..7235544285 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -91,7 +91,6 @@ static int add_match(sd_journal *j, const char *match) {
}
static int add_matches(sd_journal *j, char **matches) {
- char **match;
int r;
r = sd_journal_add_match(j, "MESSAGE_ID=" SD_MESSAGE_COREDUMP_STR, 0);
diff --git a/src/creds/creds.c b/src/creds/creds.c
index 3d2841c07d..2fd314ff37 100644
--- a/src/creds/creds.c
+++ b/src/creds/creds.c
@@ -311,7 +311,6 @@ static int write_blob(FILE *f, const void *data, size_t size) {
static int verb_cat(int argc, char **argv, void *userdata) {
_cleanup_(closedirp) DIR *d = NULL;
int r, ret = 0;
- char **cn;
r = open_credential_directory(&d);
if (r == -ENXIO)
diff --git a/src/cryptenroll/cryptenroll.c b/src/cryptenroll/cryptenroll.c
index 2fd6d9080e..2e11ffe291 100644
--- a/src/cryptenroll/cryptenroll.c
+++ b/src/cryptenroll/cryptenroll.c
@@ -489,7 +489,6 @@ static int prepare_luks(
for (;;) {
_cleanup_strv_free_erase_ char **passwords = NULL;
- char **p;
if (--i == 0)
return log_error_errno(SYNTHETIC_ERRNO(ENOKEY),
diff --git a/src/cryptsetup/cryptsetup-keyfile.c b/src/cryptsetup/cryptsetup-keyfile.c
index 924555d262..1867e9012c 100644
--- a/src/cryptsetup/cryptsetup-keyfile.c
+++ b/src/cryptsetup/cryptsetup-keyfile.c
@@ -12,7 +12,6 @@ int find_key_file(
void **ret_key,
size_t *ret_key_size) {
- char **i;
int r;
assert(key_file);
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index f2b0269fc5..f92624fb13 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -573,7 +573,7 @@ static int get_password(
_cleanup_free_ char *friendly = NULL, *text = NULL, *disk_path = NULL;
_cleanup_strv_free_erase_ char **passwords = NULL;
- char **p, *id;
+ char *id;
int r = 0;
AskPasswordFlags flags = arg_ask_password_flags | ASK_PASSWORD_PUSH_CACHE;
@@ -861,7 +861,6 @@ static int attach_luks2_by_fido2(
#if HAVE_LIBCRYPTSETUP_PLUGINS
AskPasswordFlags flags = ASK_PASSWORD_PUSH_CACHE | ASK_PASSWORD_ACCEPT_CACHED;
_cleanup_strv_free_erase_ char **pins = NULL;
- char **p;
int r;
r = crypt_activate_by_token_pin(cd, name, "systemd-fido2", CRYPT_ANY_TOKEN, NULL, 0, usrptr, activation_flags);
@@ -1547,7 +1546,6 @@ static int attach_luks_or_plain_or_bitlk_by_passphrase(
uint32_t flags,
bool pass_volume_key) {
- char **p;
int r;
assert(cd);
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index a724ae510d..e2e1df5715 100644
--- a/src/debug-generator/debug-generator.c
+++ b/src/debug-generator/debug-generator.c
@@ -89,7 +89,6 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
}
static int generate_mask_symlinks(void) {
- char **u;
int r = 0;
if (strv_isempty(arg_mask))
@@ -112,7 +111,6 @@ static int generate_mask_symlinks(void) {
}
static int generate_wants_symlinks(void) {
- char **u;
int r = 0;
if (strv_isempty(arg_wants))
diff --git a/src/delta/delta.c b/src/delta/delta.c
index e14ad36d03..aa5a546bce 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -195,7 +195,6 @@ static int enumerate_dir_d(
_cleanup_free_ char *unit = NULL;
_cleanup_free_ char *path = NULL;
_cleanup_strv_free_ char **list = NULL;
- char **file;
char *c;
int r;
@@ -292,7 +291,6 @@ static int enumerate_dir(
_cleanup_closedir_ DIR *d = NULL;
_cleanup_strv_free_ char **files = NULL, **dirs = NULL;
size_t n_files = 0, n_dirs = 0;
- char **t;
int r;
assert(top);
diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c
index a9632a3f16..1d78dc5085 100644
--- a/src/dissect/dissect.c
+++ b/src/dissect/dissect.c
@@ -354,7 +354,6 @@ static int parse_argv(int argc, char *argv[]) {
static int strv_pair_to_json(char **l, JsonVariant **ret) {
_cleanup_strv_free_ char **jl = NULL;
- char **a, **b;
STRV_FOREACH_PAIR(a, b, l) {
char *j;
@@ -371,8 +370,6 @@ static int strv_pair_to_json(char **l, JsonVariant **ret) {
}
static void strv_pair_print(char **l, const char *prefix) {
- char **p, **q;
-
assert(prefix);
STRV_FOREACH_PAIR(p, q, l) {
diff --git a/src/environment-d-generator/environment-d-generator.c b/src/environment-d-generator/environment-d-generator.c
index 1171fdc290..39c46c7c2b 100644
--- a/src/environment-d-generator/environment-d-generator.c
+++ b/src/environment-d-generator/environment-d-generator.c
@@ -41,7 +41,6 @@ static int environment_dirs(char ***ret) {
static int load_and_print(void) {
_cleanup_strv_free_ char **dirs = NULL, **files = NULL, **env = NULL;
- char **i;
int r;
r = environment_dirs(&dirs);
diff --git a/src/escape/escape.c b/src/escape/escape.c
index 676b7dce54..0ad77f3f94 100644
--- a/src/escape/escape.c
+++ b/src/escape/escape.c
@@ -155,7 +155,6 @@ static int parse_argv(int argc, char *argv[]) {
}
static int run(int argc, char *argv[]) {
- char **i;
int r;
log_setup();
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index ca9b045e85..75523d0c07 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -237,7 +237,6 @@ static int write_dependency(
_cleanup_strv_free_ char **names = NULL, **units = NULL;
_cleanup_free_ char *res = NULL;
- char **s;
int r;
assert(f);
@@ -518,8 +517,6 @@ static int add_mount(
if (r < 0)
return r;
} else {
- char **s;
-
STRV_FOREACH(s, wanted_by) {
r = generator_add_symlink(dest, *s, "wants", name);
if (r < 0)
diff --git a/src/home/homectl.c b/src/home/homectl.c
index 3c179ca4ae..671d5f5130 100644
--- a/src/home/homectl.c
+++ b/src/home/homectl.c
@@ -557,7 +557,6 @@ static int acquire_passed_secrets(const char *user_name, UserRecord **ret) {
static int activate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
@@ -606,7 +605,6 @@ static int activate_home(int argc, char *argv[], void *userdata) {
static int deactivate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
@@ -693,7 +691,7 @@ static int inspect_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(strv_freep) char **mangled_list = NULL;
int r, ret = 0;
- char **items, **i;
+ char **items;
pager_open(arg_pager_flags);
@@ -777,7 +775,7 @@ static int authenticate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(strv_freep) char **mangled_list = NULL;
int r, ret = 0;
- char **i, **items;
+ char **items;
items = mangle_user_list(strv_skip(argv, 1), &mangled_list);
if (!items)
@@ -1087,7 +1085,6 @@ static int add_disposition(JsonVariant **v) {
static int acquire_new_home_record(UserRecord **ret) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
- char **i;
int r;
assert(ret);
@@ -1370,7 +1367,6 @@ static int create_home(int argc, char *argv[], void *userdata) {
static int remove_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
@@ -1408,7 +1404,6 @@ static int acquire_updated_home_record(
_cleanup_(json_variant_unrefp) JsonVariant *json = NULL;
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
- char **i;
int r;
assert(ret);
@@ -1858,7 +1853,6 @@ static int resize_home(int argc, char *argv[], void *userdata) {
static int lock_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
@@ -1890,7 +1884,6 @@ static int lock_home(int argc, char *argv[], void *userdata) {
static int unlock_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
diff --git a/src/home/homed-manager-bus.c b/src/home/homed-manager-bus.c
index 47eb287aa9..ba5ca42ed3 100644
--- a/src/home/homed-manager-bus.c
+++ b/src/home/homed-manager-bus.c
@@ -39,7 +39,6 @@ static int property_get_auto_login(
HASHMAP_FOREACH(h, m->homes_by_name) {
_cleanup_(strv_freep) char **seats = NULL;
_cleanup_free_ char *home_path = NULL;
- char **s;
r = home_auto_login(h, &seats);
if (r < 0) {
diff --git a/src/home/homed-manager.c b/src/home/homed-manager.c
index dc1bb070dc..9ed1348592 100644
--- a/src/home/homed-manager.c
+++ b/src/home/homed-manager.c
@@ -1551,7 +1551,6 @@ static int manager_load_public_key_one(Manager *m, const char *path) {
static int manager_load_public_keys(Manager *m) {
_cleanup_strv_free_ char **files = NULL;
- char **i;
int r;
assert(m);
diff --git a/src/home/homed-varlink.c b/src/home/homed-varlink.c
index 96a6ea754e..3dd5a14802 100644
--- a/src/home/homed-varlink.c
+++ b/src/home/homed-varlink.c
@@ -282,7 +282,6 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet
if (p.user_name) {
const char *last = NULL;
- char **i;
h = hashmap_get(m->homes_by_name, p.user_name);
if (!h)
@@ -335,9 +334,7 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet
} else {
const char *last_user_name = NULL, *last_group_name = NULL;
- HASHMAP_FOREACH(h, m->homes_by_name) {
- char **j;
-
+ HASHMAP_FOREACH(h, m->homes_by_name)
STRV_FOREACH(j, h->record->member_of) {
if (last_user_name) {
@@ -353,7 +350,6 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet
last_user_name = h->user_name;
last_group_name = *j;
}
- }
if (last_user_name) {
assert(last_group_name);
diff --git a/src/home/homework-cifs.c b/src/home/homework-cifs.c
index ed06d1f221..6d499f76b2 100644
--- a/src/home/homework-cifs.c
+++ b/src/home/homework-cifs.c
@@ -20,7 +20,6 @@ int home_setup_cifs(
HomeSetup *setup) {
_cleanup_free_ char *chost = NULL, *cservice = NULL, *cdir = NULL, *chost_and_service = NULL, *j = NULL;
- char **pw;
int r;
assert(h);
diff --git a/src/home/homework-fscrypt.c b/src/home/homework-fscrypt.c
index f9fef73f75..afa706a1bf 100644
--- a/src/home/homework-fscrypt.c
+++ b/src/home/homework-fscrypt.c
@@ -197,7 +197,6 @@ static int fscrypt_slot_try_many(
const uint8_t match_key_descriptor[static FS_KEY_DESCRIPTOR_SIZE],
void **ret_decrypted, size_t *ret_decrypted_size) {
- char **i;
int r;
STRV_FOREACH(i, passwords) {
@@ -499,7 +498,6 @@ int home_create_fscrypt(
_cleanup_free_ char *d = NULL;
uint32_t nr = 0;
const char *ip;
- char **i;
int r;
assert(h);
@@ -649,7 +647,6 @@ int home_passwd_fscrypt(
size_t volume_key_size = 0;
uint32_t slot = 0;
const char *xa;
- char **p;
int r;
assert(h);
diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c
index 38164fadc3..8b3341c643 100644
--- a/src/home/homework-luks.c
+++ b/src/home/homework-luks.c
@@ -304,7 +304,6 @@ static int luks_try_passwords(
size_t *volume_key_size,
key_serial_t *ret_key_serial) {
- char **pp;
int r;
assert(h);
@@ -1718,7 +1717,6 @@ static int luks_format(
_cleanup_free_ char *text = NULL;
size_t volume_key_size;
int slot = 0, r;
- char **pp;
assert(node);
assert(dm_name);
@@ -3659,7 +3657,6 @@ static int luks_try_resume(
const char *dm_name,
char **password) {
- char **pp;
int r;
assert(cd);
diff --git a/src/home/homework-pkcs11.c b/src/home/homework-pkcs11.c
index 15402b1002..7868fb6064 100644
--- a/src/home/homework-pkcs11.c
+++ b/src/home/homework-pkcs11.c
@@ -20,7 +20,6 @@ int pkcs11_callback(
CK_TOKEN_INFO updated_token_info;
size_t decrypted_key_size;
CK_OBJECT_HANDLE object;
- char **i;
CK_RV rv;
int r;
diff --git a/src/home/homework.c b/src/home/homework.c
index 9fdc74b775..0014a7f598 100644
--- a/src/home/homework.c
+++ b/src/home/homework.c
@@ -97,9 +97,7 @@ int user_record_authenticate(
log_info("None of the supplied plaintext passwords unlock the user record's hashed recovery keys.");
/* Second, test cached PKCS#11 passwords */
- for (size_t n = 0; n < h->n_pkcs11_encrypted_key; n++) {
- char **pp;
-
+ for (size_t n = 0; n < h->n_pkcs11_encrypted_key; n++)
STRV_FOREACH(pp, cache->pkcs11_passwords) {
r = test_password_one(h->pkcs11_encrypted_key[n].hashed_password, *pp);
if (r < 0)
@@ -109,12 +107,9 @@ int user_record_authenticate(
return 1;
}
}
- }
/* Third, test cached FIDO2 passwords */
- for (size_t n = 0; n < h->n_fido2_hmac_salt; n++) {
- char **pp;
-
+ for (size_t n = 0; n < h->n_fido2_hmac_salt; n++)
/* See if any of the previously calculated passwords work */
STRV_FOREACH(pp, cache->fido2_passwords) {
r = test_password_one(h->fido2_hmac_salt[n].hashed_password, *pp);
@@ -125,7 +120,6 @@ int user_record_authenticate(
return 1;
}
}
- }
/* Fourth, let's see if any of the PKCS#11 security tokens are plugged in and help us */
for (size_t n = 0; n < h->n_pkcs11_encrypted_key; n++) {
@@ -1096,7 +1090,6 @@ static int user_record_compile_effective_passwords(
_cleanup_(strv_free_erasep) char **effective = NULL;
size_t n;
- char **i;
int r;
assert(h);
@@ -1116,7 +1109,6 @@ static int user_record_compile_effective_passwords(
STRV_FOREACH(i, h->hashed_password) {
bool found = false;
- char **j;
log_debug("Looking for plaintext password for: %s", *i);
@@ -1144,7 +1136,6 @@ static int user_record_compile_effective_passwords(
for (n = 0; n < h->n_recovery_key; n++) {
bool found = false;
- char **j;
log_debug("Looking for plaintext recovery key for: %s", h->recovery_key[n].hashed_password);
diff --git a/src/home/user-record-pwquality.c b/src/home/user-record-pwquality.c
index 23c3357836..609e620511 100644
--- a/src/home/user-record-pwquality.c
+++ b/src/home/user-record-pwquality.c
@@ -17,7 +17,7 @@ int user_record_quality_check_password(
sd_bus_error *error) {
_cleanup_(sym_pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
- char buf[PWQ_MAX_ERROR_MESSAGE_LEN], **pp;
+ char buf[PWQ_MAX_ERROR_MESSAGE_LEN];
void *auxerror;
int r;
@@ -37,7 +37,6 @@ int user_record_quality_check_password(
/* Iterate through all new passwords */
STRV_FOREACH(pp, secret->password) {
bool called = false;
- char **old;
r = test_password_many(hr->hashed_password, *pp);
if (r < 0)
diff --git a/src/home/user-record-util.c b/src/home/user-record-util.c
index 6a892d45b5..2b727df533 100644
--- a/src/home/user-record-util.c
+++ b/src/home/user-record-util.c
@@ -563,7 +563,6 @@ int user_record_test_image_path_and_warn(UserRecord *h) {
}
int user_record_test_password(UserRecord *h, UserRecord *secret) {
- char **i;
int r;
assert(h);
@@ -585,7 +584,6 @@ int user_record_test_password(UserRecord *h, UserRecord *secret) {
}
int user_record_test_recovery_key(UserRecord *h, UserRecord *secret) {
- char **i;
int r;
assert(h);
@@ -779,7 +777,6 @@ int user_record_update_last_changed(UserRecord *h, bool with_password) {
int user_record_make_hashed_password(UserRecord *h, char **secret, bool extend) {
_cleanup_(json_variant_unrefp) JsonVariant *priv = NULL;
_cleanup_strv_free_ char **np = NULL;
- char **i;
int r;
assert(h);
diff --git a/src/id128/id128.c b/src/id128/id128.c
index 484a72677d..6f4d65103c 100644
--- a/src/id128/id128.c
+++ b/src/id128/id128.c
@@ -102,7 +102,6 @@ static int show_one(Table **table, const char *name, sd_id128_t uuid, bool first
static int verb_show(int argc, char **argv, void *userdata) {
_cleanup_(table_unrefp) Table *table = NULL;
- char **p;
int r;
argv = strv_skip(argv, 1);
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 6ab91263b1..13ca22ef26 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -594,7 +594,6 @@ static int create_remoteserver(
const char* trust) {
int r, n, fd;
- char **file;
r = journal_remote_server_init(s, arg_output, arg_split_mode, arg_compress, arg_seal);
if (r < 0)
diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c
index e6a8254491..a8119bd687 100644
--- a/src/journal-remote/microhttpd-util.c
+++ b/src/journal-remote/microhttpd-util.c
@@ -151,18 +151,17 @@ static int log_enable_gnutls_category(const char *cat) {
}
int setup_gnutls_logger(char **categories) {
- char **cat;
int r;
gnutls_global_set_log_function(log_func_gnutls);
- if (categories) {
+ if (categories)
STRV_FOREACH(cat, categories) {
r = log_enable_gnutls_category(*cat);
if (r < 0)
return r;
}
- } else
+ else
log_reset_gnutls_level();
return 0;
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 63334c0ea4..cff34fd585 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1146,7 +1146,6 @@ static int parse_argv(int argc, char *argv[]) {
}
static int add_matches(sd_journal *j, char **args) {
- char **i;
bool have_term = false;
assert(j);
@@ -1334,7 +1333,7 @@ static int get_boots(
bool skip_once;
int r, count = 0;
- BootId *head = NULL, *tail = NULL, *id;
+ BootId *head = NULL, *tail = NULL;
const bool advance_older = boot_id && offset <= 0;
sd_id128_t previous_boot_id;
@@ -1449,7 +1448,7 @@ finish:
static int list_boots(sd_journal *j) {
_cleanup_(table_unrefp) Table *table = NULL;
- BootId *id, *all_ids;
+ BootId *all_ids;
int count, i, r;
assert(j);
@@ -1584,7 +1583,7 @@ static int get_possible_units(
return r;
SD_JOURNAL_FOREACH_UNIQUE(j, data, size) {
- char **pattern, *eq;
+ char *eq;
size_t prefix;
_cleanup_free_ char *u = NULL;
@@ -1637,7 +1636,6 @@ static int get_possible_units(
static int add_units(sd_journal *j) {
_cleanup_strv_free_ char **patterns = NULL;
int r, count = 0;
- char **i;
assert(j);
@@ -1782,7 +1780,6 @@ static int add_facilities(sd_journal *j) {
static int add_syslog_identifier(sd_journal *j) {
int r;
- char **i;
assert(j);
diff --git a/src/journal/journald-rate-limit.c b/src/journal/journald-rate-limit.c
index 8accd7c7f5..842882bc59 100644
--- a/src/journal/journald-rate-limit.c
+++ b/src/journal/journald-rate-limit.c
@@ -185,10 +185,10 @@ static unsigned burst_modulate(unsigned burst, uint64_t available) {
}
int journal_ratelimit_test(JournalRateLimit *r, const char *id, usec_t rl_interval, unsigned rl_burst, int priority, uint64_t available) {
- uint64_t h;
- JournalRateLimitGroup *g;
+ JournalRateLimitGroup *g, *found = NULL;
JournalRateLimitPool *p;
unsigned burst;
+ uint64_t h;
usec_t ts;
assert(id);
@@ -208,23 +208,25 @@ int journal_ratelimit_test(JournalRateLimit *r, const char *id, usec_t rl_interv
h = siphash24_string(id, r->hash_key);
g = r->buckets[h % BUCKETS_MAX];
- LIST_FOREACH(bucket, g, g)
- if (streq(g->id, id))
+ LIST_FOREACH(bucket, i, g)
+ if (streq(i->id, id)) {
+ found = i;
break;
+ }
- if (!g) {
- g = journal_ratelimit_group_new(r, id, rl_interval, ts);
- if (!g)
+ if (!found) {
+ found = journal_ratelimit_group_new(r, id, rl_interval, ts);
+ if (!found)
return -ENOMEM;
} else
- g->interval = rl_interval;
+ found->interval = rl_interval;
if (rl_interval == 0 || rl_burst == 0)
return 1;
burst = burst_modulate(rl_burst, available);
- p = &g->pools[priority_map[priority]];
+ p = &found->pools[priority_map[priority]];
if (p->begin <= 0) {
p->suppressed = 0;
diff --git a/src/libsystemd-network/dhcp-option.c b/src/libsystemd-network/dhcp-option.c
index ebe8eecc9d..efb676e60b 100644
--- a/src/libsystemd-network/dhcp-option.c
+++ b/src/libsystemd-network/dhcp-option.c
@@ -58,7 +58,6 @@ static int option_append(uint8_t options[], size_t size, size_t *offset,
case SD_DHCP_OPTION_USER_CLASS: {
size_t total = 0;
- char **s;
if (strv_isempty((char **) optval))
return -EINVAL;
diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c
index 735fd2cde2..4e6ee7970e 100644
--- a/src/libsystemd-network/dhcp6-option.c
+++ b/src/libsystemd-network/dhcp6-option.c
@@ -328,7 +328,6 @@ static int option_append_pd_prefix(uint8_t **buf, size_t *buflen, const struct i
int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia) {
struct ia_header header;
- const DHCP6Address *addr;
size_t ia_buflen;
uint8_t *ia_hdr;
uint16_t len;
@@ -418,7 +417,6 @@ int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn) {
int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *user_class) {
_cleanup_free_ uint8_t *p = NULL;
size_t total = 0, offset = 0;
- char * const *s;
assert(buf);
assert(*buf);
@@ -451,7 +449,6 @@ int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const
_cleanup_free_ uint8_t *p = NULL;
uint32_t enterprise_identifier;
size_t total, offset;
- char * const *s;
assert(buf);
assert(*buf);
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 5456c85641..cdf49fc586 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -595,7 +595,6 @@ int sd_dhcp_client_set_user_class(
sd_dhcp_client *client,
char * const *user_class) {
- char * const *p;
char **s = NULL;
assert_return(client, -EINVAL);
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 84f3199076..e6e0e08ab2 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -916,13 +916,15 @@ int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***d
}
int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len) {
- struct sd_dhcp_raw_option *cur, *option;
+ struct sd_dhcp_raw_option *option, *before = NULL;
assert(lease);
LIST_FOREACH(options, cur, lease->private_options) {
- if (tag < cur->tag)
+ if (tag < cur->tag) {
+ before = cur;
break;
+ }
if (tag == cur->tag) {
log_debug("Ignoring duplicate option, tagged %i.", tag);
return 0;
@@ -941,7 +943,7 @@ int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const vo
return -ENOMEM;
}
- LIST_INSERT_BEFORE(options, lease->private_options, cur, option);
+ LIST_INSERT_BEFORE(options, lease->private_options, before, option);
return 0;
}
@@ -961,7 +963,6 @@ int dhcp_lease_new(sd_dhcp_lease **ret) {
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
_cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
- struct sd_dhcp_raw_option *option;
struct in_addr address;
const struct in_addr *addresses;
const void *client_id, *data;
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 163a208a44..a0faa1ec86 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -403,7 +403,6 @@ int sd_dhcp6_client_set_request_mud_url(sd_dhcp6_client *client, const char *mud
}
int sd_dhcp6_client_set_request_user_class(sd_dhcp6_client *client, char * const *user_class) {
- char * const *p;
char **s;
assert_return(client, -EINVAL);
@@ -425,7 +424,6 @@ int sd_dhcp6_client_set_request_user_class(sd_dhcp6_client *client, char * const
}
int sd_dhcp6_client_set_request_vendor_class(sd_dhcp6_client *client, char * const *vendor_class) {
- char * const *p;
char **s;
assert_return(client, -EINVAL);
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c
index 941de2f68c..8734e5a824 100644
--- a/src/libsystemd-network/sd-dhcp6-lease.c
+++ b/src/libsystemd-network/sd-dhcp6-lease.c
@@ -41,7 +41,6 @@ static usec_t sec2usec(uint32_t sec) {
static void dhcp6_lease_set_lifetime(sd_dhcp6_lease *lease) {
uint32_t t1 = UINT32_MAX, t2 = UINT32_MAX, min_valid_lt = UINT32_MAX;
- DHCP6Address *a;
assert(lease);
assert(lease->ia_na || lease->ia_pd);
@@ -107,11 +106,9 @@ int sd_dhcp6_lease_get_server_address(sd_dhcp6_lease *lease, struct in6_addr *re
}
void dhcp6_ia_clear_addresses(DHCP6IA *ia) {
- DHCP6Address *a, *n;
-
assert(ia);
- LIST_FOREACH_SAFE(addresses, a, n, ia->addresses)
+ LIST_FOREACH(addresses, a, ia->addresses)
free(a);
ia->addresses = NULL;
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c
index c2f633a82b..370a10a013 100644
--- a/src/libsystemd-network/sd-radv.c
+++ b/src/libsystemd-network/sd-radv.c
@@ -148,8 +148,6 @@ static be32_t usec_to_be32_sec(usec_t usec) {
}
static int radv_send(sd_radv *ra, const struct in6_addr *dst, usec_t lifetime_usec) {
- sd_radv_route_prefix *rt;
- sd_radv_prefix *p;
struct sockaddr_in6 dst_addr = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_ALL_NODES_MULTICAST_INIT,
@@ -578,7 +576,7 @@ int sd_radv_set_preference(sd_radv *ra, unsigned preference) {
int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
_cleanup_free_ char *addr_p = NULL;
- sd_radv_prefix *cur, *found = NULL;
+ sd_radv_prefix *found = NULL;
int r;
assert_return(ra, -EINVAL);
@@ -661,8 +659,6 @@ void sd_radv_remove_prefix(
const struct in6_addr *prefix,
unsigned char prefixlen) {
- sd_radv_prefix *cur;
-
if (!ra)
return;
@@ -685,7 +681,7 @@ void sd_radv_remove_prefix(
int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) {
_cleanup_free_ char *addr_p = NULL;
- sd_radv_route_prefix *cur, *found = NULL;
+ sd_radv_route_prefix *found = NULL;
int r;
assert_return(ra, -EINVAL);
@@ -803,7 +799,6 @@ int sd_radv_set_dnssl(
_cleanup_free_ struct sd_radv_opt_dns *opt_dnssl = NULL;
size_t len = 0;
- char **s;
uint8_t *p;
assert_return(ra, -EINVAL);
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index 19040452bc..050eec3a7c 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -413,8 +413,6 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
r = sd_bus_creds_get_cmdline(c, &cmdline);
if (r >= 0) {
- char **i;
-
fprintf(f, "%sCommandLine=%s", prefix, color);
STRV_FOREACH(i, cmdline) {
if (i != cmdline)
@@ -479,8 +477,6 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
fprintf(f, "%sUniqueName=%s%s%s", prefix, color, c->unique_name, suffix);
if (sd_bus_creds_get_well_known_names(c, &well_known) >= 0) {
- char **i;
-
fprintf(f, "%sWellKnownNames=%s", prefix, color);
STRV_FOREACH(i, well_known) {
if (i != well_known)
diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c
index 12a50845db..d4da60717e 100644
--- a/src/libsystemd/sd-bus/bus-match.c
+++ b/src/libsystemd/sd-bus/bus-match.c
@@ -139,8 +139,6 @@ static bool value_node_test(
return true;
if (m->creds.mask & SD_BUS_CREDS_WELL_KNOWN_NAMES) {
- char **i;
-
/* on kdbus we have the well known names list
* in the credentials, let's make use of that
* for an accurate match */
@@ -174,8 +172,6 @@ static bool value_node_test(
return false;
case BUS_MATCH_ARG_HAS ... BUS_MATCH_ARG_HAS_LAST: {
- char **i;
-
STRV_FOREACH(i, value_strv)
if (streq_ptr(node->value.str, *i))
return true;
@@ -386,8 +382,6 @@ int bus_match_run(
if (test_str)
found = hashmap_get(node->compare.children, test_str);
else if (test_strv) {
- char **i;
-
STRV_FOREACH(i, test_strv) {
found = hashmap_get(node->compare.children, *i);
if (found) {
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 96529b422b..b77372c3a0 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -2815,7 +2815,6 @@ _public_ int sd_bus_message_append_string_memfd(
}
_public_ int sd_bus_message_append_strv(sd_bus_message *m, char **l) {
- char **i;
int r;
assert_return(m, -EINVAL);
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index b852475419..519cd198e5 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -101,7 +101,6 @@ static int add_enumerated_to_set(
OrderedSet *s,
sd_bus_error *error) {
- struct node_enumerator *c;
int r;
assert(bus);
@@ -109,7 +108,7 @@ static int add_enumerated_to_set(
assert(s);
LIST_FOREACH(enumerators, c, first) {
- char **children = NULL, **k;
+ char **children = NULL;
sd_bus_slot *slot;
if (bus->nodes_modified)
@@ -173,7 +172,6 @@ static int add_subtree_to_set(
OrderedSet *s,
sd_bus_error *error) {
- struct node *i;
int r;
assert(bus);
@@ -251,7 +249,6 @@ static int node_callbacks_run(
bool require_fallback,
bool *found_object) {
- struct node_callback *c;
int r;
assert(bus);
@@ -807,7 +804,6 @@ static int property_get_all_callbacks_run(
bool *found_object) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
- struct node_vtable *c;
bool found_interface;
int r;
@@ -887,8 +883,6 @@ static int bus_node_exists(
const char *path,
bool require_fallback) {
- struct node_vtable *c;
- struct node_callback *k;
int r;
assert(bus);
@@ -936,7 +930,6 @@ int introspect_path(
_cleanup_ordered_set_free_ OrderedSet *s = NULL;
_cleanup_(introspect_free) struct introspect intro = {};
- struct node_vtable *c;
bool empty;
int r;
@@ -1057,7 +1050,6 @@ static int object_manager_serialize_path(
const char *previous_interface = NULL;
bool found_something = false;
- struct node_vtable *i;
struct node *n;
int r;
@@ -1787,7 +1779,7 @@ static int add_object_vtable_internal(
void *userdata) {
sd_bus_slot *s = NULL;
- struct node_vtable *i, *existing = NULL;
+ struct node_vtable *existing = NULL;
const sd_bus_vtable *v;
struct node *n;
int r;
@@ -2068,9 +2060,7 @@ static int emit_properties_changed_on_interface(
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
bool has_invalidating = false, has_changing = false;
struct vtable_member key = {};
- struct node_vtable *c;
struct node *n;
- char **property;
void *u = NULL;
int r;
@@ -2355,7 +2345,6 @@ static int object_added_append_all_prefix(
bool require_fallback) {
const char *previous_interface = NULL;
- struct node_vtable *c;
struct node *n;
int r;
@@ -2575,7 +2564,6 @@ static int object_removed_append_all_prefix(
bool require_fallback) {
const char *previous_interface = NULL;
- struct node_vtable *c;
struct node *n;
int r;
@@ -2753,7 +2741,6 @@ static int interfaces_added_append_one_prefix(
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
bool found_interface = false;
- struct node_vtable *c;
struct node *n;
void *u = NULL;
int r;
@@ -2852,7 +2839,6 @@ static int interfaces_added_append_one(
_public_ int sd_bus_emit_interfaces_added_strv(sd_bus *bus, const char *path, char **interfaces) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
struct node *object_manager;
- char **i;
int r;
assert_return(bus, -EINVAL);
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 9e1d29cc1d..f96149473b 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -2783,7 +2783,6 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) {
static int process_filter(sd_bus *bus, sd_bus_message *m) {
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
- struct filter_callback *l;
int r;
assert(bus);
diff --git a/src/libsystemd/sd-bus/test-bus-address.c b/src/libsystemd/sd-bus/test-bus-address.c
index 00d3c15a8f..ec9ee83fac 100644
--- a/src/libsystemd/sd-bus/test-bus-address.c
+++ b/src/libsystemd/sd-bus/test-bus-address.c
@@ -27,7 +27,6 @@ TEST(bus_set_address_system_remote) {
assert_se(sd_bus_new(&b) >= 0);
if (!strv_isempty(saved_argv + 1)) {
- char **a;
STRV_FOREACH(a, saved_argv + 1)
test_one_address(b, *a, 0, NULL);
return;
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
index c383833740..d08d81f53a 100644
--- a/src/libsystemd/sd-device/device-private.c
+++ b/src/libsystemd/sd-device/device-private.c
@@ -437,7 +437,6 @@ static int device_verify(sd_device *device) {
int device_new_from_strv(sd_device **ret, char **strv) {
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
- char **key;
const char *major = NULL, *minor = NULL;
int r;
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index fcb242fefa..38b2ef510b 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -1920,7 +1920,6 @@ static int event_make_inode_data(
static uint32_t inode_data_determine_mask(struct inode_data *d) {
bool excl_unlink = true;
uint32_t combined = 0;
- sd_event_source *s;
assert(d);
@@ -3458,9 +3457,7 @@ static int event_inotify_data_process(sd_event *e, struct inotify_data *d) {
/* The queue overran, let's pass this event to all event sources connected to this inotify
* object */
- HASHMAP_FOREACH(inode_data, d->inodes) {
- sd_event_source *s;
-
+ HASHMAP_FOREACH(inode_data, d->inodes)
LIST_FOREACH(inotify.by_inode_data, s, inode_data->event_sources) {
if (event_source_is_offline(s))
@@ -3470,10 +3467,8 @@ static int event_inotify_data_process(sd_event *e, struct inotify_data *d) {
if (r < 0)
return r;
}
- }
} else {
struct inode_data *inode_data;
- sd_event_source *s;
/* Find the inode object for this watch descriptor. If IN_IGNORED is set we also remove it from
* our watch descriptor table. */
@@ -3521,7 +3516,6 @@ static int event_inotify_data_process(sd_event *e, struct inotify_data *d) {
}
static int process_inotify(sd_event *e) {
- struct inotify_data *d;
int r, done = 0;
assert(e);
diff --git a/src/libsystemd/sd-journal/catalog.c b/src/libsystemd/sd-journal/catalog.c
index e2397f47e3..b988ee3bba 100644
--- a/src/libsystemd/sd-journal/catalog.c
+++ b/src/libsystemd/sd-journal/catalog.c
@@ -439,7 +439,6 @@ error:
int catalog_update(const char* database, const char* root, const char* const* dirs) {
_cleanup_strv_free_ char **files = NULL;
- char **f;
_cleanup_(strbuf_freep) struct strbuf *sb = NULL;
_cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
_cleanup_free_ CatalogItem *items = NULL;
@@ -706,7 +705,6 @@ int catalog_list(FILE *f, const char *database, bool oneline) {
}
int catalog_list_items(FILE *f, const char *database, bool oneline, char **items) {
- char **item;
int r = 0;
STRV_FOREACH(item, items) {
diff --git a/src/libsystemd/sd-journal/mmap-cache.c b/src/libsystemd/sd-journal/mmap-cache.c
index 124ee3f8c1..82407f9396 100644
--- a/src/libsystemd/sd-journal/mmap-cache.c
+++ b/src/libsystemd/sd-journal/mmap-cache.c
@@ -86,7 +86,6 @@ MMapCache* mmap_cache_new(void) {
}
static void window_unlink(Window *w) {
- Context *c;
assert(w);
@@ -306,7 +305,7 @@ static int find_mmap(
size_t size,
void **ret) {
- Window *w;
+ Window *found = NULL;
assert(f);
assert(f->cache);
@@ -318,16 +317,18 @@ static int find_mmap(
return -EIO;
LIST_FOREACH(by_fd, w, f->windows)
- if (window_matches(w, offset, size))
+ if (window_matches(w, offset, size)) {
+ found = w;
break;
+ }
- if (!w)
+ if (!found)
return 0;
- context_attach_window(f->cache, c, w);
- w->keep_always = w->keep_always || keep_always;
+ context_attach_window(f->cache, c, found);
+ found->keep_always = found->keep_always || keep_always;
- *ret = (uint8_t*) w->ptr + (offset - w->offset);
+ *ret = (uint8_t*) found->ptr + (offset - found->offset);
f->cache->n_window_list_hit++;
return 1;
@@ -494,8 +495,6 @@ static void mmap_cache_process_sigbus(MMapCache *m) {
ours = false;
HASHMAP_FOREACH(f, m->fds) {
- Window *w;
-
LIST_FOREACH(by_fd, w, f->windows) {
if ((uint8_t*) addr >= (uint8_t*) w->ptr &&
(uint8_t*) addr < (uint8_t*) w->ptr + w->size) {
@@ -523,8 +522,6 @@ static void mmap_cache_process_sigbus(MMapCache *m) {
return;
HASHMAP_FOREACH(f, m->fds) {
- Window *w;
-
if (!f->sigbus)
continue;
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index 399e33fa2b..62755ed965 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -233,7 +233,7 @@ static Match *match_free_if_empty(Match *m) {
}
_public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size) {
- Match *l3, *l4, *add_here = NULL, *m = NULL;
+ Match *add_here = NULL, *m = NULL;
uint64_t hash;
assert_return(j, -EINVAL);
@@ -372,7 +372,6 @@ _public_ int sd_journal_add_disjunction(sd_journal *j) {
static char *match_make_string(Match *m) {
char *p = NULL, *r;
- Match *i;
bool enclose = false;
if (!m)
@@ -518,7 +517,6 @@ static int next_for_match(
return journal_file_move_to_entry_by_offset_for_data(f, d, after_offset, direction, ret, offset);
} else if (m->type == MATCH_OR_TERM) {
- Match *i;
/* Find the earliest match beyond after_offset */
@@ -538,7 +536,7 @@ static int next_for_match(
return 0;
} else if (m->type == MATCH_AND_TERM) {
- Match *i, *last_moved;
+ Match *last_moved;
/* Always jump to the next matching entry and repeat
* this until we find an offset that matches for all
@@ -636,7 +634,6 @@ static int find_location_for_match(
} else if (m->type == MATCH_OR_TERM) {
uint64_t np = 0;
Object *n;
- Match *i;
/* Find the earliest match */
@@ -667,7 +664,6 @@ static int find_location_for_match(
return 1;
} else {
- Match *i;
uint64_t np = 0;
assert(m->type == MATCH_AND_TERM);
@@ -2035,7 +2031,6 @@ _public_ int sd_journal_open_directory(sd_journal **ret, const char *path, int f
_public_ int sd_journal_open_files(sd_journal **ret, const char **paths, int flags) {
_cleanup_(sd_journal_closep) sd_journal *j = NULL;
- const char **path;
int r;
assert_return(ret, -EINVAL);
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
index 30d159ec98..e846399a53 100644
--- a/src/libsystemd/sd-netlink/netlink-message.c
+++ b/src/libsystemd/sd-netlink/netlink-message.c
@@ -259,7 +259,6 @@ int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type,
int sd_netlink_message_append_strv(sd_netlink_message *m, unsigned short type, char * const *data) {
size_t length, size;
- char * const *p;
int r;
assert_return(m, -EINVAL);
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
index 4cd4e73405..5271c1492d 100644
--- a/src/libsystemd/sd-netlink/sd-netlink.c
+++ b/src/libsystemd/sd-netlink/sd-netlink.c
@@ -424,7 +424,6 @@ static int process_reply(sd_netlink *nl, sd_netlink_message *m) {
}
static int process_match(sd_netlink *nl, sd_netlink_message *m) {
- struct match_callback *c;
uint16_t type;
uint8_t cmd;
int r;
diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c
index ff1e0d5f8e..8d9cfbc0af 100644
--- a/src/libsystemd/sd-path/sd-path.c
+++ b/src/libsystemd/sd-path/sd-path.c
@@ -669,7 +669,7 @@ _public_ int sd_path_lookup_strv(uint64_t type, const char *suffix, char ***path
if (!n)
return -ENOMEM;
- char **i, **j = n;
+ char **j = n;
STRV_FOREACH(i, l) {
*j = path_join(*i, suffix);
if (!*j)
diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c
index 69efc1013c..d3b63b1f8f 100644
--- a/src/libudev/libudev-list.c
+++ b/src/libudev/libudev-list.c
@@ -110,8 +110,6 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *
}
void udev_list_cleanup(struct udev_list *list) {
- struct udev_list_entry *i, *n;
-
if (!list)
return;
@@ -119,7 +117,7 @@ void udev_list_cleanup(struct udev_list *list) {
list->uptodate = false;
hashmap_clear_with_destructor(list->unique_entries, udev_list_entry_free);
} else
- LIST_FOREACH_SAFE(entries, i, n, list->entries)
+ LIST_FOREACH(entries, i, list->entries)
udev_list_entry_free(i);
}
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index b5624209dc..661d54c27d 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -98,8 +98,6 @@ static void print_status_info(StatusInfo *i) {
if (strv_isempty(i->locale))
puts(" System Locale: n/a");
else {
- char **j;
-
printf(" System Locale: %s\n", i->locale[0]);
STRV_FOREACH(j, i->locale + 1)
printf(" %s\n", *j);
diff --git a/src/locale/localed.c b/src/locale/localed.c
index c228385d0e..5d95da1560 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -346,7 +346,6 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
Context *c = userdata;
bool modified = false;
int interactive, r;
- char **i;
bool use_localegen;
assert(m);
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 6af0ad2f3c..83f25135a2 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -601,7 +601,6 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line)
printf("\t State: %s\n", i.state);
if (!strv_isempty(i.sessions)) {
- char **l;
printf("\tSessions:");
STRV_FOREACH(l, i.sessions)
@@ -662,7 +661,6 @@ static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line)
printf("%s\n", strna(i.id));
if (!strv_isempty(i.sessions)) {
- char **l;
printf("\tSessions:");
STRV_FOREACH(l, i.sessions) {
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 2ed4eeddfe..a1c7d0a883 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -3813,8 +3813,8 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
if (streq_ptr(path, user->service_job)) {
user->service_job = mfree(user->service_job);
- LIST_FOREACH(sessions_by_user, session, user->sessions)
- (void) session_jobs_reply(session, id, unit, NULL /* don't propagate user service failures to the client */);
+ LIST_FOREACH(sessions_by_user, s, user->sessions)
+ (void) session_jobs_reply(s, id, unit, NULL /* don't propagate user service failures to the client */);
user_save(user);
}
@@ -3957,7 +3957,6 @@ int manager_start_scope(
char **job) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
- char **i;
int r;
assert(manager);
diff --git a/src/login/logind-device.c b/src/login/logind-device.c
index 982a772194..592ee3b9d6 100644
--- a/src/login/logind-device.c
+++ b/src/login/logind-device.c
@@ -67,7 +67,6 @@ void device_free(Device *d) {
}
void device_attach(Device *d, Seat *s) {
- Device *i;
bool had_master;
assert(d);
diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c
index f82991c5da..cd20693cbe 100644
--- a/src/login/logind-seat-dbus.c
+++ b/src/login/logind-seat-dbus.c
@@ -56,7 +56,6 @@ static int property_get_sessions(
sd_bus_error *error) {
Seat *s = userdata;
- Session *session;
int r;
assert(bus);
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 58912b85b3..8e603f1f38 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -122,8 +122,6 @@ int seat_save(Seat *s) {
}
if (s->sessions) {
- Session *i;
-
fputs("SESSIONS=", f);
LIST_FOREACH(sessions_by_seat, i, s->sessions) {
fprintf(f,
@@ -349,7 +347,7 @@ int seat_switch_to_previous(Seat *s) {
}
int seat_active_vt_changed(Seat *s, unsigned vtnr) {
- Session *i, *new_active = NULL;
+ Session *new_active = NULL;
int r;
assert(s);
@@ -368,7 +366,7 @@ int seat_active_vt_changed(Seat *s, unsigned vtnr) {
break;
}
- if (!new_active) {
+ if (!new_active)
/* no running one? then we can't decide which one is the
* active one, let the first one win */
LIST_FOREACH(sessions_by_seat, i, s->sessions)
@@ -376,7 +374,6 @@ int seat_active_vt_changed(Seat *s, unsigned vtnr) {
new_active = i;
break;
}
- }
r = seat_set_active(s, new_active);
manager_spawn_autovt(s->manager, vtnr);
@@ -467,7 +464,6 @@ int seat_stop(Seat *s, bool force) {
}
int seat_stop_sessions(Seat *s, bool force) {
- Session *session;
int r = 0, k;
assert(s);
@@ -482,7 +478,6 @@ int seat_stop_sessions(Seat *s, bool force) {
}
void seat_evict_position(Seat *s, Session *session) {
- Session *iter;
unsigned pos = session->position;
session->position = 0;
@@ -496,12 +491,11 @@ void seat_evict_position(Seat *s, Session *session) {
/* There might be another session claiming the same
* position (eg., during gdm->session transition), so let's look
* for it and set it on the free slot. */
- LIST_FOREACH(sessions_by_seat, iter, s->sessions) {
+ LIST_FOREACH(sessions_by_seat, iter, s->sessions)
if (iter->position == pos && session_get_state(iter) != SESSION_CLOSING) {
s->positions[pos] = iter;
break;
}
- }
}
}
@@ -599,7 +593,6 @@ bool seat_can_graphical(Seat *s) {
}
int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
- Session *session;
bool idle_hint = true;
dual_timestamp ts = DUAL_TIMESTAMP_NULL;
diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c
index 572a16a7af..67b6556d7d 100644
--- a/src/login/logind-user-dbus.c
+++ b/src/login/logind-user-dbus.c
@@ -106,7 +106,6 @@ static int property_get_sessions(
sd_bus_error *error) {
User *u = userdata;
- Session *session;
int r;
assert(bus);
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 8d6bafe45d..af33bf7a4f 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -189,7 +189,6 @@ static int user_save_internal(User *u) {
u->last_session_timestamp);
if (u->sessions) {
- Session *i;
bool first;
fputs("SESSIONS=", f);
@@ -499,8 +498,8 @@ static void user_stop_service(User *u, bool force) {
}
int user_stop(User *u, bool force) {
- Session *s;
int r = 0;
+
assert(u);
/* This is called whenever we begin with tearing down a user record. It's called in two cases: explicit API
@@ -534,7 +533,6 @@ int user_stop(User *u, bool force) {
}
int user_finalize(User *u) {
- Session *s;
int r = 0, k;
assert(u);
@@ -575,7 +573,6 @@ int user_finalize(User *u) {
}
int user_get_idle_hint(User *u, dual_timestamp *t) {
- Session *s;
bool idle_hint = true;
dual_timestamp ts = DUAL_TIMESTAMP_NULL;
@@ -721,8 +718,6 @@ void user_add_to_gc_queue(User *u) {
}
UserState user_get_state(User *u) {
- Session *i;
-
assert(u);
if (u->stopping)
@@ -805,8 +800,6 @@ static int elect_display_compare(Session *s1, Session *s2) {
}
void user_elect_display(User *u) {
- Session *s;
-
assert(u);
/* This elects a primary session for each user, which we call the "display". We try to keep the assignment
diff --git a/src/login/logind.c b/src/login/logind.c
index 3b4de5b799..0483902edd 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -685,7 +685,7 @@ static int manager_connect_bus(Manager *m) {
static int manager_vt_switch(sd_event_source *src, const struct signalfd_siginfo *si, void *data) {
Manager *m = data;
- Session *active, *iter;
+ Session *active;
/*
* We got a VT-switch signal and we have to acknowledge it immediately.
@@ -732,16 +732,14 @@ static int manager_vt_switch(sd_event_source *src, const struct signalfd_siginfo
return 0;
}
- if (active->vtfd >= 0) {
+ if (active->vtfd >= 0)
session_leave_vt(active);
- } else {
- LIST_FOREACH(sessions_by_seat, iter, m->seat0->sessions) {
+ else
+ LIST_FOREACH(sessions_by_seat, iter, m->seat0->sessions)
if (iter->vtnr == active->vtnr && iter->vtfd >= 0) {
session_leave_vt(iter);
break;
}
- }
- }
return 0;
}
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index 5bd7efc3e8..2047dc1817 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -533,7 +533,6 @@ static int pam_putenv_and_log(pam_handle_t *handle, const char *e, bool debug) {
}
static int apply_user_record_settings(pam_handle_t *handle, UserRecord *ur, bool debug) {
- char **i;
int r;
assert(handle);
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index eda847cb4a..9e20d59389 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -194,7 +194,6 @@ static int run(int argc, char *argv[]) {
} else {
_cleanup_strv_free_ char **files = NULL;
- char **fn, **i;
STRV_FOREACH(i, arg_proc_cmdline_modules) {
k = module_load_and_warn(ctx, *i, true);
diff --git a/src/network/generator/network-generator.c b/src/network/generator/network-generator.c
index 063ad08d80..a1b5511338 100644
--- a/src/network/generator/network-generator.c
+++ b/src/network/generator/network-generator.c
@@ -1033,7 +1033,6 @@ int parse_cmdline_item(const char *key, const char *value, void *data) {
int context_merge_networks(Context *context) {
Network *all, *network;
- Route *route;
int r;
assert(context);
@@ -1129,10 +1128,7 @@ static int route_dump(Route *route, FILE *f) {
}
void network_dump(Network *network, FILE *f) {
- Address *address;
- Route *route;
const char *dhcp;
- char **dns;
assert(network);
assert(f);
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c
index 187b24c558..3d1a5e5b31 100644
--- a/src/network/netdev/netdev.c
+++ b/src/network/netdev/netdev.c
@@ -860,7 +860,6 @@ int netdev_load_one(Manager *manager, const char *filename) {
int netdev_load(Manager *manager, bool reload) {
_cleanup_strv_free_ char **files = NULL;
- char **f;
int r;
assert(manager);
diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
index 3bb496130b..9e98b93a5c 100644
--- a/src/network/netdev/wireguard.c
+++ b/src/network/netdev/wireguard.c
@@ -147,7 +147,7 @@ cancel:
}
static int wireguard_set_peer_one(NetDev *netdev, sd_netlink_message *message, const WireguardPeer *peer, uint16_t index, WireguardIPmask **mask_start) {
- WireguardIPmask *mask, *start;
+ WireguardIPmask *start, *last = NULL;
uint16_t j = 0;
int r;
@@ -196,8 +196,10 @@ static int wireguard_set_peer_one(NetDev *netdev, sd_netlink_message *message, c
r = wireguard_set_ipmask_one(netdev, message, mask, ++j);
if (r < 0)
return r;
- if (r == 0)
+ if (r == 0) {
+ last = mask;
break;
+ }
}
r = sd_netlink_message_close_container(message);
@@ -208,8 +210,8 @@ static int wireguard_set_peer_one(NetDev *netdev, sd_netlink_message *message, c
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not add wireguard peer: %m");
- *mask_start = mask; /* Start next cycle from this mask. */
- return !mask;
+ *mask_start = last; /* Start next cycle from this mask. */
+ return !last;
cancel:
r = sd_netlink_message_cancel_array(message);
@@ -222,7 +224,7 @@ cancel:
static int wireguard_set_interface(NetDev *netdev) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
WireguardIPmask *mask_start = NULL;
- WireguardPeer *peer, *peer_start;
+ WireguardPeer *peer_start;
bool sent_once = false;
uint32_t serial;
Wireguard *w;
@@ -267,14 +269,17 @@ static int wireguard_set_interface(NetDev *netdev) {
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append wireguard peer attributes: %m");
+ WireguardPeer *peer_last = NULL;
LIST_FOREACH(peers, peer, peer_start) {
r = wireguard_set_peer_one(netdev, message, peer, ++i, &mask_start);
if (r < 0)
return r;
- if (r == 0)
+ if (r == 0) {
+ peer_last = peer;
break;
+ }
}
- peer_start = peer; /* Start next cycle from this peer. */
+ peer_start = peer_last; /* Start next cycle from this peer. */
r = sd_netlink_message_close_container(message);
if (r < 0)
@@ -424,7 +429,6 @@ static int peer_resolve_endpoint(WireguardPeer *peer) {
}
static void wireguard_resolve_endpoints(NetDev *netdev) {
- WireguardPeer *peer;
Wireguard *w;
assert(netdev);
@@ -1124,7 +1128,6 @@ static int wireguard_peer_verify(WireguardPeer *peer) {
}
static int wireguard_verify(NetDev *netdev, const char *filename) {
- WireguardPeer *peer, *peer_next;
Wireguard *w;
int r;
@@ -1143,9 +1146,7 @@ static int wireguard_verify(NetDev *netdev, const char *filename) {
"%s: Missing PrivateKey= or PrivateKeyFile=, "
"Ignoring network device.", filename);
- LIST_FOREACH_SAFE(peers, peer, peer_next, w->peers) {
- WireguardIPmask *ipmask;
-
+ LIST_FOREACH(peers, peer, w->peers) {
if (wireguard_peer_verify(peer) < 0) {
wireguard_peer_free(peer);
continue;
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 8fe9844c4f..d656027ec4 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -525,7 +525,6 @@ static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, b
if (!strv_fnmatch_full(patterns, str, 0, &pos) &&
!strv_fnmatch_full(patterns, name, 0, &pos)) {
bool match = false;
- char **p;
STRV_FOREACH(p, altnames)
if (strv_fnmatch_full(patterns, *p, 0, &pos)) {
diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c
index 79ded2e99e..5861ecb922 100644
--- a/src/network/networkd-dhcp-server.c
+++ b/src/network/networkd-dhcp-server.c
@@ -217,8 +217,6 @@ static int link_push_uplink_to_dhcp_server(
break;
case SD_DHCP_LEASE_NTP: {
- char **i;
-
/* For NTP things are similar, but for NTP hostnames can be configured too, which we cannot
* propagate via DHCP. Hence let's only propagate those which are IP addresses. */
diff --git a/src/network/networkd-json.c b/src/network/networkd-json.c
index fb1f50063e..dc9823c375 100644
--- a/src/network/networkd-json.c
+++ b/src/network/networkd-json.c
@@ -699,7 +699,6 @@ static int server_build_json_one_string(const char *str, NetworkConfigSource s,
static int ntp_build_json(Link *link, JsonVariant **ret) {
JsonVariant **elements = NULL;
size_t n = 0;
- char **p;
int r;
assert(link);
@@ -878,7 +877,7 @@ static int domains_build_json(Link *link, bool is_route, JsonVariant **ret) {
JsonVariant **elements = NULL;
DHCPUseDomains use_domains;
union in_addr_union s;
- char **p, **domains;
+ char **domains;
const char *domain;
size_t n = 0;
int r;
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c
index 765733b38c..4173eaa15f 100644
--- a/src/network/networkd-link-bus.c
+++ b/src/network/networkd-link-bus.c
@@ -81,7 +81,6 @@ int bus_link_method_set_ntp_servers(sd_bus_message *message, void *userdata, sd_
_cleanup_strv_free_ char **ntp = NULL;
Link *l = userdata;
int r;
- char **i;
assert(message);
assert(l);
@@ -484,7 +483,6 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
_cleanup_strv_free_ char **ntas = NULL;
Link *l = userdata;
int r;
- char **i;
assert(message);
assert(l);
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index e925739d06..a122ea84fe 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -910,8 +910,6 @@ static void link_drop_requests(Link *link) {
}
static Link *link_drop(Link *link) {
- char **n;
-
if (!link)
return NULL;
@@ -2251,7 +2249,6 @@ static int link_update_mtu(Link *link, sd_netlink_message *message) {
static int link_update_alternative_names(Link *link, sd_netlink_message *message) {
_cleanup_strv_free_ char **altnames = NULL;
- char **n;
int r;
assert(link);
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index 8cbc67f542..63e5ff6cc6 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -790,7 +790,6 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
struct in6_addr router;
uint32_t lifetime_sec;
bool updated = false;
- char **j;
int r;
assert(link);
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 683b04b5ac..9acfc863f2 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -580,7 +580,6 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
int network_load(Manager *manager, OrderedHashmap **networks) {
_cleanup_strv_free_ char **files = NULL;
- char **f;
int r;
assert(manager);
diff --git a/src/nspawn/nspawn-bind-user.c b/src/nspawn/nspawn-bind-user.c
index 97761cb6f0..45ddb59f76 100644
--- a/src/nspawn/nspawn-bind-user.c
+++ b/src/nspawn/nspawn-bind-user.c
@@ -200,7 +200,6 @@ int bind_user_prepare(
_cleanup_(bind_user_context_freep) BindUserContext *c = NULL;
uid_t current_uid = MAP_UID_MIN;
- char **n;
int r;
assert(custom_mounts);
diff --git a/src/nspawn/nspawn-expose-ports.c b/src/nspawn/nspawn-expose-ports.c
index 2890190eec..166383cce3 100644
--- a/src/nspawn/nspawn-expose-ports.c
+++ b/src/nspawn/nspawn-expose-ports.c
@@ -16,11 +16,10 @@
#include "util.h"
int expose_port_parse(ExposePort **l, const char *s) {
-
const char *split, *e;
uint16_t container_port, host_port;
+ ExposePort *port;
int protocol;
- ExposePort *p;
int r;
assert(l);
@@ -59,17 +58,17 @@ int expose_port_parse(ExposePort **l, const char *s) {
if (p->protocol == protocol && p->host_port == host_port)
return -EEXIST;
- p = new(ExposePort, 1);
- if (!p)
+ port = new(ExposePort, 1);
+ if (!port)
return -ENOMEM;
- *p = (ExposePort) {
+ *port = (ExposePort) {
.protocol = protocol,
.host_port = host_port,
.container_port = container_port,
};
- LIST_PREPEND(ports, *l, p);
+ LIST_PREPEND(ports, *l, port);
return 0;
}
@@ -84,7 +83,6 @@ void expose_port_free_all(ExposePort *p) {
}
int expose_port_flush(FirewallContext **fw_ctx, ExposePort* l, int af, union in_addr_union *exposed) {
- ExposePort *p;
int r;
assert(exposed);
@@ -117,7 +115,6 @@ int expose_port_flush(FirewallContext **fw_ctx, ExposePort* l, int af, union in_
int expose_port_execute(sd_netlink *rtnl, FirewallContext **fw_ctx, ExposePort *l, int af, union in_addr_union *exposed) {
_cleanup_free_ struct local_address *addresses = NULL;
union in_addr_union new_exposed;
- ExposePort *p;
bool add;
int r;
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c
index f2fad0f462..7101a87694 100644
--- a/src/nspawn/nspawn-mount.c
+++ b/src/nspawn/nspawn-mount.c
@@ -166,8 +166,6 @@ int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n) {
}
if (m->type == CUSTOM_MOUNT_OVERLAY) {
- char **j;
-
STRV_FOREACH(j, m->lower) {
char *s;
@@ -319,8 +317,6 @@ int overlay_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_onl
if (!destination)
return -ENOMEM;
} else {
- char **i;
-
/* If more than two parameters are specified, the last one is the destination, the second to last one
* the "upper", and all before that the "lower" directories. */
diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c
index 023b1e7e1a..fab4eb9609 100644
--- a/src/nspawn/nspawn-network.c
+++ b/src/nspawn/nspawn-network.c
@@ -288,7 +288,6 @@ int setup_veth_extra(
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
uint64_t idx = 0;
- char **a, **b;
int r;
assert(machine_name);
@@ -495,7 +494,6 @@ int test_network_interface_initialized(const char *name) {
int move_network_interfaces(int netns_fd, char **ifaces) {
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
- char **i;
int r;
if (strv_isempty(ifaces))
@@ -532,7 +530,6 @@ int move_network_interfaces(int netns_fd, char **ifaces) {
int setup_macvlan(const char *machine_name, pid_t pid, char **ifaces) {
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
unsigned idx = 0;
- char **i;
int r;
if (strv_isempty(ifaces))
@@ -619,7 +616,6 @@ int setup_macvlan(const char *machine_name, pid_t pid, char **ifaces) {
int setup_ipvlan(const char *machine_name, pid_t pid, char **ifaces) {
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
- char **i;
int r;
if (strv_isempty(ifaces))
@@ -728,7 +724,6 @@ int veth_extra_parse(char ***l, const char *p) {
int remove_veth_links(const char *primary, char **pairs) {
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
- char **a, **b;
int r;
/* In some cases the kernel might pin the veth links between host and container even after the namespace
diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c
index a23358464b..44564ba619 100644
--- a/src/nspawn/nspawn-oci.c
+++ b/src/nspawn/nspawn-oci.c
@@ -1892,7 +1892,6 @@ static int oci_seccomp_syscalls(const char *name, JsonVariant *v, JsonDispatchFl
struct syscall_rule rule = {
.action = UINT32_MAX,
};
- char **i;
r = json_dispatch(e, table, oci_unexpected, flags, &rule);
if (r < 0)
diff --git a/src/nspawn/nspawn-seccomp.c b/src/nspawn/nspawn-seccomp.c
index c94512ef30..77f4c2ac88 100644
--- a/src/nspawn/nspawn-seccomp.c
+++ b/src/nspawn/nspawn-seccomp.c
@@ -140,7 +140,6 @@ static int add_syscall_filters(
};
_cleanup_strv_free_ char **added = NULL;
- char **p;
int r;
for (size_t i = 0; i < ELEMENTSOF(allow_list); i++) {
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index ff4ccde1f8..7fab88b31a 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -3149,7 +3149,6 @@ static int patch_sysctl(void) {
};
unsigned long flags;
- char **k, **v;
int r;
flags = effective_clone_ns_flags();
diff --git a/src/nss-systemd/userdb-glue.c b/src/nss-systemd/userdb-glue.c
index 002e6925f9..c69667d660 100644
--- a/src/nss-systemd/userdb-glue.c
+++ b/src/nss-systemd/userdb-glue.c
@@ -217,7 +217,7 @@ int nss_pack_group_record(
char *buffer,
size_t buflen) {
- char **array = NULL, *p, **m;
+ char **array = NULL, *p;
size_t required, n = 0, i = 0;
assert(g);
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 52fd0436e3..600c4f6e5b 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -373,7 +373,6 @@ static int context_add_free_area(
static bool context_drop_one_priority(Context *context) {
int32_t priority = 0;
- Partition *p;
bool exists = false;
LIST_FOREACH(partitions, p, context->partitions) {
@@ -561,8 +560,6 @@ static uint64_t charge_weight(uint64_t total, uint64_t amount) {
}
static bool context_allocate_partitions(Context *context, uint64_t *ret_largest_free_area) {
- Partition *p;
-
assert(context);
/* Sort free areas by size, putting smallest first */
@@ -613,7 +610,6 @@ static bool context_allocate_partitions(Context *context, uint64_t *ret_largest_
static int context_sum_weights(Context *context, FreeArea *a, uint64_t *ret) {
uint64_t weight_sum = 0;
- Partition *p;
assert(context);
assert(a);
@@ -677,7 +673,6 @@ static int context_grow_partitions_phase(
uint64_t *span,
uint64_t *weight_sum) {
- Partition *p;
int r;
assert(context);
@@ -832,9 +827,7 @@ static int context_grow_partitions_on_free_area(Context *context, FreeArea *a) {
/* What? Even still some space left (maybe because there was no preceding partition, or it had a
* size limit), then let's donate it to whoever wants it. */
- if (span > 0) {
- Partition *p;
-
+ if (span > 0)
LIST_FOREACH(partitions, p, context->partitions) {
uint64_t m, xsz;
@@ -857,7 +850,6 @@ static int context_grow_partitions_on_free_area(Context *context, FreeArea *a) {
if (span == 0)
break;
}
- }
/* Yuck, still no one? Then make it padding */
if (span > 0 && a->after) {
@@ -869,7 +861,6 @@ static int context_grow_partitions_on_free_area(Context *context, FreeArea *a) {
}
static int context_grow_partitions(Context *context) {
- Partition *p;
int r;
assert(context);
@@ -903,7 +894,6 @@ static int context_grow_partitions(Context *context) {
static void context_place_partitions(Context *context) {
uint64_t partno = 0;
- Partition *p;
assert(context);
@@ -1404,7 +1394,6 @@ static int context_read_definitions(
_cleanup_strv_free_ char **files = NULL;
Partition *last = NULL;
- char **f;
int r;
assert(context);
@@ -1729,7 +1718,7 @@ static int context_load_partition_table(
n_partitions = fdisk_table_get_nents(t);
for (size_t i = 0; i < n_partitions; i++) {
_cleanup_free_ char *label_copy = NULL;
- Partition *pp, *last = NULL;
+ Partition *last = NULL;
struct fdisk_partition *p;
struct fdisk_parttype *pt;
const char *pts, *ids, *label;
@@ -1910,11 +1899,9 @@ add_initial_free_area:
}
static void context_unload_partition_table(Context *context) {
- Partition *p, *next;
-
assert(context);
- LIST_FOREACH_SAFE(partitions, p, next, context->partitions) {
+ LIST_FOREACH(partitions, p, context->partitions) {
/* Entirely remove partitions that have no configuration */
if (PARTITION_IS_FOREIGN(p)) {
@@ -1999,7 +1986,6 @@ static const char *partition_label(const Partition *p) {
static int context_dump_partitions(Context *context, const char *node) {
_cleanup_(table_unrefp) Table *t = NULL;
uint64_t sum_padding = 0, sum_size = 0;
- Partition *p;
int r;
if ((arg_json_format_flags & JSON_FORMAT_OFF) && context->n_partitions == 0) {
@@ -2189,7 +2175,7 @@ done:
static int context_dump_partition_bar(Context *context, const char *node) {
_cleanup_free_ Partition **bar = NULL;
_cleanup_free_ size_t *start_array = NULL;
- Partition *p, *last = NULL;
+ Partition *last = NULL;
bool z = false;
size_t c, j = 0;
@@ -2300,7 +2286,7 @@ static int context_dump_partition_bar(Context *context, const char *node) {
}
static bool context_changed(const Context *context) {
- Partition *p;
+ assert(context);
LIST_FOREACH(partitions, p, context->partitions) {
if (p->dropped)
@@ -2470,7 +2456,6 @@ static int context_discard_partition(Context *context, Partition *p) {
static int context_discard_gap_after(Context *context, Partition *p) {
uint64_t gap, next = UINT64_MAX;
- Partition *q;
int r;
assert(context);
@@ -2528,7 +2513,6 @@ static int context_discard_gap_after(Context *context, Partition *p) {
}
static int context_wipe_and_discard(Context *context, bool from_scratch) {
- Partition *p;
int r;
assert(context);
@@ -2746,7 +2730,6 @@ static int deactivate_luks(struct crypt_device *cd, const char *node) {
}
static int context_copy_blocks(Context *context) {
- Partition *p;
int whole_fd = -1, r;
assert(context);
@@ -2832,7 +2815,6 @@ static int context_copy_blocks(Context *context) {
}
static int do_copy_files(Partition *p, const char *fs) {
- char **source, **target;
int r;
assert(p);
@@ -2929,7 +2911,6 @@ static int do_copy_files(Partition *p, const char *fs) {
}
static int do_make_directories(Partition *p, const char *fs) {
- char **d;
int r;
assert(p);
@@ -2996,7 +2977,6 @@ static int partition_populate(Partition *p, const char *node) {
}
static int context_mkfs(Context *context) {
- Partition *p;
int fd = -1, r;
assert(context);
@@ -3114,7 +3094,6 @@ static int partition_acquire_uuid(Context *context, Partition *p, sd_id128_t *re
} result;
uint64_t k = 0;
- Partition *q;
int r;
assert(context);
@@ -3198,7 +3177,6 @@ static int partition_acquire_label(Context *context, Partition *p, char **ret) {
for (;;) {
const char *ll = label ?: prefix;
bool retry = false;
- Partition *q;
LIST_FOREACH(partitions, q, context->partitions) {
if (p == q)
@@ -3230,7 +3208,6 @@ static int partition_acquire_label(Context *context, Partition *p, char **ret) {
}
static int context_acquire_partition_uuids_and_labels(Context *context) {
- Partition *p;
int r;
assert(context);
@@ -3337,7 +3314,6 @@ static uint64_t partition_merge_flags(Partition *p) {
}
static int context_mangle_partitions(Context *context) {
- Partition *p;
int r;
assert(context);
@@ -3604,7 +3580,6 @@ static int context_read_seed(Context *context, const char *root) {
}
static int context_factory_reset(Context *context, bool from_scratch) {
- Partition *p;
size_t n = 0;
int r;
@@ -3653,8 +3628,6 @@ static int context_factory_reset(Context *context, bool from_scratch) {
}
static int context_can_factory_reset(Context *context) {
- Partition *p;
-
assert(context);
LIST_FOREACH(partitions, p, context->partitions)
@@ -3969,7 +3942,6 @@ static int context_open_copy_block_paths(
const char *root,
dev_t restrict_devno) {
- Partition *p;
int r;
assert(context);
@@ -4797,7 +4769,6 @@ done:
static int determine_auto_size(Context *c) {
uint64_t sum;
- Partition *p;
assert(c);
diff --git a/src/portable/portable.c b/src/portable/portable.c
index a54e091185..a07a95a229 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -58,7 +58,6 @@ static bool prefix_match(const char *unit, const char *prefix) {
static bool unit_match(const char *unit, char **matches) {
const char *dot;
- char **i;
dot = strrchr(unit, '.');
if (!dot)
@@ -182,7 +181,6 @@ static int extract_now(
_cleanup_close_ int os_release_fd = -1;
_cleanup_free_ char *os_release_path = NULL;
const char *os_release_id;
- char **i;
int r;
/* Extracts the metadata from a directory tree 'where'. Extracts two kinds of information: the /etc/os-release
@@ -535,8 +533,6 @@ static int extract_image_and_extensions(
return r;
if (!strv_isempty(extension_image_paths)) {
- char **p;
-
extension_images = ordered_hashmap_new(&image_hash_ops);
if (!extension_images)
return -ENOMEM;
@@ -1261,8 +1257,6 @@ static int install_image_and_extensions_symlinks(
}
static bool prefix_matches_compatible(char **matches, char **valid_prefixes) {
- char **m;
-
/* Checks if all 'matches' are included in the list of 'valid_prefixes' */
STRV_FOREACH(m, matches)
@@ -1380,7 +1374,6 @@ int portable_attach(
static bool marker_matches_images(const char *marker, const char *name_or_path, char **extension_image_paths) {
_cleanup_strv_free_ char **root_and_extensions = NULL;
- char **image_name_or_path;
const char *a;
int r;
diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c
index 46e60310fc..9fb1cdffec 100644
--- a/src/portable/portablectl.c
+++ b/src/portable/portablectl.c
@@ -90,7 +90,6 @@ static int determine_image(const char *image, bool permit_non_existing, char **r
}
static int attach_extensions_to_message(sd_bus_message *m, char **extensions) {
- char **p;
int r;
assert(m);
@@ -1174,7 +1173,6 @@ static int dump_profiles(void) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_strv_free_ char **l = NULL;
- char **i;
int r;
r = acquire_bus(&bus);
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c
index 5b3ceeff36..96a505f5e1 100644
--- a/src/resolve/resolvectl.c
+++ b/src/resolve/resolvectl.c
@@ -705,7 +705,6 @@ invalid:
static int verb_query(int argc, char **argv, void *userdata) {
sd_bus *bus = userdata;
- char **p;
int q, r = 0;
if (arg_type != 0)
@@ -975,7 +974,6 @@ static int resolve_openpgp(sd_bus *bus, const char *address) {
static int verb_openpgp(int argc, char **argv, void *userdata) {
sd_bus *bus = userdata;
- char **p;
int q, r = 0;
STRV_FOREACH(p, argv + 1) {
@@ -1025,7 +1023,7 @@ static bool service_family_is_valid(const char *s) {
static int verb_tlsa(int argc, char **argv, void *userdata) {
sd_bus *bus = userdata;
- char **p, **args = argv + 1;
+ char **args = argv + 1;
const char *family = "tcp";
int q, r = 0;
@@ -1389,7 +1387,6 @@ static int status_print_strv_ifindex(int ifindex, const char *ifname, char **p)
printf("%s%nGlobal%n%s:", ansi_highlight(), &pos1, &pos2, ansi_normal());
size_t cols = columns(), position = pos2 - pos1 + 2;
- char **i;
STRV_FOREACH(i, p) {
size_t our_len = utf8_console_width(*i); /* This returns -1 on invalid utf-8 (which shouldn't happen).
@@ -2025,7 +2022,6 @@ static int verb_status(int argc, char **argv, void *userdata) {
int r = 0;
if (argc > 1) {
- char **ifname;
bool empty_line = false;
STRV_FOREACH(ifname, argv + 1) {
@@ -2049,7 +2045,6 @@ static int verb_status(int argc, char **argv, void *userdata) {
static int call_dns(sd_bus *bus, char **dns, const BusLocator *locator, sd_bus_error *error, bool extended) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL;
- char **p;
int r;
r = bus_message_new_method_call(bus, &req, locator, extended ? "SetLinkDNSEx" : "SetLinkDNS");
@@ -2157,7 +2152,6 @@ static int verb_dns(int argc, char **argv, void *userdata) {
static int call_domain(sd_bus *bus, char **domain, const BusLocator *locator, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL;
- char **p;
int r;
r = bus_message_new_method_call(bus, &req, locator, "SetLinkDomains");
@@ -2454,7 +2448,6 @@ static int call_nta(sd_bus *bus, char **nta, const BusLocator *locator, sd_bus_
static int verb_nta(int argc, char **argv, void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
- char **p;
int r;
bool clear;
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index 0dada39d6e..4425a2f320 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -863,7 +863,6 @@ static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd
static int append_srv(DnsQuery *q, sd_bus_message *reply, DnsResourceRecord *rr) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *canonical = NULL;
_cleanup_free_ char *normalized = NULL;
- DnsQuery *aux;
int r;
assert(q);
@@ -994,7 +993,6 @@ static int append_srv(DnsQuery *q, sd_bus_message *reply, DnsResourceRecord *rr)
}
static int append_txt(sd_bus_message *reply, DnsResourceRecord *rr) {
- DnsTxtItem *i;
int r;
assert(reply);
@@ -1025,7 +1023,6 @@ static void resolve_service_all_complete(DnsQuery *query) {
DnsQuestion *question;
DnsResourceRecord *rr;
unsigned added = 0;
- DnsQuery *aux;
int r;
assert(q);
@@ -1448,7 +1445,6 @@ static int bus_property_get_dns_servers_internal(
bool extended) {
Manager *m = userdata;
- DnsServer *s;
Link *l;
int r;
@@ -1507,7 +1503,7 @@ static int bus_property_get_fallback_dns_servers_internal(
sd_bus_error *error,
bool extended) {
- DnsServer *s, **f = userdata;
+ DnsServer **f = userdata;
int r;
assert(reply);
@@ -1600,7 +1596,6 @@ static int bus_property_get_domains(
sd_bus_error *error) {
Manager *m = userdata;
- DnsSearchDomain *d;
Link *l;
int r;
@@ -1658,7 +1653,6 @@ static int bus_property_get_cache_statistics(
uint64_t size = 0, hit = 0, miss = 0;
Manager *m = userdata;
- DnsScope *s;
assert(reply);
assert(m);
@@ -1751,7 +1745,6 @@ static int bus_property_get_resolv_conf_mode(
static int bus_method_reset_statistics(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
- DnsScope *s;
assert(message);
assert(m);
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
index 57e0ac3acc..3dce32ed38 100644
--- a/src/resolve/resolved-dns-cache.c
+++ b/src/resolve/resolved-dns-cache.c
@@ -117,7 +117,7 @@ static void dns_cache_item_unlink_and_free(DnsCache *c, DnsCacheItem *i) {
}
static bool dns_cache_remove_by_rr(DnsCache *c, DnsResourceRecord *rr) {
- DnsCacheItem *first, *i;
+ DnsCacheItem *first;
int r;
first = hashmap_get(c->by_key, rr->key);
@@ -135,7 +135,7 @@ static bool dns_cache_remove_by_rr(DnsCache *c, DnsResourceRecord *rr) {
}
static bool dns_cache_remove_by_key(DnsCache *c, DnsResourceKey *key) {
- DnsCacheItem *first, *i, *n;
+ DnsCacheItem *first;
assert(c);
assert(key);
@@ -144,7 +144,7 @@ static bool dns_cache_remove_by_key(DnsCache *c, DnsResourceKey *key) {
if (!first)
return false;
- LIST_FOREACH_SAFE(by_key, i, n, first) {
+ LIST_FOREACH(by_key, i, first) {
prioq_remove(c->by_expiry, i, &i->prioq_idx);
dns_cache_item_free(i);
}
@@ -301,12 +301,10 @@ static int dns_cache_link_item(DnsCache *c, DnsCacheItem *i) {
}
static DnsCacheItem* dns_cache_get(DnsCache *c, DnsResourceRecord *rr) {
- DnsCacheItem *i;
-
assert(c);
assert(rr);
- LIST_FOREACH(by_key, i, hashmap_get(c->by_key, rr->key))
+ LIST_FOREACH(by_key, i, (DnsCacheItem*) hashmap_get(c->by_key, rr->key))
if (i->rr && dns_resource_record_equal(i->rr, rr) > 0)
return i;
@@ -987,7 +985,7 @@ int dns_cache_lookup(
unsigned n = 0;
int r;
bool nxdomain = false;
- DnsCacheItem *j, *first, *nsec = NULL;
+ DnsCacheItem *first, *nsec = NULL;
bool have_authenticated = false, have_non_authenticated = false, have_confidential = false, have_non_confidential = false;
usec_t current = 0;
int found_rcode = -1;
@@ -1223,7 +1221,7 @@ miss:
}
int dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_family, const union in_addr_union *owner_address) {
- DnsCacheItem *i, *first;
+ DnsCacheItem *first;
bool same_owner = true;
assert(cache);
@@ -1266,9 +1264,7 @@ int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p) {
assert(cache);
assert(p);
- HASHMAP_FOREACH(i, cache->by_key) {
- DnsCacheItem *j;
-
+ HASHMAP_FOREACH(i, cache->by_key)
LIST_FOREACH(by_key, j, i) {
if (!j->rr)
continue;
@@ -1299,7 +1295,6 @@ int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p) {
ancount++;
}
- }
DNS_PACKET_HEADER(p)->ancount = htobe16(ancount);
@@ -1315,9 +1310,7 @@ void dns_cache_dump(DnsCache *cache, FILE *f) {
if (!f)
f = stdout;
- HASHMAP_FOREACH(i, cache->by_key) {
- DnsCacheItem *j;
-
+ HASHMAP_FOREACH(i, cache->by_key)
LIST_FOREACH(by_key, j, i) {
fputc('\t', f);
@@ -1341,7 +1334,6 @@ void dns_cache_dump(DnsCache *cache, FILE *f) {
fputc('\n', f);
}
}
- }
}
bool dns_cache_is_empty(DnsCache *cache) {
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index d45f87ff5d..74396f14a8 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -941,15 +941,12 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, const DnsAns
r = dns_packet_append_raw_string(p, NULL, 0, NULL);
if (r < 0)
goto fail;
- } else {
- DnsTxtItem *i;
-
+ } else
LIST_FOREACH(items, i, rr->txt.items) {
r = dns_packet_append_raw_string(p, i->data, i->length, NULL);
if (r < 0)
goto fail;
}
- }
r = 0;
break;
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index c0bb40937a..b7cb21dd49 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -345,8 +345,6 @@ fail:
}
static void dns_query_stop(DnsQuery *q) {
- DnsQueryCandidate *c;
-
assert(q);
event_source_disable(q->timeout_event_source);
@@ -718,8 +716,7 @@ static int dns_query_try_etc_hosts(DnsQuery *q) {
int dns_query_go(DnsQuery *q) {
DnsScopeMatch found = DNS_SCOPE_NO;
- DnsScope *s, *first = NULL;
- DnsQueryCandidate *c;
+ DnsScope *first = NULL;
int r;
assert(q);
@@ -938,8 +935,7 @@ fail:
}
void dns_query_ready(DnsQuery *q) {
-
- DnsQueryCandidate *bad = NULL, *c;
+ DnsQueryCandidate *bad = NULL;
bool pending = false;
assert(q);
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index 720b4c58d7..83140d79f8 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -784,7 +784,6 @@ static char *format_types(Bitmap *types) {
}
static char *format_txt(DnsTxtItem *first) {
- DnsTxtItem *i;
size_t c = 1;
char *p, *s;
@@ -1358,8 +1357,6 @@ void dns_resource_record_hash_func(const DnsResourceRecord *rr, struct siphash *
case DNS_TYPE_TXT:
case DNS_TYPE_SPF: {
- DnsTxtItem *j;
-
LIST_FOREACH(items, j, rr->txt.items) {
siphash24_compress_safe(j->data, j->length, state);
@@ -1813,7 +1810,7 @@ bool dns_txt_item_equal(DnsTxtItem *a, DnsTxtItem *b) {
}
DnsTxtItem *dns_txt_item_copy(DnsTxtItem *first) {
- DnsTxtItem *i, *copy = NULL, *end = NULL;
+ DnsTxtItem *copy = NULL, *end = NULL;
LIST_FOREACH(items, i, first) {
DnsTxtItem *j;
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index 16c5e0094c..96978f8ac3 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -529,7 +529,6 @@ static DnsScopeMatch match_subnet_reverse_lookups(
bool exclude_own) {
union in_addr_union ia;
- LinkAddress *a;
int f, r;
assert(s);
@@ -587,7 +586,6 @@ DnsScopeMatch dns_scope_good_domain(
DnsQuery *q) {
DnsQuestion *question;
- DnsSearchDomain *d;
const char *domain;
uint64_t flags;
int ifindex;
@@ -1082,7 +1080,7 @@ DnsTransaction *dns_scope_find_transaction(
DnsResourceKey *key,
uint64_t query_flags) {
- DnsTransaction *first, *t;
+ DnsTransaction *first;
assert(scope);
assert(key);
@@ -1398,8 +1396,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
_cleanup_set_free_ Set *types = NULL;
- DnsTransaction *t;
- DnsZoneItem *z, *i;
+ DnsZoneItem *z;
unsigned size = 0;
char *service_type;
int r;
@@ -1527,7 +1524,6 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
int dns_scope_add_dnssd_services(DnsScope *scope) {
DnssdService *service;
- DnssdTxtData *txt_data;
int r;
assert(scope);
@@ -1561,7 +1557,6 @@ int dns_scope_add_dnssd_services(DnsScope *scope) {
int dns_scope_remove_dnssd_services(DnsScope *scope) {
_cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
DnssdService *service;
- DnssdTxtData *txt_data;
int r;
assert(scope);
@@ -1586,7 +1581,7 @@ int dns_scope_remove_dnssd_services(DnsScope *scope) {
}
static bool dns_scope_has_route_only_domains(DnsScope *scope) {
- DnsSearchDomain *domain, *first;
+ DnsSearchDomain *first;
bool route_only = false;
assert(scope);
diff --git a/src/resolve/resolved-dns-search-domain.c b/src/resolve/resolved-dns-search-domain.c
index c9f148a2b9..0cc50d6478 100644
--- a/src/resolve/resolved-dns-search-domain.c
+++ b/src/resolve/resolved-dns-search-domain.c
@@ -178,7 +178,6 @@ void dns_search_domain_mark_all(DnsSearchDomain *first) {
}
int dns_search_domain_find(DnsSearchDomain *first, const char *name, DnsSearchDomain **ret) {
- DnsSearchDomain *d;
int r;
assert(name);
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index cd755b13d4..c2b608d383 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -815,8 +815,6 @@ void dns_server_mark_all(DnsServer *server) {
}
DnsServer *dns_server_find(DnsServer *first, int family, const union in_addr_union *in_addr, uint16_t port, int ifindex, const char *name) {
- DnsServer *s;
-
LIST_FOREACH(servers, s, first)
if (s->family == family &&
in_addr_equal(family, &s->address, in_addr) > 0 &&
@@ -992,8 +990,6 @@ void dns_server_reset_features(DnsServer *s) {
}
void dns_server_reset_features_all(DnsServer *s) {
- DnsServer *i;
-
LIST_FOREACH(servers, i, s)
dns_server_reset_features(i);
}
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index f937f9f7b5..52897649d1 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -634,12 +634,9 @@ static int on_stream_complete(DnsStream *s, int error) {
}
}
- if (error != 0) {
- DnsTransaction *t, *n;
-
- LIST_FOREACH_SAFE(transactions_by_stream, t, n, s->transactions)
+ if (error != 0)
+ LIST_FOREACH(transactions_by_stream, t, s->transactions)
on_transaction_stream_error(t, error);
- }
return 0;
}
@@ -1762,7 +1759,6 @@ static int dns_transaction_prepare(DnsTransaction *t, usec_t ts) {
static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
bool add_known_answers = false;
- DnsTransaction *other;
DnsResourceKey *tkey;
_cleanup_set_free_ Set *keys = NULL;
unsigned qdcount;
diff --git a/src/resolve/resolved-dns-trust-anchor.c b/src/resolve/resolved-dns-trust-anchor.c
index b036aa402c..4a6c06d13d 100644
--- a/src/resolve/resolved-dns-trust-anchor.c
+++ b/src/resolve/resolved-dns-trust-anchor.c
@@ -409,7 +409,6 @@ static int dns_trust_anchor_load_files(
int (*loader)(DnsTrustAnchor *d, const char *path, unsigned n, const char *line)) {
_cleanup_strv_free_ char **files = NULL;
- char **f;
int r;
assert(d);
diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c
index 6b3f5f707d..f533f972fc 100644
--- a/src/resolve/resolved-dns-zone.c
+++ b/src/resolve/resolved-dns-zone.c
@@ -78,12 +78,10 @@ void dns_zone_flush(DnsZone *z) {
}
DnsZoneItem* dns_zone_get(DnsZone *z, DnsResourceRecord *rr) {
- DnsZoneItem *i;
-
assert(z);
assert(rr);
- LIST_FOREACH(by_key, i, hashmap_get(z->by_key, rr->key))
+ LIST_FOREACH(by_key, i, (DnsZoneItem*) hashmap_get(z->by_key, rr->key))
if (dns_resource_record_equal(i->rr, rr) > 0)
return i;
@@ -250,21 +248,15 @@ int dns_zone_put(DnsZone *z, DnsScope *s, DnsResourceRecord *rr, bool probe) {
return r;
if (probe) {
- DnsZoneItem *first, *j;
bool established = false;
/* Check if there's already an RR with the same name
* established. If so, it has been probed already, and
* we don't need to probe again. */
- LIST_FIND_HEAD(by_name, i, first);
- LIST_FOREACH(by_name, j, first) {
- if (i == j)
- continue;
-
+ LIST_FOREACH_OTHERS(by_name, j, i)
if (j->state == DNS_ZONE_ITEM_ESTABLISHED)
established = true;
- }
if (established)
i->state = DNS_ZONE_ITEM_ESTABLISHED;
@@ -306,7 +298,7 @@ static int dns_zone_add_authenticated_answer(DnsAnswer *a, DnsZoneItem *i, int i
int dns_zone_lookup(DnsZone *z, DnsResourceKey *key, int ifindex, DnsAnswer **ret_answer, DnsAnswer **ret_soa, bool *ret_tentative) {
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL, *soa = NULL;
unsigned n_answer = 0;
- DnsZoneItem *j, *first;
+ DnsZoneItem *first;
bool tentative = true, need_soa = false;
int r;
@@ -576,7 +568,7 @@ static int dns_zone_item_verify(DnsZoneItem *i) {
}
int dns_zone_check_conflicts(DnsZone *zone, DnsResourceRecord *rr) {
- DnsZoneItem *i, *first;
+ DnsZoneItem *first;
int c = 0;
assert(zone);
@@ -614,7 +606,7 @@ int dns_zone_check_conflicts(DnsZone *zone, DnsResourceRecord *rr) {
}
int dns_zone_verify_conflicts(DnsZone *zone, DnsResourceKey *key) {
- DnsZoneItem *i, *first;
+ DnsZoneItem *first;
int c = 0;
assert(zone);
@@ -639,12 +631,9 @@ void dns_zone_verify_all(DnsZone *zone) {
assert(zone);
- HASHMAP_FOREACH(i, zone->by_key) {
- DnsZoneItem *j;
-
+ HASHMAP_FOREACH(i, zone->by_key)
LIST_FOREACH(by_key, j, i)
dns_zone_item_verify(j);
- }
}
void dns_zone_dump(DnsZone *zone, FILE *f) {
@@ -656,9 +645,7 @@ void dns_zone_dump(DnsZone *zone, FILE *f) {
if (!f)
f = stdout;
- HASHMAP_FOREACH(i, zone->by_key) {
- DnsZoneItem *j;
-
+ HASHMAP_FOREACH(i, zone->by_key)
LIST_FOREACH(by_key, j, i) {
const char *t;
@@ -672,7 +659,6 @@ void dns_zone_dump(DnsZone *zone, FILE *f) {
fputs(t, f);
fputc('\n', f);
}
- }
}
bool dns_zone_is_empty(DnsZone *zone) {
@@ -683,7 +669,7 @@ bool dns_zone_is_empty(DnsZone *zone) {
}
bool dns_zone_contains_name(DnsZone *z, const char *name) {
- DnsZoneItem *i, *first;
+ DnsZoneItem *first;
first = hashmap_get(z->by_name, name);
if (!first)
diff --git a/src/resolve/resolved-dnssd-bus.c b/src/resolve/resolved-dnssd-bus.c
index d908cc64e6..84a51ba2e6 100644
--- a/src/resolve/resolved-dnssd-bus.c
+++ b/src/resolve/resolved-dnssd-bus.c
@@ -12,7 +12,6 @@
int bus_dnssd_method_unregister(sd_bus_message *message, void *userdata, sd_bus_error *error) {
DnssdService *s = userdata;
- DnssdTxtData *txt_data;
Manager *m;
Link *l;
int r;
diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c
index ab2773e4e4..6d77aa817e 100644
--- a/src/resolve/resolved-dnssd.c
+++ b/src/resolve/resolved-dnssd.c
@@ -186,7 +186,6 @@ int dnssd_render_instance_name(DnssdService *s, char **ret_name) {
int dnssd_load(Manager *manager) {
_cleanup_strv_free_ char **files = NULL;
- char **f;
int r;
assert(manager);
@@ -211,7 +210,6 @@ int dnssd_update_rrs(DnssdService *s) {
_cleanup_free_ char *n = NULL;
_cleanup_free_ char *service_name = NULL;
_cleanup_free_ char *full_name = NULL;
- DnssdTxtData *txt_data;
int r;
assert(s);
diff --git a/src/resolve/resolved-etc-hosts.c b/src/resolve/resolved-etc-hosts.c
index a8da6c3d88..72d6b42189 100644
--- a/src/resolve/resolved-etc-hosts.c
+++ b/src/resolve/resolved-etc-hosts.c
@@ -192,7 +192,6 @@ static void strip_localhost(EtcHosts *hosts) {
for (size_t j = 0; j < ELEMENTSOF(local_in_addrs); j++) {
bool all_localhost, in_order;
- char **i;
item = hashmap_get(hosts->by_address, local_in_addrs + j);
if (!item)
@@ -392,8 +391,6 @@ int manager_etc_hosts_lookup(Manager *m, DnsQuestion* q, DnsAnswer **answer) {
}
if (found_ptr) {
- char **n;
-
r = dns_answer_reserve(answer, strv_length(item->names));
if (r < 0)
return r;
diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c
index 8d533d7ecf..881b65bb26 100644
--- a/src/resolve/resolved-link-bus.c
+++ b/src/resolve/resolved-link-bus.c
@@ -51,7 +51,6 @@ static int property_get_dns_internal(
bool extended) {
Link *l = userdata;
- DnsServer *s;
int r;
assert(reply);
@@ -144,7 +143,6 @@ static int property_get_domains(
sd_bus_error *error) {
Link *l = userdata;
- DnsSearchDomain *d;
int r;
assert(reply);
@@ -706,7 +704,6 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
_cleanup_free_ char *j = NULL;
Link *l = userdata;
int r;
- char **i;
assert(message);
assert(l);
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index 9eb0ccefd1..8027eb6f91 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -186,7 +186,6 @@ void link_allocate_scopes(Link *l) {
}
void link_add_rrs(Link *l, bool force_remove) {
- LinkAddress *a;
int r;
LIST_FOREACH(addresses, a, l->addresses)
@@ -284,7 +283,6 @@ static int link_update_dns_server_one(Link *l, const char *str) {
static int link_update_dns_servers(Link *l) {
_cleanup_strv_free_ char **nameservers = NULL;
- char **nameserver;
int r;
assert(l);
@@ -519,7 +517,6 @@ static int link_update_search_domain_one(Link *l, const char *name, bool route_o
static int link_update_search_domains(Link *l) {
_cleanup_strv_free_ char **sdomains = NULL, **rdomains = NULL;
- char **i;
int r, q;
assert(l);
@@ -682,8 +679,6 @@ int link_update(Link *l) {
}
bool link_relevant(Link *l, int family, bool local_multicast) {
- LinkAddress *a;
-
assert(l);
/* A link is relevant for local multicast traffic if it isn't a loopback device, has a link
@@ -717,8 +712,6 @@ bool link_relevant(Link *l, int family, bool local_multicast) {
}
LinkAddress *link_find_address(Link *l, int family, const union in_addr_union *in_addr) {
- LinkAddress *a;
-
assert(l);
if (!IN_SET(family, AF_INET, AF_INET6))
@@ -1223,8 +1216,6 @@ int link_save_user(Link *l) {
fprintf(f, "DEFAULT_ROUTE=%s\n", yes_no(l->default_route));
if (l->dns_servers) {
- DnsServer *server;
-
fputs("SERVERS=", f);
LIST_FOREACH(servers, server, l->dns_servers) {
@@ -1243,8 +1234,6 @@ int link_save_user(Link *l) {
}
if (l->search_domains) {
- DnsSearchDomain *domain;
-
fputs("DOMAINS=", f);
LIST_FOREACH(domains, domain, l->search_domains) {
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 221d0afbdb..916ad3ce03 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -503,9 +503,7 @@ static int manager_sigusr1(sd_event_source *s, const struct signalfd_siginfo *si
_cleanup_free_ char *buffer = NULL;
_cleanup_fclose_ FILE *f = NULL;
Manager *m = userdata;
- DnsServer *server;
size_t size = 0;
- DnsScope *scope;
Link *l;
assert(s);
@@ -1305,8 +1303,6 @@ DnsScope* manager_find_scope(Manager *m, DnsPacket *p) {
}
void manager_verify_all(Manager *m) {
- DnsScope *s;
-
assert(m);
LIST_FOREACH(scopes, s, m->dns_scopes)
@@ -1338,7 +1334,6 @@ int manager_is_own_hostname(Manager *m, const char *name) {
}
int manager_compile_dns_servers(Manager *m, OrderedSet **dns) {
- DnsServer *s;
Link *l;
int r;
@@ -1389,7 +1384,6 @@ int manager_compile_dns_servers(Manager *m, OrderedSet **dns) {
* > 0 or true: return only domains which are for routing only
*/
int manager_compile_search_domains(Manager *m, OrderedSet **domains, int filter_route) {
- DnsSearchDomain *d;
Link *l;
int r;
@@ -1501,8 +1495,6 @@ bool manager_routable(Manager *m) {
}
void manager_flush_caches(Manager *m, int log_level) {
- DnsScope *scope;
-
assert(m);
LIST_FOREACH(scopes, scope, m->dns_scopes)
diff --git a/src/resolve/resolved-mdns.c b/src/resolve/resolved-mdns.c
index 07cd5e9a15..cf855a614c 100644
--- a/src/resolve/resolved-mdns.c
+++ b/src/resolve/resolved-mdns.c
@@ -203,7 +203,6 @@ static bool mdns_should_reply_using_unicast(DnsPacket *p) {
}
static bool sender_on_local_subnet(DnsScope *s, DnsPacket *p) {
- LinkAddress *a;
int r;
/* Check whether the sender is on a local subnet. */
@@ -359,7 +358,6 @@ static int on_mdns_packet(sd_event_source *s, int fd, uint32_t revents, void *us
if (dns_packet_validate_reply(p) > 0) {
DnsResourceRecord *rr;
- DnsTransaction *t;
log_debug("Got mDNS reply packet");
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index bca2f3b812..656afa06ac 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -188,17 +188,14 @@ static int load_state(Context *c, const struct rfkill_event *event) {
}
static void save_state_queue_remove(Context *c, int idx, const char *state_file) {
- struct write_queue_item *item, *tmp;
-
assert(c);
- LIST_FOREACH_SAFE(queue, item, tmp, c->write_queue) {
+ LIST_FOREACH(queue, item, c->write_queue)
if ((state_file && streq(item->file, state_file)) || idx == item->rfkill_idx) {
log_debug("Canceled previous save state of '%s' to %s.", one_zero(item->state), item->file);
LIST_REMOVE(queue, c->write_queue, item);
write_queue_item_free(item);
}
- }
}
static int save_state_queue(Context *c, const struct rfkill_event *event) {
diff --git a/src/run-generator/run-generator.c b/src/run-generator/run-generator.c
index 1cf14e71fc..fb62209704 100644
--- a/src/run-generator/run-generator.c
+++ b/src/run-generator/run-generator.c
@@ -55,7 +55,6 @@ static int parse(const char *key, const char *value, void *data) {
static int generate(void) {
_cleanup_fclose_ FILE *f = NULL;
const char *p;
- char **c;
int r;
if (strv_isempty(arg_commands) && !arg_success_action)
diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c
index 3f286a888b..2bdc529b80 100644
--- a/src/shared/acl-util.c
+++ b/src/shared/acl-util.c
@@ -212,7 +212,6 @@ int acl_search_groups(const char *path, char ***ret_groups) {
int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) {
_cleanup_free_ char **a = NULL, **d = NULL; /* strings are not freed */
_cleanup_strv_free_ char **split = NULL;
- char **entry;
int r = -EINVAL;
_cleanup_(acl_freep) acl_t a_acl = NULL, d_acl = NULL;
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 8147204116..c3b9a6cf60 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -280,7 +280,6 @@ static int boot_entries_find(
size_t *n_entries) {
_cleanup_strv_free_ char **files = NULL;
- char **f;
int r;
assert(root);
@@ -856,8 +855,6 @@ int boot_entries_augment_from_loader(
"auto-reboot-to-firmware-setup", "Reboot Into Firmware Interface",
};
- char **i;
-
assert(config);
/* Let's add the entries discovered by the boot loader to the end of our list, unless they are
@@ -866,7 +863,6 @@ int boot_entries_augment_from_loader(
STRV_FOREACH(i, found_by_loader) {
BootEntry *existing;
_cleanup_free_ char *c = NULL, *t = NULL, *p = NULL;
- char **a, **b;
existing = boot_config_find_entry(config, *i);
if (existing) {
diff --git a/src/shared/bus-polkit.c b/src/shared/bus-polkit.c
index bbe04bea37..4d733a8173 100644
--- a/src/shared/bus-polkit.c
+++ b/src/shared/bus-polkit.c
@@ -36,7 +36,6 @@ static int bus_message_append_strv_key_value(
sd_bus_message *m,
const char **l) {
- const char **k, **v;
int r;
assert(m);
diff --git a/src/shared/bus-unit-procs.c b/src/shared/bus-unit-procs.c
index 87c0334fec..3693fd61dc 100644
--- a/src/shared/bus-unit-procs.c
+++ b/src/shared/bus-unit-procs.c
@@ -199,7 +199,7 @@ static int dump_processes(
}
if (cg->children) {
- struct CGroupInfo **children, *child;
+ struct CGroupInfo **children;
size_t n = 0, i;
/* Order subcgroups by their name */
@@ -217,9 +217,7 @@ static int dump_processes(
const char *name, *special;
bool more;
- child = children[i];
-
- name = strrchr(child->cgroup_path, '/');
+ name = strrchr(children[i]->cgroup_path, '/');
if (!name)
return -EINVAL;
name++;
@@ -238,7 +236,7 @@ static int dump_processes(
if (!pp)
return -ENOMEM;
- r = dump_processes(cgroups, child->cgroup_path, pp, n_columns, flags);
+ r = dump_processes(cgroups, children[i]->cgroup_path, pp, n_columns, flags);
if (r < 0)
return r;
}
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index c35dd286e6..95ef3230b4 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -1675,7 +1675,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
if (streq(field, "RootImageOptions")) {
_cleanup_strv_free_ char **l = NULL;
- char **first = NULL, **second = NULL;
const char *p = eq;
r = sd_bus_message_open_container(m, SD_BUS_TYPE_STRUCT, "sv");
@@ -2024,7 +2023,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
if (r < 0)
return bus_log_create_error(r);
- char **source, **destination;
STRV_FOREACH_PAIR(source, destination, symlinks) {
r = sd_bus_message_append(m, "(sst)", *source, *destination, 0);
if (r < 0)
@@ -2648,7 +2646,6 @@ int bus_append_unit_property_assignment(sd_bus_message *m, UnitType t, const cha
}
int bus_append_unit_property_assignment_many(sd_bus_message *m, UnitType t, char **l) {
- char **i;
int r;
assert(m);
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 4a2b7684bc..a907b67a70 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -490,7 +490,6 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send
int bus_track_add_name_many(sd_bus_track *t, char **l) {
int r = 0;
- char **i;
assert(t);
@@ -562,7 +561,6 @@ int bus_open_system_watch_bind_with_description(sd_bus **ret, const char *descri
int bus_reply_pair_array(sd_bus_message *m, char **l) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
- char **k, **v;
int r;
assert(m);
diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c
index 38a6755d17..a1fabc73c1 100644
--- a/src/shared/cgroup-setup.c
+++ b/src/shared/cgroup-setup.c
@@ -22,7 +22,6 @@
static int cg_any_controller_used_for_v1(void) {
_cleanup_free_ char *buf = NULL;
_cleanup_strv_free_ char **lines = NULL;
- char **line;
int r;
r = read_full_virtual_file("/proc/cgroups", &buf, NULL);
diff --git a/src/shared/condition.c b/src/shared/condition.c
index 68fbbf643a..0a4072c9be 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -89,9 +89,7 @@ Condition* condition_free(Condition *c) {
}
Condition* condition_free_list_type(Condition *head, ConditionType type) {
- Condition *c, *n;
-
- LIST_FOREACH_SAFE(conditions, c, n, head)
+ LIST_FOREACH(conditions, c, head)
if (type < 0 || c->type == type) {
LIST_REMOVE(conditions, head, c);
condition_free(c);
@@ -829,7 +827,6 @@ static int condition_test_first_boot(Condition *c, char **env) {
static int condition_test_environment(Condition *c, char **env) {
bool equal;
- char **i;
assert(c);
assert(c->parameter);
@@ -1171,7 +1168,6 @@ bool condition_test_list(
condition_test_logger_t logger,
void *userdata) {
- Condition *c;
int triggered = -1;
assert(!!logger == !!to_string);
@@ -1234,8 +1230,6 @@ void condition_dump(Condition *c, FILE *f, const char *prefix, condition_to_stri
}
void condition_dump_list(Condition *first, FILE *f, const char *prefix, condition_to_string_t to_string) {
- Condition *c;
-
LIST_FOREACH(conditions, c, first)
condition_dump(c, f, prefix, to_string);
}
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 0ae499814e..23aed96b48 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -486,7 +486,6 @@ static int config_parse_many_files(
_cleanup_hashmap_free_ Hashmap *stats_by_path = NULL;
struct stat st;
- char **fn;
int r;
if (ret_stats_by_path) {
diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c
index 268d910214..024ffb3248 100644
--- a/src/shared/discover-image.c
+++ b/src/shared/discover-image.c
@@ -632,7 +632,6 @@ int image_remove(Image *i) {
_cleanup_(release_lock_file) LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT;
_cleanup_strv_free_ char **settings = NULL;
_cleanup_free_ char *roothash = NULL;
- char **j;
int r;
assert(i);
@@ -695,10 +694,9 @@ int image_remove(Image *i) {
return -EOPNOTSUPP;
}
- STRV_FOREACH(j, settings) {
+ STRV_FOREACH(j, settings)
if (unlink(*j) < 0 && errno != ENOENT)
log_debug_errno(errno, "Failed to unlink %s, ignoring: %m", *j);
- }
if (unlink(roothash) < 0 && errno != ENOENT)
log_debug_errno(errno, "Failed to unlink %s, ignoring: %m", roothash);
@@ -724,7 +722,6 @@ int image_rename(Image *i, const char *new_name) {
_cleanup_free_ char *new_path = NULL, *nn = NULL, *roothash = NULL;
_cleanup_strv_free_ char **settings = NULL;
unsigned file_attr = 0;
- char **j;
int r;
assert(i);
@@ -845,7 +842,6 @@ int image_clone(Image *i, const char *new_name, bool read_only) {
_cleanup_strv_free_ char **settings = NULL;
_cleanup_free_ char *roothash = NULL;
const char *new_path;
- char **j;
int r;
assert(i);
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index 14361a0e5a..8a3da1f650 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -2208,7 +2208,6 @@ static int validate_signature_userspace(const VeritySettings *verity) {
_cleanup_(BIO_freep) BIO *bio = NULL; /* 'bio' must be freed first, 's' second, hence keep this order
* of declaration in place, please */
const unsigned char *d;
- char **i;
int r;
assert(verity);
@@ -3333,8 +3332,6 @@ MountOptions* mount_options_free_all(MountOptions *options) {
}
const char* mount_options_from_designator(const MountOptions *options, PartitionDesignator designator) {
- const MountOptions *m;
-
LIST_FOREACH(mount_options, m, options)
if (designator == m->partition_designator && !isempty(m->options))
return m->options;
diff --git a/src/shared/dropin.c b/src/shared/dropin.c
index eb016eb114..375a3ca600 100644
--- a/src/shared/dropin.c
+++ b/src/shared/dropin.c
@@ -232,7 +232,6 @@ int unit_file_find_dropin_paths(
_cleanup_strv_free_ char **dirs = NULL;
const char *n;
- char **p;
int r;
assert(ret);
diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c
index c1da81e809..d1f50249d0 100644
--- a/src/shared/exec-util.c
+++ b/src/shared/exec-util.c
@@ -91,7 +91,6 @@ static int do_execute(
_cleanup_hashmap_free_free_ Hashmap *pids = NULL;
_cleanup_strv_free_ char **paths = NULL;
- char **path, **e;
int r;
bool parallel_execution;
@@ -254,7 +253,7 @@ int execute_directories(
}
static int gather_environment_generate(int fd, void *arg) {
- char ***env = arg, **x, **y;
+ char ***env = arg;
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **new = NULL;
int r;
@@ -369,7 +368,6 @@ static int gather_environment_consume(int fd, void *arg) {
int exec_command_flags_from_strv(char **ex_opts, ExecCommandFlags *flags) {
ExecCommandFlags ex_flag, ret_flags = 0;
- char **opt;
assert(flags);
diff --git a/src/shared/format-table.c b/src/shared/format-table.c
index 44b736d1fd..d4e66cb6a4 100644
--- a/src/shared/format-table.c
+++ b/src/shared/format-table.c
@@ -1364,7 +1364,6 @@ static char* format_strv_width(char **strv, size_t column_width) {
return NULL;
size_t position = 0;
- char **p;
STRV_FOREACH(p, strv) {
size_t our_len = utf8_console_width(*p); /* This returns -1 on invalid utf-8 (which shouldn't happen).
* If that happens, we'll just print one item per line. */
diff --git a/src/shared/hwdb-util.c b/src/shared/hwdb-util.c
index fe4785f3e5..f98d03f766 100644
--- a/src/shared/hwdb-util.c
+++ b/src/shared/hwdb-util.c
@@ -434,7 +434,7 @@ static int trie_store(struct trie *trie, const char *filename, bool compat) {
static int insert_data(struct trie *trie, char **match_list, char *line, const char *filename,
uint16_t file_priority, uint32_t line_number, bool compat) {
- char *value, **entry;
+ char *value;
assert(line[0] == ' ');
@@ -583,7 +583,6 @@ int hwdb_update(const char *root, const char *hwdb_bin_dir, bool strict, bool co
_cleanup_free_ char *hwdb_bin = NULL;
_cleanup_(trie_freep) struct trie *trie = NULL;
_cleanup_strv_free_ char **files = NULL;
- char **f;
uint16_t file_priority = 1;
int r = 0, err;
diff --git a/src/shared/install.c b/src/shared/install.c
index 4a2698d6a1..53b5418804 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -864,7 +864,6 @@ static int find_symlinks_in_scope(
bool same_name_link_runtime = false, same_name_link_config = false;
bool enabled_in_runtime = false, enabled_at_all = false;
bool ignore_same_name = false;
- char **p;
int r;
assert(lp);
@@ -1421,7 +1420,6 @@ static int unit_file_search(
_cleanup_free_ char *template = NULL;
bool found_unit = false;
int r, result;
- char **p;
assert(info);
assert(lp);
@@ -1810,7 +1808,6 @@ static int install_info_symlink_alias(
UnitFileChange **changes,
size_t *n_changes) {
- char **s;
int r = 0, q;
assert(i);
@@ -1854,7 +1851,6 @@ static int install_info_symlink_wants(
_cleanup_free_ char *buf = NULL;
UnitNameFlags valid_dst_type = UNIT_NAME_ANY;
const char *n;
- char **s;
int r = 0, q;
assert(i);
@@ -2158,7 +2154,6 @@ int unit_file_mask(
_cleanup_(lookup_paths_free) LookupPaths lp = {};
const char *config_path;
- char **i;
int r;
assert(scope >= 0);
@@ -2207,7 +2202,6 @@ int unit_file_unmask(
_cleanup_strv_free_ char **todo = NULL;
const char *config_path;
size_t n_todo = 0;
- char **i;
int r, q;
assert(scope >= 0);
@@ -2299,7 +2293,6 @@ int unit_file_link(
_cleanup_strv_free_ char **todo = NULL;
const char *config_path;
size_t n_todo = 0;
- char **i;
int r, q;
assert(scope >= 0);
@@ -2399,7 +2392,6 @@ int unit_file_revert(
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_strv_free_ char **todo = NULL;
size_t n_todo = 0;
- char **i;
int r, q;
/* Puts a unit file back into vendor state. This means:
@@ -2419,7 +2411,6 @@ int unit_file_revert(
STRV_FOREACH(i, files) {
bool has_vendor = false;
- char **p;
if (!unit_name_is_valid(*i, UNIT_NAME_ANY))
return -EINVAL;
@@ -2503,7 +2494,6 @@ int unit_file_revert(
STRV_FOREACH(i, todo) {
_cleanup_strv_free_ char **fs = NULL;
const char *rp;
- char **j;
(void) get_files_in_directory(*i, &fs);
@@ -2556,7 +2546,6 @@ int unit_file_add_dependency(
_cleanup_(install_context_done) InstallContext c = {};
UnitFileInstallInfo *i, *target_info;
const char *config_path;
- char **f;
int r;
assert(scope >= 0);
@@ -2625,7 +2614,6 @@ int unit_file_enable(
_cleanup_(install_context_done) InstallContext c = {};
const char *config_path;
UnitFileInstallInfo *i;
- char **f;
int r;
assert(scope >= 0);
@@ -2668,7 +2656,6 @@ int unit_file_disable(
_cleanup_(install_context_done) InstallContext c = {};
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
const char *config_path;
- char **i;
int r;
assert(scope >= 0);
@@ -2986,7 +2973,6 @@ static int presets_find_config(UnitFileScope scope, const char *root_dir, char *
static int read_presets(UnitFileScope scope, const char *root_dir, UnitFilePresets *presets) {
_cleanup_(unit_file_presets_freep) UnitFilePresets ps = {};
_cleanup_strv_free_ char **files = NULL;
- char **p;
int r;
assert(scope >= 0);
@@ -3104,7 +3090,6 @@ static int pattern_match_multiple_instances(
if (unit_name_is_valid(unit_name, UNIT_NAME_TEMPLATE)) {
_cleanup_strv_free_ char **out_strv = NULL;
- char **iter;
STRV_FOREACH(iter, rule.instances) {
_cleanup_free_ char *name = NULL;
@@ -3151,11 +3136,10 @@ static int query_presets(const char *name, const UnitFilePresets *presets, char
log_debug("Preset files don't specify rule for %s. Enabling.", name);
return 1;
case PRESET_ENABLE:
- if (instance_name_list && *instance_name_list) {
- char **s;
+ if (instance_name_list && *instance_name_list)
STRV_FOREACH(s, *instance_name_list)
log_debug("Preset files say enable %s.", *s);
- } else
+ else
log_debug("Preset files say enable %s.", name);
return 1;
case PRESET_DISABLE:
@@ -3261,15 +3245,14 @@ static int preset_prepare_one(
return r;
if (r > 0) {
- if (instance_name_list) {
- char **s;
+ if (instance_name_list)
STRV_FOREACH(s, instance_name_list) {
r = install_info_discover_and_check(scope, plus, lp, *s, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS,
&i, changes, n_changes);
if (r < 0)
return r;
}
- } else {
+ else {
r = install_info_discover_and_check(scope, plus, lp, name, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS,
&i, changes, n_changes);
if (r < 0)
@@ -3296,7 +3279,6 @@ int unit_file_preset(
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(unit_file_presets_freep) UnitFilePresets presets = {};
const char *config_path;
- char **i;
int r;
assert(scope >= 0);
@@ -3336,7 +3318,6 @@ int unit_file_preset_all(
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(unit_file_presets_freep) UnitFilePresets presets = {};
const char *config_path = NULL;
- char **i;
int r;
assert(scope >= 0);
@@ -3408,7 +3389,6 @@ int unit_file_get_list(
char **patterns) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
- char **dirname;
int r;
assert(scope >= 0);
diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c
index 5b315413aa..0d72032f53 100644
--- a/src/shared/libcrypt-util.c
+++ b/src/shared/libcrypt-util.c
@@ -197,7 +197,6 @@ int test_password_one(const char *hashed_password, const char *password) {
}
int test_password_many(char **hashed_password, const char *password) {
- char **hpw;
int r;
STRV_FOREACH(hpw, hashed_password) {
diff --git a/src/shared/libfido2-util.c b/src/shared/libfido2-util.c
index 87b88f04d6..8c9fa88e32 100644
--- a/src/shared/libfido2-util.c
+++ b/src/shared/libfido2-util.c
@@ -313,8 +313,6 @@ static int fido2_use_hmac_hash_specific_token(
bool retry_with_up = false, retry_with_pin = false;
if (FLAGS_SET(required, FIDO2ENROLL_PIN)) {
- char **i;
-
/* OK, we need a pin, try with all pins in turn */
if (strv_isempty(pins))
r = FIDO_ERR_PIN_REQUIRED;
@@ -683,7 +681,6 @@ int fido2_generate_hmac_hash(
for (;;) {
_cleanup_(strv_free_erasep) char **pin = NULL;
- char **i;
r = ask_password_auto("Please enter security token PIN:", askpw_icon_name, NULL, "fido2-pin", "fido2-pin", USEC_INFINITY, 0, &pin);
if (r < 0)
diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c
index 7917968497..eb6dac32e1 100644
--- a/src/shared/mount-setup.c
+++ b/src/shared/mount-setup.c
@@ -247,8 +247,6 @@ static const char *join_with(const char *controller) {
NULL
};
- const char *const *x, *const *y;
-
assert(controller);
/* This will lookup which controller to mount another controller with. Input is a controller name, and output
@@ -436,7 +434,6 @@ static int relabel_cgroup_filesystems(void) {
static int relabel_extra(void) {
_cleanup_strv_free_ char **files = NULL;
- char **file;
int r, c = 0;
/* Support for relabelling additional files or directories after loading the policy. For this, code in the
diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c
index ae1f2f0b80..694c0383f5 100644
--- a/src/shared/mount-util.c
+++ b/src/shared/mount-util.c
@@ -274,7 +274,6 @@ int bind_remount_recursive_with_mountinfo(
* we shall operate on. */
if (!path_equal(path, prefix)) {
bool deny_listed = false;
- char **i;
STRV_FOREACH(i, deny_list) {
if (path_equal(*i, prefix))
diff --git a/src/shared/net-condition.c b/src/shared/net-condition.c
index b96cb60064..15e3d94ded 100644
--- a/src/shared/net-condition.c
+++ b/src/shared/net-condition.c
@@ -48,7 +48,6 @@ bool net_match_is_empty(const NetMatch *match) {
}
static bool net_condition_test_strv(char * const *patterns, const char *string) {
- char * const *p;
bool match = false, has_positive_rule = false;
if (strv_isempty(patterns))
@@ -79,7 +78,6 @@ static bool net_condition_test_ifname(char * const *patterns, const char *ifname
if (net_condition_test_strv(patterns, ifname))
return true;
- char * const *p;
STRV_FOREACH(p, alternative_names)
if (net_condition_test_strv(patterns, *p))
return true;
@@ -88,8 +86,6 @@ static bool net_condition_test_ifname(char * const *patterns, const char *ifname
}
static int net_condition_test_property(char * const *match_property, sd_device *device) {
- char * const *p;
-
if (strv_isempty(match_property))
return true;
diff --git a/src/shared/nscd-flush.c b/src/shared/nscd-flush.c
index 0655030633..95dfe24b22 100644
--- a/src/shared/nscd-flush.c
+++ b/src/shared/nscd-flush.c
@@ -132,7 +132,6 @@ static int nscd_flush_cache_one(const char *database, usec_t end) {
int nscd_flush_cache(char **databases) {
usec_t end;
int r = 0;
- char **i;
/* Tries to invalidate the specified database in nscd. We do this carefully, with a 5s timeout, so that we
* don't block indefinitely on another service. */
diff --git a/src/shared/pkcs11-util.c b/src/shared/pkcs11-util.c
index b01b9983c2..80feeb1fae 100644
--- a/src/shared/pkcs11-util.c
+++ b/src/shared/pkcs11-util.c
@@ -276,7 +276,6 @@ int pkcs11_token_login(
for (unsigned tries = 0; tries < 3; tries++) {
_cleanup_strv_free_erase_ char **passwords = NULL;
_cleanup_(erase_and_freep) char *envpin = NULL;
- char **i;
r = getenv_steal_erase("PIN", &envpin);
if (r < 0)
diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c
index 26daec3450..98619c25d4 100644
--- a/src/shared/pretty-print.c
+++ b/src/shared/pretty-print.c
@@ -168,7 +168,6 @@ static int cat_file(const char *filename, bool newline) {
}
int cat_files(const char *file, char **dropins, CatFlags flags) {
- char **path;
int r;
if (file) {
@@ -284,10 +283,9 @@ static int guess_type(const char **name, char ***prefixes, bool *is_collection,
int conf_files_cat(const char *root, const char *name) {
_cleanup_strv_free_ char **dirs = NULL, **files = NULL;
_cleanup_free_ char *path = NULL;
- char **prefix, **prefixes = NULL; /* explicit initialization to appease gcc */
+ char **prefixes = NULL; /* explicit initialization to appease gcc */
bool is_collection;
const char *extension;
- char **t;
int r;
r = guess_type(&name, &prefixes, &is_collection, &extension);
diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c
index 32bd8aa73b..e597a156cf 100644
--- a/src/shared/seccomp-util.c
+++ b/src/shared/seccomp-util.c
@@ -1837,7 +1837,6 @@ int seccomp_restrict_archs(Set *archs) {
int parse_syscall_archs(char **l, Set **ret_archs) {
_cleanup_set_free_ Set *archs = NULL;
- char **s;
int r;
assert(l);
diff --git a/src/shared/serialize.c b/src/shared/serialize.c
index 47996b9ead..cd48286355 100644
--- a/src/shared/serialize.c
+++ b/src/shared/serialize.c
@@ -117,7 +117,6 @@ int serialize_dual_timestamp(FILE *f, const char *name, const dual_timestamp *t)
int serialize_strv(FILE *f, const char *key, char **l) {
int ret = 0, r;
- char **i;
/* Returns the first error, or positive if anything was serialized, 0 otherwise. */
diff --git a/src/shared/tests.c b/src/shared/tests.c
index b00006b41a..e0a1409e3a 100644
--- a/src/shared/tests.c
+++ b/src/shared/tests.c
@@ -49,7 +49,6 @@ static void load_testdata_env(void) {
_cleanup_free_ char *s = NULL;
_cleanup_free_ char *envpath = NULL;
_cleanup_strv_free_ char **pairs = NULL;
- char **k, **v;
if (called)
return;
diff --git a/src/shared/user-record-show.c b/src/shared/user-record-show.c
index 7c2751f3a7..95895a8e45 100644
--- a/src/shared/user-record-show.c
+++ b/src/shared/user-record-show.c
@@ -143,7 +143,6 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) {
break;
}
bool has_valid_passwords = false;
- char **p;
STRV_FOREACH(p, hr->hashed_password)
if (!hashed_password_is_locked_or_invalid(*p)) {
has_valid_passwords = true;
@@ -240,15 +239,12 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) {
if (hr->preferred_language)
printf(" Language: %s\n", hr->preferred_language);
- if (!strv_isempty(hr->environment)) {
- char **i;
-
+ if (!strv_isempty(hr->environment))
STRV_FOREACH(i, hr->environment) {
printf(i == hr->environment ?
" Environment: %s\n" :
" %s\n", *i);
}
- }
if (hr->locked >= 0)
printf(" Locked: %s\n", yes_no(hr->locked));
@@ -478,14 +474,11 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) {
if (!strv_isempty(hr->ssh_authorized_keys))
printf("SSH Pub. Key: %zu\n", strv_length(hr->ssh_authorized_keys));
- if (!strv_isempty(hr->pkcs11_token_uri)) {
- char **i;
-
+ if (!strv_isempty(hr->pkcs11_token_uri))
STRV_FOREACH(i, hr->pkcs11_token_uri)
printf(i == hr->pkcs11_token_uri ?
"PKCS11 Token: %s\n" :
" %s\n", *i);
- }
if (hr->n_fido2_hmac_credential > 0)
printf(" FIDO2 Token: %zu\n", hr->n_fido2_hmac_credential);
@@ -558,7 +551,6 @@ void group_record_show(GroupRecord *gr, bool show_full_user_info) {
}
} else {
const char *prefix = " Members:";
- char **i;
STRV_FOREACH(i, gr->members) {
printf("%s %s\n", prefix, *i);
@@ -568,7 +560,6 @@ void group_record_show(GroupRecord *gr, bool show_full_user_info) {
if (!strv_isempty(gr->administrators)) {
const char *prefix = " Admins:";
- char **i;
STRV_FOREACH(i, gr->administrators) {
printf("%s %s\n", prefix, *i);
diff --git a/src/shared/varlink.c b/src/shared/varlink.c
index 04e69a601e..bae2031d0c 100644
--- a/src/shared/varlink.c
+++ b/src/shared/varlink.c
@@ -2347,7 +2347,6 @@ int varlink_server_shutdown(VarlinkServer *s) {
}
int varlink_server_attach_event(VarlinkServer *s, sd_event *e, int64_t priority) {
- VarlinkServerSocket *ss;
int r;
assert_return(s, -EINVAL);
@@ -2382,8 +2381,6 @@ fail:
}
int varlink_server_detach_event(VarlinkServer *s) {
- VarlinkServerSocket *ss;
-
assert_return(s, -EINVAL);
LIST_FOREACH(sockets, ss, s->sockets)
diff --git a/src/shutdown/test-umount.c b/src/shutdown/test-umount.c
index 56fcff05b1..c92105b62b 100644
--- a/src/shutdown/test-umount.c
+++ b/src/shutdown/test-umount.c
@@ -12,7 +12,6 @@
static void test_mount_points_list_one(const char *fname) {
_cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head);
_cleanup_free_ char *testdata_fname = NULL;
- MountPoint *m;
log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/self/mountinfo");
@@ -43,7 +42,6 @@ TEST(mount_points_list) {
static void test_swap_list_one(const char *fname) {
_cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head);
_cleanup_free_ char *testdata_fname = NULL;
- MountPoint *m;
int r;
log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/swaps");
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c
index ed45ea9edb..3e9e241499 100644
--- a/src/shutdown/umount.c
+++ b/src/shutdown/umount.c
@@ -589,7 +589,6 @@ static int umount_with_timeout(MountPoint *m, int umount_log_level) {
/* This includes remounting readonly, which changes the kernel mount options. Therefore the list passed to
* this function is invalidated, and should not be reused. */
static int mount_points_list_umount(MountPoint **head, bool *changed, int umount_log_level) {
- MountPoint *m;
int n_failed = 0;
assert(head);
@@ -635,13 +634,12 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, int umount
}
static int swap_points_list_off(MountPoint **head, bool *changed) {
- MountPoint *m, *n;
int n_failed = 0;
assert(head);
assert(changed);
- LIST_FOREACH_SAFE(mount_point, m, n, *head) {
+ LIST_FOREACH(mount_point, m, *head) {
log_info("Deactivating swap %s.", m->path);
if (swapoff(m->path) < 0) {
log_warning_errno(errno, "Could not deactivate swap %s: %m", m->path);
@@ -657,7 +655,6 @@ static int swap_points_list_off(MountPoint **head, bool *changed) {
}
static int loopback_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
- MountPoint *m, *n;
int n_failed = 0, r;
dev_t rootdev = 0;
@@ -666,7 +663,7 @@ static int loopback_points_list_detach(MountPoint **head, bool *changed, int umo
(void) get_block_device("/", &rootdev);
- LIST_FOREACH_SAFE(mount_point, m, n, *head) {
+ LIST_FOREACH(mount_point, m, *head) {
if (major(rootdev) != 0 && rootdev == m->devnum) {
n_failed++;
continue;
@@ -689,7 +686,6 @@ static int loopback_points_list_detach(MountPoint **head, bool *changed, int umo
}
static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
- MountPoint *m, *n;
int n_failed = 0, r;
dev_t rootdev = 0;
@@ -698,7 +694,7 @@ static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_lo
(void) get_block_device("/", &rootdev);
- LIST_FOREACH_SAFE(mount_point, m, n, *head) {
+ LIST_FOREACH(mount_point, m, *head) {
if (major(rootdev) != 0 && rootdev == m->devnum) {
n_failed ++;
continue;
@@ -720,7 +716,6 @@ static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_lo
}
static int md_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
- MountPoint *m, *n;
int n_failed = 0, r;
dev_t rootdev = 0;
@@ -729,7 +724,7 @@ static int md_points_list_detach(MountPoint **head, bool *changed, int umount_lo
(void) get_block_device("/", &rootdev);
- LIST_FOREACH_SAFE(mount_point, m, n, *head) {
+ LIST_FOREACH(mount_point, m, *head) {
if (major(rootdev) != 0 && rootdev == m->devnum) {
n_failed ++;
continue;
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 7064f3a905..f108529bbd 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -85,7 +85,6 @@ static int write_hibernate_location_info(const HibernateLocation *hibernate_loca
static int write_mode(char **modes) {
int r = 0;
- char **mode;
STRV_FOREACH(mode, modes) {
int k;
@@ -103,7 +102,6 @@ static int write_mode(char **modes) {
}
static int write_state(FILE **f, char **states) {
- char **state;
int r = 0;
assert(f);
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 408ac3b8be..24c8baab03 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -51,8 +51,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Option*, option_free);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(option_hash_ops, char, string_hash_func, string_compare_func, Option, option_free);
static bool test_prefix(const char *p) {
- char **i;
-
if (strv_isempty(arg_prefixes))
return true;
@@ -131,7 +129,6 @@ static int apply_all(OrderedHashmap *sysctl_options) {
if (string_is_glob(option->key)) {
_cleanup_strv_free_ char **paths = NULL;
_cleanup_free_ char *pattern = NULL;
- char **s;
pattern = path_join("/proc/sys", option->key);
if (!pattern)
@@ -403,7 +400,6 @@ static int run(int argc, char *argv[]) {
}
} else {
_cleanup_strv_free_ char **files = NULL;
- char **f;
r = conf_files_list_strv(&files, ".conf", NULL, 0, (const char**) CONF_PATHS_STRV("sysctl.d"));
if (r < 0)
diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c
index 60789e0f2c..6d4df0afd2 100644
--- a/src/sysext/sysext.c
+++ b/src/sysext/sysext.c
@@ -124,7 +124,6 @@ static int unmerge_hierarchy(const char *p) {
static int unmerge(void) {
int r, ret = 0;
- char **p;
STRV_FOREACH(p, arg_hierarchies) {
_cleanup_free_ char *resolved = NULL;
@@ -161,7 +160,6 @@ static int verb_unmerge(int argc, char **argv, void *userdata) {
static int verb_status(int argc, char **argv, void *userdata) {
_cleanup_(table_unrefp) Table *t = NULL;
int r, ret = 0;
- char **p;
t = table_new("hierarchy", "extensions", "since");
if (!t)
@@ -245,7 +243,6 @@ static int mount_overlayfs(
_cleanup_free_ char *options = NULL;
bool separator = false;
- char **l;
int r;
assert(where);
@@ -285,7 +282,6 @@ static int merge_hierarchy(
_cleanup_free_ char *resolved_hierarchy = NULL, *f = NULL, *buf = NULL;
_cleanup_strv_free_ char **layers = NULL;
struct stat st;
- char **p;
int r;
assert(hierarchy);
@@ -453,7 +449,6 @@ static int merge_subprocess(Hashmap *images, const char *workspace) {
size_t n_extensions = 0;
unsigned n_ignored = 0;
Image *img;
- char **h;
int r;
/* Mark the whole of /run as MS_SLAVE, so that we can mount stuff below it that doesn't show up on
@@ -764,7 +759,6 @@ static int image_discover_and_read_metadata(Hashmap **ret_images) {
static int verb_merge(int argc, char **argv, void *userdata) {
_cleanup_(hashmap_freep) Hashmap *images = NULL;
- char **p;
int r;
if (!have_effective_cap(CAP_SYS_ADMIN))
diff --git a/src/systemctl/systemctl-cancel-job.c b/src/systemctl/systemctl-cancel-job.c
index 76976010ad..3cf1369463 100644
--- a/src/systemctl/systemctl-cancel-job.c
+++ b/src/systemctl/systemctl-cancel-job.c
@@ -10,7 +10,6 @@
int verb_cancel(int argc, char *argv[], void *userdata) {
sd_bus *bus;
- char **name;
int r;
if (argc <= 1) /* Shortcut to trivial_method() if no argument is given */
diff --git a/src/systemctl/systemctl-clean-or-freeze.c b/src/systemctl/systemctl-clean-or-freeze.c
index 7ed41e8e0a..5c15a9fba0 100644
--- a/src/systemctl/systemctl-clean-or-freeze.c
+++ b/src/systemctl/systemctl-clean-or-freeze.c
@@ -11,7 +11,6 @@ int verb_clean_or_freeze(int argc, char *argv[], void *userdata) {
_cleanup_(bus_wait_for_units_freep) BusWaitForUnits *w = NULL;
_cleanup_strv_free_ char **names = NULL;
int r, ret = EXIT_SUCCESS;
- char **name;
const char *method;
sd_bus *bus;
diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c
index f5123e80c1..e18a32190f 100644
--- a/src/systemctl/systemctl-edit.c
+++ b/src/systemctl/systemctl-edit.c
@@ -26,7 +26,6 @@ int verb_cat(int argc, char *argv[], void *userdata) {
_cleanup_(hashmap_freep) Hashmap *cached_name_map = NULL, *cached_id_map = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_strv_free_ char **names = NULL;
- char **name;
sd_bus *bus;
bool first = true;
int r, rc = 0;
@@ -145,7 +144,6 @@ static int create_edit_temp_file(const char *new_path, const char *original_path
} else if (original_unit_paths) {
_cleanup_free_ char *new_contents = NULL;
_cleanup_fclose_ FILE *f = NULL;
- char **path;
r = mac_selinux_create_file_prepare(new_path, S_IFREG);
if (r < 0)
@@ -318,7 +316,7 @@ static int run_editor(char **paths) {
if (r < 0)
return r;
if (r == 0) {
- char **editor_args = NULL, **tmp_path, **original_path;
+ char **editor_args = NULL;
size_t n_editor_args = 0, i = 1, argc;
const char **args, *editor, *p;
@@ -379,7 +377,6 @@ static int run_editor(char **paths) {
static int find_paths_to_edit(sd_bus *bus, char **names, char ***paths) {
_cleanup_(hashmap_freep) Hashmap *cached_name_map = NULL, *cached_id_map = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
- char **name;
int r;
assert(names);
@@ -501,7 +498,6 @@ int verb_edit(int argc, char *argv[], void *userdata) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_strv_free_ char **names = NULL;
_cleanup_strv_free_ char **paths = NULL;
- char **original, **tmp;
sd_bus *bus;
int r;
diff --git a/src/systemctl/systemctl-enable.c b/src/systemctl/systemctl-enable.c
index 9fb935cc5e..b18c516b26 100644
--- a/src/systemctl/systemctl-enable.c
+++ b/src/systemctl/systemctl-enable.c
@@ -12,7 +12,6 @@
#include "systemctl.h"
static int normalize_filenames(char **names) {
- char **u;
int r;
STRV_FOREACH(u, names)
@@ -40,7 +39,6 @@ static int normalize_filenames(char **names) {
}
static int normalize_names(char **names) {
- char **u;
bool was_path = false;
STRV_FOREACH(u, names) {
@@ -141,7 +139,6 @@ int verb_enable(int argc, char *argv[], void *userdata) {
sd_bus *bus;
if (STR_IN_SET(verb, "mask", "unmask")) {
- char **name;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
r = lookup_paths_init(&lp, arg_scope, 0, arg_root);
diff --git a/src/systemctl/systemctl-is-active.c b/src/systemctl/systemctl-is-active.c
index e1acf79702..7218e90015 100644
--- a/src/systemctl/systemctl-is-active.c
+++ b/src/systemctl/systemctl-is-active.c
@@ -13,7 +13,6 @@ static int check_unit_generic(int code, const UnitActiveState good_states[], int
_cleanup_strv_free_ char **names = NULL;
UnitActiveState active_state;
sd_bus *bus;
- char **name;
int r;
bool found = false;
diff --git a/src/systemctl/systemctl-is-enabled.c b/src/systemctl/systemctl-is-enabled.c
index 3b4fbd9c1f..c280d55d69 100644
--- a/src/systemctl/systemctl-is-enabled.c
+++ b/src/systemctl/systemctl-is-enabled.c
@@ -59,7 +59,6 @@ static int show_installation_targets(sd_bus *bus, const char *name) {
int verb_is_enabled(int argc, char *argv[], void *userdata) {
_cleanup_strv_free_ char **names = NULL;
bool enabled;
- char **name;
int r;
r = mangle_names("to check", strv_skip(argv, 1), &names);
diff --git a/src/systemctl/systemctl-kill.c b/src/systemctl/systemctl-kill.c
index 0346be98a6..1a8b4a3eda 100644
--- a/src/systemctl/systemctl-kill.c
+++ b/src/systemctl/systemctl-kill.c
@@ -8,7 +8,7 @@
int verb_kill(int argc, char *argv[], void *userdata) {
_cleanup_strv_free_ char **names = NULL;
- char *kill_who = NULL, **name;
+ char *kill_who = NULL;
sd_bus *bus;
int r, q;
diff --git a/src/systemctl/systemctl-list-dependencies.c b/src/systemctl/systemctl-list-dependencies.c
index 0a45a017e6..86d1c5b7c2 100644
--- a/src/systemctl/systemctl-list-dependencies.c
+++ b/src/systemctl/systemctl-list-dependencies.c
@@ -63,7 +63,6 @@ static int list_dependencies_one(
unsigned branches) {
_cleanup_strv_free_ char **deps = NULL;
- char **c;
int r;
assert(bus);
@@ -138,7 +137,7 @@ static int list_dependencies_one(
int verb_list_dependencies(int argc, char *argv[], void *userdata) {
_cleanup_strv_free_ char **units = NULL, **done = NULL;
- char **u, **patterns;
+ char **patterns;
sd_bus *bus;
int r;
diff --git a/src/systemctl/systemctl-list-machines.c b/src/systemctl/systemctl-list-machines.c
index 1ebfb019ec..0abafa7bf0 100644
--- a/src/systemctl/systemctl-list-machines.c
+++ b/src/systemctl/systemctl-list-machines.c
@@ -93,7 +93,6 @@ static int get_machine_list(
struct machine_info *machine_infos = NULL;
_cleanup_strv_free_ char **m = NULL;
_cleanup_free_ char *hn = NULL;
- char **i;
int c = 0, r;
hn = gethostname_malloc();
diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c
index fdf524385f..4f3d534bc8 100644
--- a/src/systemctl/systemctl-list-units.c
+++ b/src/systemctl/systemctl-list-units.c
@@ -49,7 +49,6 @@ static int get_unit_list_recursive(
if (arg_recursive) {
_cleanup_strv_free_ char **machines = NULL;
- char **i;
r = sd_get_machine_names(&machines);
if (r < 0)
diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c
index 897d936aba..40521b8595 100644
--- a/src/systemctl/systemctl-logind.c
+++ b/src/systemctl/systemctl-logind.c
@@ -112,7 +112,6 @@ int logind_check_inhibitors(enum action a) {
uint32_t uid, pid;
sd_bus *bus;
unsigned c = 0;
- char **s;
int r;
if (arg_check_inhibitors == 0 || arg_force > 0)
@@ -399,7 +398,6 @@ int help_boot_loader_entry(void) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_strv_free_ char **l = NULL;
sd_bus *bus;
- char **i;
int r;
r = acquire_bus(BUS_FULL, &bus);
diff --git a/src/systemctl/systemctl-reset-failed.c b/src/systemctl/systemctl-reset-failed.c
index abc8aadf63..1ca05339dc 100644
--- a/src/systemctl/systemctl-reset-failed.c
+++ b/src/systemctl/systemctl-reset-failed.c
@@ -10,7 +10,6 @@
int verb_reset_failed(int argc, char *argv[], void *userdata) {
_cleanup_strv_free_ char **names = NULL;
sd_bus *bus;
- char **name;
int r, q;
if (argc <= 1) /* Shortcut to trivial_method() if no argument is given */
diff --git a/src/systemctl/systemctl-set-environment.c b/src/systemctl/systemctl-set-environment.c
index 61540e03e2..55d1160510 100644
--- a/src/systemctl/systemctl-set-environment.c
+++ b/src/systemctl/systemctl-set-environment.c
@@ -171,7 +171,6 @@ int verb_import_environment(int argc, char *argv[], void *userdata) {
strv_env_clean_with_callback(copy, invalid_callback, NULL);
- char **e;
STRV_FOREACH(e, copy)
if (string_has_cc(*e, NULL))
log_notice("Environment variable $%.*s contains control characters, importing anyway.",
@@ -180,8 +179,6 @@ int verb_import_environment(int argc, char *argv[], void *userdata) {
r = sd_bus_message_append_strv(m, copy);
} else {
- char **a, **b;
-
r = sd_bus_message_open_container(m, 'a', "s");
if (r < 0)
return bus_log_create_error(r);
diff --git a/src/systemctl/systemctl-set-property.c b/src/systemctl/systemctl-set-property.c
index 24182d4fff..b8d702ac0e 100644
--- a/src/systemctl/systemctl-set-property.c
+++ b/src/systemctl/systemctl-set-property.c
@@ -46,7 +46,6 @@ static int set_property_one(sd_bus *bus, const char *name, char **properties) {
int verb_set_property(int argc, char *argv[], void *userdata) {
sd_bus *bus;
_cleanup_strv_free_ char **names = NULL;
- char **name;
int r, k;
r = acquire_bus(BUS_MANAGER, &bus);
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index c1298ce758..0f3099b7b5 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -305,10 +305,8 @@ static void print_status_info(
const char *active_on, *active_off, *on, *off, *ss, *fs;
_cleanup_free_ char *formatted_path = NULL;
- ExecStatusInfo *p;
usec_t timestamp;
const char *path;
- char **t, **t2;
int r;
assert(i);
@@ -367,7 +365,6 @@ static void print_status_info(
if (!strv_isempty(i->dropin_paths)) {
_cleanup_free_ char *dir = NULL;
bool last = false;
- char ** dropin;
STRV_FOREACH(dropin, i->dropin_paths) {
_cleanup_free_ char *dropin_formatted = NULL;
@@ -488,7 +485,6 @@ static void print_status_info(
}
if (!i->condition_result && i->condition_timestamp > 0) {
- UnitCondition *c;
int n = 0;
printf(" Condition: start %scondition failed%s at %s; %s\n",
@@ -774,8 +770,6 @@ static void print_status_info(
}
static void show_unit_help(UnitStatusInfo *i) {
- char **p;
-
assert(i);
if (!i->documentation) {
@@ -1078,7 +1072,6 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
if (FLAGS_SET(flags, BUS_PRINT_PROPERTY_SHOW_EMPTY) || allow_list || !strv_isempty(l)) {
bool first = true;
- char **i;
if (!FLAGS_SET(flags, BUS_PRINT_PROPERTY_ONLY_VALUE)) {
fputs(name, stdout);
@@ -1970,7 +1963,6 @@ static int show_one(
.io_read_bytes = UINT64_MAX,
.io_write_bytes = UINT64_MAX,
};
- char **pp;
int r;
assert(path);
@@ -2194,7 +2186,6 @@ int verb_show(int argc, char *argv[], void *userdata) {
ret = show_all(bus, &new_line, &ellipsized);
} else {
_cleanup_free_ char **patterns = NULL;
- char **name;
STRV_FOREACH(name, strv_skip(argv, 1)) {
_cleanup_free_ char *path = NULL, *unit = NULL;
diff --git a/src/systemctl/systemctl-start-unit.c b/src/systemctl/systemctl-start-unit.c
index 590ee17194..9b215c2e8a 100644
--- a/src/systemctl/systemctl-start-unit.c
+++ b/src/systemctl/systemctl-start-unit.c
@@ -199,16 +199,13 @@ static int enqueue_marked_jobs(
if (r < 0)
return bus_log_parse_error(r);
- if (w) {
- char **path;
-
+ if (w)
STRV_FOREACH(path, paths) {
log_debug("Adding %s to the set", *path);
r = bus_wait_for_jobs_add(w, *path);
if (r < 0)
return log_error_errno(r, "Failed to watch job %s: %m", *path);
}
- }
return 0;
}
@@ -269,7 +266,6 @@ int verb_start(int argc, char *argv[], void *userdata) {
_cleanup_strv_free_ char **names = NULL;
int r, ret = EXIT_SUCCESS;
sd_bus *bus;
- char **name;
if (arg_wait && !STR_IN_SET(argv[0], "start", "restart"))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c
index 8afd4b222a..0334b8c1fc 100644
--- a/src/systemctl/systemctl-util.c
+++ b/src/systemctl/systemctl-util.c
@@ -234,7 +234,6 @@ int get_unit_list(
int expand_unit_names(sd_bus *bus, char **names, const char* suffix, char ***ret, bool *ret_expanded) {
_cleanup_strv_free_ char **mangled = NULL, **globs = NULL;
- char **name;
int r;
assert(bus);
@@ -294,7 +293,6 @@ int check_triggering_units(sd_bus *bus, const char *unit) {
_cleanup_strv_free_ char **triggered_by = NULL;
bool print_warning_label = true;
UnitActiveState active_state;
- char **i;
int r;
r = unit_name_mangle(unit, 0, &n);
@@ -386,8 +384,6 @@ void warn_unit_file_changed(const char *unit) {
}
int unit_file_find_path(LookupPaths *lp, const char *unit_name, char **ret_unit_path) {
- char **p;
-
assert(lp);
assert(unit_name);
@@ -666,7 +662,6 @@ int unit_exists(LookupPaths *lp, const char *unit) {
int append_unit_dependencies(sd_bus *bus, char **names, char ***ret) {
_cleanup_strv_free_ char **with_deps = NULL;
- char **name;
assert(bus);
assert(ret);
@@ -860,7 +855,7 @@ UnitFileFlags unit_file_flags_from_args(void) {
int mangle_names(const char *operation, char **original_names, char ***ret_mangled_names) {
_cleanup_strv_free_ char **l = NULL;
- char **i, **name;
+ char **i;
int r;
assert(ret_mangled_names);
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 4962bf7233..59b76c8620 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -312,7 +312,6 @@ static int putgrent_with_members(const struct group *gr, FILE *group) {
if (a) {
_cleanup_strv_free_ char **l = NULL;
bool added = false;
- char **i;
l = strv_copy(gr->gr_mem);
if (!l)
@@ -357,7 +356,6 @@ static int putsgent_with_members(const struct sgrp *sg, FILE *gshadow) {
if (a) {
_cleanup_strv_free_ char **l = NULL;
bool added = false;
- char **i;
l = strv_copy(sg->sg_mem);
if (!l)
@@ -1406,8 +1404,6 @@ static int add_implicit(void) {
/* Implicitly create additional users and groups, if they were listed in "m" lines */
ORDERED_HASHMAP_FOREACH_KEY(l, g, members) {
- char **m;
-
STRV_FOREACH(m, l)
if (!ordered_hashmap_get(users, *m)) {
_cleanup_(item_freep) Item *j = NULL;
@@ -1977,7 +1973,6 @@ static int parse_argv(int argc, char *argv[]) {
}
static int parse_arguments(char **args) {
- char **arg;
unsigned pos = 1;
int r;
@@ -1999,7 +1994,6 @@ static int parse_arguments(char **args) {
static int read_config_files(char **args) {
_cleanup_strv_free_ char **files = NULL;
_cleanup_free_ char *p = NULL;
- char **f;
int r;
r = conf_files_list_with_replacement(arg_root, CONF_PATHS_STRV("sysusers.d"), arg_replace, &files, &p);
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index e9976540b5..a81df6600b 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -103,7 +103,6 @@ static int generate_unit_file(SysvStub *s) {
_cleanup_free_ char *path_escaped = NULL;
_cleanup_fclose_ FILE *f = NULL;
const char *unit;
- char **p;
int r;
assert(s);
@@ -707,7 +706,6 @@ static int acquire_search_path(const char *def, const char *envvar, char ***ret)
static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) {
_cleanup_strv_free_ char **sysvinit_path = NULL;
- char **path;
int r;
assert(lp);
@@ -791,7 +789,6 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic
Set *runlevel_services[ELEMENTSOF(rcnd_table)] = {};
_cleanup_strv_free_ char **sysvrcnd_path = NULL;
SysvStub *service;
- char **p;
int r;
assert(lp);
diff --git a/src/test/test-bpf-foreign-programs.c b/src/test/test-bpf-foreign-programs.c
index d73f487ff6..377019f193 100644
--- a/src/test/test-bpf-foreign-programs.c
+++ b/src/test/test-bpf-foreign-programs.c
@@ -133,8 +133,6 @@ static int bpf_foreign_test_to_string(enum bpf_attach_type attach_type, const ch
}
static char **unlink_paths_and_free(char **paths) {
- char **i;
-
STRV_FOREACH(i, paths)
(void) unlink(*i);
diff --git a/src/test/test-bpf-lsm.c b/src/test/test-bpf-lsm.c
index 60d1789a0a..480865d0bc 100644
--- a/src/test/test-bpf-lsm.c
+++ b/src/test/test-bpf-lsm.c
@@ -16,7 +16,6 @@ static int test_restrict_filesystems(Manager *m, const char *unit_name, const ch
_cleanup_free_ char *exec_start = NULL;
_cleanup_(unit_freep) Unit *u = NULL;
ExecContext *ec = NULL;
- char **allow_filesystem;
int cld_code, r;
assert_se(u = unit_new(m, sizeof(Service)));
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
index 2c17c9d83d..71836a307e 100644
--- a/src/test/test-copy.c
+++ b/src/test/test-copy.c
@@ -83,7 +83,6 @@ TEST(copy_tree) {
char **hardlinks = STRV_MAKE("hlink", "file",
"hlink2", "dir1/file");
const char *unixsockp;
- char **p, **ll;
struct stat st;
int xattr_worked = -1; /* xattr support is optional in temporary directories, hence use it if we can,
* but don't fail if we can't */
diff --git a/src/test/test-env-util.c b/src/test/test-env-util.c
index 99ed0d2a05..cc37d96327 100644
--- a/src/test/test-env-util.c
+++ b/src/test/test-env-util.c
@@ -412,7 +412,6 @@ TEST(getenv_steal_erase) {
r = safe_fork("(sd-getenvstealerase)", FORK_DEATHSIG|FORK_LOG|FORK_WAIT, NULL);
if (r == 0) {
_cleanup_strv_free_ char **l = NULL;
- char **e;
/* child */
diff --git a/src/test/test-exec-util.c b/src/test/test-exec-util.c
index d6a9de32ad..e8b04e879f 100644
--- a/src/test/test-exec-util.c
+++ b/src/test/test-exec-util.c
@@ -212,7 +212,7 @@ static int gather_stdout_one(int fd, void *arg) {
return 0;
}
static int gather_stdout_two(int fd, void *arg) {
- char ***s = arg, **t;
+ char ***s = arg;
STRV_FOREACH(t, *s)
assert_se(write(fd, *t, strlen(*t)) == (ssize_t) strlen(*t));
@@ -285,7 +285,6 @@ TEST(stdout_gathering) {
TEST(environment_gathering) {
_cleanup_(rm_rf_physical_and_freep) char *tmpdir = NULL;
const char *name, *name2, *name3, *old;
- char **p;
int r;
char **tmp = NULL; /* this is only used in the forked process, no cleanup here */
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index 8e18bbdb01..a2758b3f84 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -610,7 +610,6 @@ static int find_libraries(const char *exec, char ***ret) {
_cleanup_strv_free_ char **v = NULL;
assert_se(strv_split_newlines_full(&v, result, 0) >= 0);
- char **q;
STRV_FOREACH(q, v) {
_cleanup_free_ char *word = NULL;
const char *p = *q;
@@ -678,7 +677,6 @@ static void test_exec_mount_apivfs(Manager *m) {
assert_se(strextend(&data, "BindReadOnlyPaths=", fullpath_touch, "\n"));
assert_se(strextend(&data, "BindReadOnlyPaths=", fullpath_test, "\n"));
- char **p;
STRV_FOREACH(p, libraries)
assert_se(strextend(&data, "BindReadOnlyPaths=", *p, "\n"));
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 087d76f760..b23aadadcc 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -35,7 +35,6 @@ TEST(parse_env_file) {
*six = NULL, *seven = NULL, *eight = NULL, *nine = NULL, *ten = NULL,
*eleven = NULL, *twelve = NULL, *thirteen = NULL;
_cleanup_strv_free_ char **a = NULL, **b = NULL;
- char **i;
unsigned k;
int r;
@@ -172,7 +171,6 @@ TEST(parse_multiline_env_file) {
p[] = "/tmp/test-fileio-out-XXXXXX";
FILE *f;
_cleanup_strv_free_ char **a = NULL, **b = NULL;
- char **i;
int r;
assert_se(fmkostemp_safe(t, "w", &f) == 0);
@@ -222,7 +220,6 @@ TEST(merge_env_file) {
_cleanup_(unlink_tempfilep) char t[] = "/tmp/test-fileio-XXXXXX";
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **a = NULL;
- char **i;
int r;
assert_se(fmkostemp_safe(t, "w", &f) == 0);
@@ -286,7 +283,6 @@ TEST(merge_env_file_invalid) {
_cleanup_(unlink_tempfilep) char t[] = "/tmp/test-fileio-XXXXXX";
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **a = NULL;
- char **i;
int r;
assert_se(fmkostemp_safe(t, "w", &f) == 0);
@@ -487,7 +483,6 @@ TEST(load_env_file_pairs) {
int fd, r;
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **l = NULL;
- char **k, **v;
fd = mkostemp_safe(fn);
assert_se(fd >= 0);
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c
index f53a3ebf59..67b6996907 100644
--- a/src/test/test-fs-util.c
+++ b/src/test/test-fs-util.c
@@ -692,7 +692,6 @@ TEST(rename_noreplace) {
_cleanup_(rm_rf_physical_and_freep) char *z = NULL;
const char *j = NULL;
- char **a, **b;
if (arg_test_dir)
j = strjoina(arg_test_dir, "/testXXXXXX");
diff --git a/src/test/test-kbd-util.c b/src/test/test-kbd-util.c
index f15cff4794..0a166c6e1f 100644
--- a/src/test/test-kbd-util.c
+++ b/src/test/test-kbd-util.c
@@ -7,7 +7,6 @@
int main(int argc, char *argv[]) {
_cleanup_strv_free_ char **maps = NULL;
- char **m;
int r;
log_show_color(true);
diff --git a/src/test/test-list.c b/src/test/test-list.c
index 25cc55a998..78bbad8e4e 100644
--- a/src/test/test-list.c
+++ b/src/test/test-list.c
@@ -11,7 +11,6 @@ int main(int argc, const char *argv[]) {
LIST_HEAD(list_item, head);
LIST_HEAD(list_item, head2);
list_item items[4];
- list_item *cursor;
LIST_HEAD_INIT(head);
LIST_HEAD_INIT(head2);
@@ -57,6 +56,7 @@ int main(int argc, const char *argv[]) {
assert_se(items[2].item_prev == &items[3]);
assert_se(items[3].item_prev == NULL);
+ list_item *cursor;
LIST_FIND_HEAD(item, &items[0], cursor);
assert_se(cursor == &items[3]);
diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c
index 9bbc5917a1..6ec3f7f00b 100644
--- a/src/test/test-locale-util.c
+++ b/src/test/test-locale-util.c
@@ -10,7 +10,6 @@
TEST(get_locales) {
_cleanup_strv_free_ char **locales = NULL;
- char **p;
int r;
r = get_locales(&locales);
@@ -58,7 +57,6 @@ TEST(locale_is_installed) {
TEST(keymaps) {
_cleanup_strv_free_ char **kmaps = NULL;
- char **p;
int r;
assert_se(!keymap_is_valid(""));
diff --git a/src/test/test-nss-hosts.c b/src/test/test-nss-hosts.c
index 3ae38acb17..69225da8b9 100644
--- a/src/test/test-nss-hosts.c
+++ b/src/test/test-nss-hosts.c
@@ -67,8 +67,6 @@ static int print_gaih_addrtuples(const struct gaih_addrtuple *tuples) {
}
static void print_struct_hostent(struct hostent *host, const char *canon) {
- char **s;
-
log_info(" \"%s\"", host->h_name);
STRV_FOREACH(s, host->h_aliases)
log_info(" alias \"%s\"", *s);
@@ -376,7 +374,6 @@ static int test_one_module(const char *dir,
if (!handle)
return -EINVAL;
- char **name;
STRV_FOREACH(name, names)
test_byname(handle, module, *name);
@@ -424,7 +421,6 @@ static int parse_argv(int argc, char **argv,
assert_se(modules);
if (argc > 2) {
- char **name;
int family;
union in_addr_union address;
@@ -463,7 +459,6 @@ static int run(int argc, char **argv) {
_cleanup_strv_free_ char **modules = NULL, **names = NULL;
_cleanup_free_ struct local_address *addresses = NULL;
int n_addresses = 0;
- char **module;
int r;
test_setup_logging(LOG_INFO);
diff --git a/src/test/test-nss-users.c b/src/test/test-nss-users.c
index 88e2764e99..5178779d54 100644
--- a/src/test/test-nss-users.c
+++ b/src/test/test-nss-users.c
@@ -170,7 +170,6 @@ static int test_one_module(const char *dir,
if (!handle)
return -EINVAL;
- char **name;
STRV_FOREACH(name, names)
test_byname(handle, module, *name);
@@ -235,7 +234,6 @@ static int parse_argv(int argc, char **argv,
static int run(int argc, char **argv) {
_cleanup_free_ char *dir = NULL;
_cleanup_strv_free_ char **modules = NULL, **names = NULL;
- char **module;
int r;
test_setup_logging(LOG_INFO);
diff --git a/src/test/test-path-lookup.c b/src/test/test-path-lookup.c
index a1ae236239..dfb7550543 100644
--- a/src/test/test-path-lookup.c
+++ b/src/test/test-path-lookup.c
@@ -41,7 +41,7 @@ TEST(paths) {
TEST(user_and_global_paths) {
_cleanup_(lookup_paths_free) LookupPaths lp_global = {}, lp_user = {};
- char **u, **g, **p;
+ char **u, **g;
unsigned k = 0;
assert_se(unsetenv("SYSTEMD_UNIT_PATH") == 0);
@@ -78,7 +78,6 @@ static void test_generator_binary_paths_one(UnitFileScope scope) {
_cleanup_strv_free_ char **env_gp_with_env = NULL;
char *systemd_generator_path = NULL;
char *systemd_env_generator_path = NULL;
- char **dir;
assert_se(mkdtemp_malloc("/tmp/test-path-lookup.XXXXXXX", &tmp) >= 0);
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index b9c4ef4126..d40febef5f 100644
--- a/src/test/test-path-util.c
+++ b/src/test/test-path-util.c
@@ -481,7 +481,6 @@ TEST(path_strv_resolve) {
char tmp_dir[] = "/tmp/test-path-util-XXXXXX";
_cleanup_strv_free_ char **search_dirs = NULL;
_cleanup_strv_free_ char **absolute_dirs = NULL;
- char **d;
assert_se(mkdtemp(tmp_dir) != NULL);
diff --git a/src/test/test-path.c b/src/test/test-path.c
index 529487d1ad..2690dc0aa4 100644
--- a/src/test/test-path.c
+++ b/src/test/test-path.c
@@ -24,7 +24,6 @@ typedef void (*test_function_t)(Manager *m);
static int setup_test(Manager **m) {
char **tests_path = STRV_MAKE("exists", "existsglobFOOBAR", "changed", "modified", "unit",
"directorynotempty", "makedirectory");
- char **test_path;
Manager *tmp = NULL;
int r;
diff --git a/src/test/test-sd-path.c b/src/test/test-sd-path.c
index 10a8a4a63f..4f23e3bb69 100644
--- a/src/test/test-sd-path.c
+++ b/src/test/test-sd-path.c
@@ -32,7 +32,6 @@ TEST(sd_path_lookup) {
TEST(sd_path_lookup_strv) {
for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
_cleanup_strv_free_ char **t = NULL, **s = NULL;
- char **item;
int r;
r = sd_path_lookup_strv(i, NULL, &t);
diff --git a/src/test/test-socket-bind.c b/src/test/test-socket-bind.c
index f4197aaf3c..62300c4ae4 100644
--- a/src/test/test-socket-bind.c
+++ b/src/test/test-socket-bind.c
@@ -13,7 +13,7 @@
#include "virt.h"
static int find_netcat_executable(char **ret_path) {
- char **candidates = STRV_MAKE("ncat", "nc", "netcat"), **c;
+ char **candidates = STRV_MAKE("ncat", "nc", "netcat");
int r = 0;
STRV_FOREACH(c, candidates) {
@@ -34,9 +34,7 @@ static int test_socket_bind(
char **deny_rules) {
_cleanup_free_ char *exec_start = NULL;
_cleanup_(unit_freep) Unit *u = NULL;
- CGroupSocketBindItem *bi;
CGroupContext *cc = NULL;
- char **rule;
int cld_code, r;
assert_se(u = unit_new(m, sizeof(Service)));
diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c
index 071b391361..93b674baab 100644
--- a/src/test/test-string-util.c
+++ b/src/test/test-string-util.c
@@ -865,7 +865,6 @@ TEST(strverscmp_improved) {
"124",
NULL,
};
- const char * const *p, * const *q;
STRV_FOREACH(p, versions)
STRV_FOREACH(q, p + 1)
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 94581fc832..ae3e2798c2 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -204,7 +204,6 @@ static void test_strv_unquote_one(const char *quoted, char **list) {
_cleanup_strv_free_ char **s;
_cleanup_free_ char *j;
unsigned i = 0;
- char **t;
int r;
log_info("/* %s */", __func__);
@@ -446,7 +445,6 @@ TEST(strv_split_colon_pairs) {
TEST(strv_split_newlines) {
unsigned i = 0;
- char **s;
_cleanup_strv_free_ char **l = NULL;
const char str[] = "one\ntwo\nthree";
@@ -619,7 +617,6 @@ TEST(strv_extendf) {
TEST(strv_foreach) {
_cleanup_strv_free_ char **a;
unsigned i = 0;
- char **check;
a = strv_new("one", "two", "three");
assert_se(a);
@@ -631,7 +628,6 @@ TEST(strv_foreach) {
TEST(strv_foreach_backwards) {
_cleanup_strv_free_ char **a;
unsigned i = 2;
- char **check;
a = strv_new("one", "two", "three");
@@ -649,7 +645,6 @@ TEST(strv_foreach_backwards) {
TEST(strv_foreach_pair) {
_cleanup_strv_free_ char **a = NULL;
- char **x, **y;
a = strv_new("pair_one", "pair_one",
"pair_two", "pair_two",
diff --git a/src/test/test-sysctl-util.c b/src/test/test-sysctl-util.c
index 8bd3c26152..02180dc4be 100644
--- a/src/test/test-sysctl-util.c
+++ b/src/test/test-sysctl-util.c
@@ -27,7 +27,6 @@ static const char* const cases[] = {
};
TEST(sysctl_normalize) {
- const char **s, **expected;
STRV_FOREACH_PAIR(s, expected, (const char**) cases) {
_cleanup_free_ char *t;
diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c
index 799d271a44..15f4a0c169 100644
--- a/src/test/test-time-util.c
+++ b/src/test/test-time-util.c
@@ -258,7 +258,6 @@ TEST(timezone_is_valid) {
TEST(get_timezones) {
_cleanup_strv_free_ char **zones = NULL;
int r;
- char **zone;
r = get_timezones(&zones);
assert_se(r == 0);
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index cc08a4ae4b..9b05a191e6 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -55,7 +55,6 @@ TEST(unit_file_build_name_map) {
if (r == 0)
log_debug("Cache rebuild skipped based on mtime.");
- char **id;
STRV_FOREACH(id, ids) {
const char *fragment, *name;
_cleanup_set_free_free_ Set *names = NULL;
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 1ac3dc102d..c28615cf5e 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -133,7 +133,6 @@ static void context_clear(Context *c) {
static int context_add_ntp_service(Context *c, const char *s, const char *source) {
_cleanup_(unit_status_info_freep) UnitStatusInfo *unit = NULL;
- UnitStatusInfo *u;
assert(c);
assert(s);
@@ -197,7 +196,6 @@ static int context_parse_ntp_services_from_environment(Context *c) {
static int context_parse_ntp_services_from_disk(Context *c) {
_cleanup_strv_free_ char **files = NULL;
- char **f;
int r;
r = conf_files_list_strv(&files, ".list", NULL, CONF_FILES_FILTER_MASKED, UNIT_LIST_DIRS);
@@ -251,7 +249,6 @@ static int context_parse_ntp_services(Context *c) {
}
static int context_ntp_service_is_active(Context *c) {
- UnitStatusInfo *info;
int count = 0;
assert(c);
@@ -265,7 +262,6 @@ static int context_ntp_service_is_active(Context *c) {
}
static int context_ntp_service_exists(Context *c) {
- UnitStatusInfo *info;
int count = 0;
assert(c);
@@ -410,7 +406,6 @@ static int context_update_ntp_status(Context *c, sd_bus *bus, sd_bus_message *m)
{ "UnitFileState", "s", NULL, offsetof(UnitStatusInfo, unit_file_state) },
{}
};
- UnitStatusInfo *u;
int r;
assert(c);
@@ -453,7 +448,6 @@ static int context_update_ntp_status(Context *c, sd_bus *bus, sd_bus_message *m)
static int match_job_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) {
Context *c = userdata;
- UnitStatusInfo *u;
const char *path;
unsigned n = 0;
int r;
@@ -925,7 +919,6 @@ static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error
_cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL;
sd_bus *bus = sd_bus_message_get_bus(m);
Context *c = userdata;
- UnitStatusInfo *u;
const UnitStatusInfo *selected = NULL;
int enable, interactive, q, r;
diff --git a/src/timesync/timesyncd-bus.c b/src/timesync/timesyncd-bus.c
index 1a14564e04..b738dfd3cc 100644
--- a/src/timesync/timesyncd-bus.c
+++ b/src/timesync/timesyncd-bus.c
@@ -23,7 +23,7 @@ static int property_get_servers(
void *userdata,
sd_bus_error *error) {
- ServerName *p, **s = userdata;
+ ServerName **s = userdata;
int r;
assert(s);
diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c
index 8f34441e15..21fe7daec4 100644
--- a/src/timesync/timesyncd-conf.c
+++ b/src/timesync/timesyncd-conf.c
@@ -24,7 +24,6 @@ int manager_parse_server_string(Manager *m, ServerType type, const char *string)
for (;;) {
_cleanup_free_ char *word = NULL;
bool found = false;
- ServerName *n;
r = extract_first_word(&string, &word, NULL, 0);
if (r < 0)
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 41c18b5e86..7392edbe27 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -953,8 +953,6 @@ Manager* manager_free(Manager *m) {
static int manager_network_read_link_servers(Manager *m) {
_cleanup_strv_free_ char **ntp = NULL;
- ServerName *n, *nx;
- char **i;
bool changed = false;
int r;
@@ -1002,7 +1000,7 @@ static int manager_network_read_link_servers(Manager *m) {
}
}
- LIST_FOREACH_SAFE(names, n, nx, m->link_servers)
+ LIST_FOREACH(names, n, m->link_servers)
if (n->marked) {
server_name_free(n);
changed = true;
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index fcab51c208..f0190f9b4c 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1044,8 +1044,6 @@ static int parse_xattrs_from_arg(Item *i) {
}
static int fd_set_xattrs(Item *i, int fd, const char *path, const struct stat *st) {
- char **name, **value;
-
assert(i);
assert(fd >= 0);
assert(path);
@@ -1964,7 +1962,6 @@ static int glob_item(Item *i, action_t action) {
.gl_opendir = (void *(*)(const char *)) opendir_nomod,
};
int r = 0, k;
- char **fn;
k = safe_glob(i->path, GLOB_NOSORT|GLOB_BRACE, &g);
if (k < 0 && k != -ENOENT)
@@ -1984,7 +1981,6 @@ static int glob_item_recursively(Item *i, fdaction_t action) {
.gl_opendir = (void *(*)(const char *)) opendir_nomod,
};
int r = 0, k;
- char **fn;
k = safe_glob(i->path, GLOB_NOSORT|GLOB_BRACE, &g);
if (k < 0 && k != -ENOENT)
@@ -2720,8 +2716,6 @@ static bool item_compatible(Item *a, Item *b) {
}
static bool should_include_path(const char *path) {
- char **prefix;
-
STRV_FOREACH(prefix, arg_exclude_prefixes)
if (path_startswith(path, *prefix)) {
log_debug("Entry \"%s\" matches exclude prefix \"%s\", skipping.",
@@ -2771,8 +2765,7 @@ static int specifier_expansion_from_arg(Item *i) {
return free_and_replace(i->argument, resolved);
}
case SET_XATTR:
- case RECURSIVE_SET_XATTR: {
- char **xattr;
+ case RECURSIVE_SET_XATTR:
STRV_FOREACH(xattr, i->xattrs) {
_cleanup_free_ char *resolved = NULL;
@@ -2783,7 +2776,7 @@ static int specifier_expansion_from_arg(Item *i) {
free_and_replace(*xattr, resolved);
}
return 0;
- }
+
default:
return 0;
}
@@ -3612,7 +3605,6 @@ static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoe
}
static int parse_arguments(char **config_dirs, char **args, bool *invalid_config) {
- char **arg;
int r;
STRV_FOREACH(arg, args) {
@@ -3627,7 +3619,6 @@ static int parse_arguments(char **config_dirs, char **args, bool *invalid_config
static int read_config_files(char **config_dirs, char **args, bool *invalid_config) {
_cleanup_strv_free_ char **files = NULL;
_cleanup_free_ char *p = NULL;
- char **f;
int r;
r = conf_files_list_with_replacement(arg_root, config_dirs, arg_replace, &files, &p);
@@ -3734,7 +3725,6 @@ static int run(int argc, char *argv[]) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *t = NULL;
- char **i;
STRV_FOREACH(i, config_dirs) {
_cleanup_free_ char *j = NULL;
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 2535593775..7fc0ed7c8d 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -59,7 +59,7 @@ static int send_passwords(const char *socket_name, char **passwords) {
union sockaddr_union sa;
socklen_t sa_len;
size_t packet_length = 1;
- char **p, *d;
+ char *d;
ssize_t n;
int r;
@@ -554,8 +554,6 @@ static int ask_on_this_console(const char *tty, pid_t *ret_pid, char **arguments
if (r < 0)
return r;
if (r == 0) {
- char **i;
-
assert_se(prctl(PR_SET_PDEATHSIG, SIGHUP) >= 0);
STRV_FOREACH(i, arguments) {
@@ -632,7 +630,6 @@ static int ask_on_consoles(char *argv[]) {
_cleanup_set_free_ Set *pids = NULL;
_cleanup_strv_free_ char **consoles = NULL, **arguments = NULL;
siginfo_t status = {};
- char **tty;
pid_t pid;
int r;
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 64691113e0..3c0e887ada 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -69,12 +69,10 @@ static LinkConfig* link_config_free(LinkConfig *config) {
DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfig*, link_config_free);
static void link_configs_free(LinkConfigContext *ctx) {
- LinkConfig *config, *config_next;
-
if (!ctx)
return;
- LIST_FOREACH_SAFE(configs, config, config_next, ctx->configs)
+ LIST_FOREACH(configs, config, ctx->configs)
link_config_free(config);
}
@@ -326,7 +324,6 @@ static int device_unsigned_attribute(sd_device *device, const char *attr, unsign
int link_config_load(LinkConfigContext *ctx) {
_cleanup_strv_free_ char **files = NULL;
- char **f;
int r;
link_configs_free(ctx);
@@ -423,7 +420,6 @@ int link_new(LinkConfigContext *ctx, sd_netlink **rtnl, sd_device *device, Link
}
int link_get_config(LinkConfigContext *ctx, Link *link) {
- LinkConfig *config;
int r;
assert(ctx);
@@ -833,7 +829,6 @@ static int link_apply_alternative_names(Link *link, sd_netlink **rtnl) {
if (r < 0)
log_link_debug_errno(link, r, "Failed to get alternative names, ignoring: %m");
- char **p;
STRV_FOREACH(p, current_altnames)
strv_remove(altnames, *p);
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 85f89fadd8..76fbbc1954 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -611,7 +611,6 @@ static int on_spawn_io(sd_event_source *s, int fd, uint32_t revents, void *userd
/* Log output only if we watch stderr. */
if (l > 0 && spawn->fd_stderr >= 0) {
_cleanup_strv_free_ char **v = NULL;
- char **q;
r = strv_split_newlines_full(&v, p, EXTRACT_RETAIN_ESCAPE);
if (r < 0)
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index ea4d548f60..d245c2c7b3 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -268,11 +268,9 @@ static void udev_rule_token_free(UdevRuleToken *token) {
}
static void udev_rule_line_clear_tokens(UdevRuleLine *rule_line) {
- UdevRuleToken *i, *next;
-
assert(rule_line);
- LIST_FOREACH_SAFE(tokens, i, next, rule_line->tokens)
+ LIST_FOREACH(tokens, i, rule_line->tokens)
udev_rule_token_free(i);
rule_line->tokens = NULL;
@@ -298,12 +296,10 @@ static UdevRuleLine* udev_rule_line_free(UdevRuleLine *rule_line) {
DEFINE_TRIVIAL_CLEANUP_FUNC(UdevRuleLine*, udev_rule_line_free);
static void udev_rule_file_free(UdevRuleFile *rule_file) {
- UdevRuleLine *i, *next;
-
if (!rule_file)
return;
- LIST_FOREACH_SAFE(rule_lines, i, next, rule_file->rule_lines)
+ LIST_FOREACH(rule_lines, i, rule_file->rule_lines)
udev_rule_line_free(i);
free(rule_file->filename);
@@ -311,12 +307,10 @@ static void udev_rule_file_free(UdevRuleFile *rule_file) {
}
UdevRules *udev_rules_free(UdevRules *rules) {
- UdevRuleFile *i, *next;
-
if (!rules)
return NULL;
- LIST_FOREACH_SAFE(rule_files, i, next, rules->rule_files)
+ LIST_FOREACH(rule_files, i, rules->rule_files)
udev_rule_file_free(i);
hashmap_free_free_key(rules->known_users);
@@ -1070,7 +1064,7 @@ static void sort_tokens(UdevRuleLine *rule_line) {
rule_line->current_token = NULL;
while (!LIST_IS_EMPTY(head_old)) {
- UdevRuleToken *t, *min_token = NULL;
+ UdevRuleToken *min_token = NULL;
LIST_FOREACH(tokens, t, head_old)
if (!min_token || min_token->type > t->type)
@@ -1146,12 +1140,10 @@ static int rule_add_line(UdevRules *rules, const char *line_str, unsigned line_n
}
static void rule_resolve_goto(UdevRuleFile *rule_file) {
- UdevRuleLine *line, *line_next, *i;
-
assert(rule_file);
/* link GOTOs to LABEL rules in this file to be able to fast-forward */
- LIST_FOREACH_SAFE(rule_lines, line, line_next, rule_file->rule_lines) {
+ LIST_FOREACH(rule_lines, line, rule_file->rule_lines) {
if (!FLAGS_SET(line->type, LINE_HAS_GOTO))
continue;
@@ -1300,7 +1292,6 @@ UdevRules* udev_rules_new(ResolveNameTiming resolve_name_timing) {
int udev_rules_load(UdevRules **ret_rules, ResolveNameTiming resolve_name_timing) {
_cleanup_(udev_rules_freep) UdevRules *rules = NULL;
_cleanup_strv_free_ char **files = NULL;
- char **f;
int r;
rules = udev_rules_new(resolve_name_timing);
@@ -1814,7 +1805,7 @@ static int udev_rule_apply_token_to_event(
}
case TK_M_IMPORT_PROGRAM: {
_cleanup_strv_free_ char **lines = NULL;
- char buf[UDEV_PATH_SIZE], result[UDEV_LINE_SIZE], **line;
+ char buf[UDEV_PATH_SIZE], result[UDEV_LINE_SIZE];
bool truncated;
(void) udev_event_apply_format(event, token->value, buf, sizeof(buf), false, &truncated);
@@ -2438,9 +2429,12 @@ static int udev_rule_apply_parent_token_to_event(
head = rules->current_file->current_line->current_token;
event->dev_parent = event->dev;
for (;;) {
- LIST_FOREACH(tokens, line->current_token, head) {
- if (!token_is_for_parents(line->current_token))
+ line->current_token = NULL;
+ LIST_FOREACH(tokens, token, head) {
+ if (!token_is_for_parents(token))
return true; /* All parent tokens match. */
+
+ line->current_token = token;
r = udev_rule_apply_token_to_event(rules, event->dev_parent, event, 0, timeout_signal, NULL);
if (r < 0)
return r;
@@ -2468,7 +2462,6 @@ static int udev_rule_apply_line_to_event(
UdevRuleLine *line = rules->current_file->current_line;
UdevRuleLineType mask = LINE_HAS_GOTO | LINE_UPDATE_SOMETHING;
- UdevRuleToken *token, *next_token;
bool parents_done = false;
sd_device_action_t action;
int r;
@@ -2492,7 +2485,7 @@ static int udev_rule_apply_line_to_event(
DEVICE_TRACE_POINT(rules_apply_line, event->dev, line->rule_file->filename, line->line_number);
- LIST_FOREACH_SAFE(tokens, token, next_token, line->tokens) {
+ LIST_FOREACH(tokens, token, line->tokens) {
line->current_token = token;
if (token_is_for_parents(token)) {
@@ -2525,8 +2518,6 @@ int udev_rules_apply_to_event(
int timeout_signal,
Hashmap *properties_list) {
- UdevRuleFile *file;
- UdevRuleLine *next_line;
int r;
assert(rules);
@@ -2534,7 +2525,8 @@ int udev_rules_apply_to_event(
LIST_FOREACH(rule_files, file, rules->rule_files) {
rules->current_file = file;
- LIST_FOREACH_SAFE(rule_lines, file->current_line, next_line, file->rule_lines) {
+ LIST_FOREACH_WITH_NEXT(rule_lines, line, next_line, file->rule_lines) {
+ file->current_line = line;
r = udev_rule_apply_line_to_event(rules, event, timeout_usec, timeout_signal, properties_list, &next_line);
if (r < 0)
return r;
@@ -2548,7 +2540,6 @@ static int apply_static_dev_perms(const char *devnode, uid_t uid, gid_t gid, mod
char device_node[UDEV_PATH_SIZE], tags_dir[UDEV_PATH_SIZE], tag_symlink[UDEV_PATH_SIZE];
_cleanup_free_ char *unescaped_filename = NULL;
struct stat stats;
- char **t;
int r;
assert(devnode);
@@ -2612,7 +2603,6 @@ static int apply_static_dev_perms(const char *devnode, uid_t uid, gid_t gid, mod
}
static int udev_rule_line_apply_static_dev_perms(UdevRuleLine *rule_line) {
- UdevRuleToken *token;
_cleanup_strv_free_ char **tags = NULL;
uid_t uid = UID_INVALID;
gid_t gid = GID_INVALID;
@@ -2645,8 +2635,6 @@ static int udev_rule_line_apply_static_dev_perms(UdevRuleLine *rule_line) {
}
int udev_rules_apply_static_dev_perms(UdevRules *rules) {
- UdevRuleFile *file;
- UdevRuleLine *line;
int r;
assert(rules);
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 992764b80c..66ddf3a779 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -584,7 +584,6 @@ int info_main(int argc, char *argv[], void *userdata) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"-x/--export or -P/--export-prefix cannot be used with --value");
- char **p;
STRV_FOREACH(p, devices) {
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 6137d805f4..41d0ec1e13 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -181,9 +181,7 @@ static Event *event_free(Event *event) {
}
static void event_queue_cleanup(Manager *manager, EventState match_state) {
- Event *event, *tmp;
-
- LIST_FOREACH_SAFE(event, event, tmp, manager->events) {
+ LIST_FOREACH(event, event, manager->events) {
if (match_state != EVENT_UNDEF && match_state != event->state)
continue;
@@ -781,7 +779,7 @@ static int event_run(Event *event) {
static int event_is_blocked(Event *event) {
const char *subsystem, *devpath, *devpath_old = NULL;
dev_t devnum = makedev(0, 0);
- Event *loop_event;
+ Event *loop_event = NULL;
size_t devpath_len;
int r, ifindex = 0;
bool is_block;
@@ -796,7 +794,9 @@ static int event_is_blocked(Event *event) {
/* we have checked previously and no blocker found */
return false;
- LIST_FOREACH(event, loop_event, event->manager->events) {
+ LIST_FOREACH(event, e, event->manager->events) {
+ loop_event = e;
+
/* we already found a later event, earlier cannot block us, no need to check again */
if (loop_event->seqnum < event->blocker_seqnum)
continue;
@@ -842,10 +842,12 @@ static int event_is_blocked(Event *event) {
return r;
/* check if queue contains events we depend on */
- LIST_FOREACH(event, loop_event, loop_event) {
+ LIST_FOREACH(event, e, loop_event) {
size_t loop_devpath_len, common;
const char *loop_devpath;
+ loop_event = e;
+
/* found ourself, no later event can block us */
if (loop_event->seqnum >= event->seqnum)
goto no_blocker;
@@ -915,7 +917,6 @@ no_blocker:
}
static int event_queue_start(Manager *manager) {
- Event *event, *event_next;
usec_t usec;
int r;
@@ -948,7 +949,7 @@ static int event_queue_start(Manager *manager) {
return log_warning_errno(r, "Failed to read udev rules: %m");
}
- LIST_FOREACH_SAFE(event, event, event_next, manager->events) {
+ LIST_FOREACH(event, event, manager->events) {
if (event->state != EVENT_QUEUED)
continue;
diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c
index 0b65ae9210..c3d61f0059 100644
--- a/src/userdb/userdbctl.c
+++ b/src/userdb/userdbctl.c
@@ -257,9 +257,7 @@ static int display_user(int argc, char *argv[], void *userdata) {
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4, (size_t) 5, (size_t) 6, (size_t) 7);
}
- if (argc > 1) {
- char **i;
-
+ if (argc > 1)
STRV_FOREACH(i, argv + 1) {
_cleanup_(user_record_unrefp) UserRecord *ur = NULL;
uid_t uid;
@@ -289,7 +287,7 @@ static int display_user(int argc, char *argv[], void *userdata) {
draw_separator = true;
}
}
- } else {
+ else {
_cleanup_(userdb_iterator_freep) UserDBIterator *iterator = NULL;
r = userdb_all(arg_userdb_flags, &iterator);
@@ -496,9 +494,7 @@ static int display_group(int argc, char *argv[], void *userdata) {
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4);
}
- if (argc > 1) {
- char **i;
-
+ if (argc > 1)
STRV_FOREACH(i, argv + 1) {
_cleanup_(group_record_unrefp) GroupRecord *gr = NULL;
gid_t gid;
@@ -528,8 +524,7 @@ static int display_group(int argc, char *argv[], void *userdata) {
draw_separator = true;
}
}
-
- } else {
+ else {
_cleanup_(userdb_iterator_freep) UserDBIterator *iterator = NULL;
r = groupdb_all(arg_userdb_flags, &iterator);
@@ -654,9 +649,7 @@ static int display_memberships(int argc, char *argv[], void *userdata) {
(void) table_set_sort(table, (size_t) 0, (size_t) 1);
}
- if (argc > 1) {
- char **i;
-
+ if (argc > 1)
STRV_FOREACH(i, argv + 1) {
_cleanup_(userdb_iterator_freep) UserDBIterator *iterator = NULL;
@@ -687,7 +680,7 @@ static int display_memberships(int argc, char *argv[], void *userdata) {
return r;
}
}
- } else {
+ else {
_cleanup_(userdb_iterator_freep) UserDBIterator *iterator = NULL;
r = membershipdb_all(arg_userdb_flags, &iterator);
@@ -849,12 +842,9 @@ static int ssh_authorized_keys(int argc, char *argv[], void *userdata) {
else {
if (strv_isempty(ur->ssh_authorized_keys))
log_debug("User record for %s has no public SSH keys.", argv[1]);
- else {
- char **i;
-
+ else
STRV_FOREACH(i, ur->ssh_authorized_keys)
printf("%s\n", *i);
- }
if (ur->incomplete) {
fflush(stdout);
diff --git a/src/xdg-autostart-generator/xdg-autostart-condition.c b/src/xdg-autostart-generator/xdg-autostart-condition.c
index c4485cf625..9ceea61547 100644
--- a/src/xdg-autostart-generator/xdg-autostart-condition.c
+++ b/src/xdg-autostart-generator/xdg-autostart-condition.c
@@ -13,7 +13,6 @@
static int run(int argc, char *argv[]) {
_cleanup_strv_free_ char **only_show_in = NULL, **not_show_in = NULL, **desktops = NULL;
const char *xdg_current_desktop;
- char **d;
if (argc != 3)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
diff --git a/src/xdg-autostart-generator/xdg-autostart-generator.c b/src/xdg-autostart-generator/xdg-autostart-generator.c
index 8bc16831e7..91dda27d43 100644
--- a/src/xdg-autostart-generator/xdg-autostart-generator.c
+++ b/src/xdg-autostart-generator/xdg-autostart-generator.c
@@ -24,7 +24,6 @@ static int enumerate_xdg_autostart(Hashmap *all_services) {
_cleanup_strv_free_ char **config_dirs = NULL;
_unused_ _cleanup_strv_free_ char **data_dirs = NULL;
_cleanup_free_ char *user_config_autostart_dir = NULL;
- char **path;
int r;
r = xdg_user_config_dir(&user_config_autostart_dir, "/autostart");