summaryrefslogtreecommitdiffstats
path: root/src/analyze
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-16 14:32:23 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-19 00:33:33 +0100
commitde010b0b2e50cf0b3837ce350b116bc92605f67a (patch)
tree226685fbb97461692562035501ebc21a314f718c /src/analyze
parentlist: make LIST_FOREACH() and LIST_FOREACH_BACKWARDS() safer (diff)
downloadsystemd-de010b0b2e50cf0b3837ce350b116bc92605f67a.tar.xz
systemd-de010b0b2e50cf0b3837ce350b116bc92605f67a.zip
strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
Diffstat (limited to 'src/analyze')
-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
15 files changed, 8 insertions, 42 deletions
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);