1
0
mirror of https://github.com/systemd/systemd synced 2024-07-09 04:26:06 +00:00

strv: make iterator in STRV_FOREACH() declaread in the loop

This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
This commit is contained in:
Yu Watanabe 2022-03-16 22:32:23 +09:00
parent 80a226b26b
commit de010b0b2e
210 changed files with 109 additions and 621 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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) {

View File

@ -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;
}

View File

@ -12,7 +12,6 @@
#include "strv.h"
static int analyze_elf(char **filenames, JsonFormatFlags json_flags) {
char **filename;
int r;
STRV_FOREACH(filename, filenames) {

View File

@ -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)) {

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -1042,8 +1042,6 @@ static int search_and_fopen_internal(
FILE **ret,
char **ret_path) {
char **i;
assert(path);
assert(mode);
assert(ret);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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 == '+')

View File

@ -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)

View File

@ -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 */

View File

@ -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) \
for (s = ({ \
typeof(l) _l = l; \
_l ? _l + strv_length(_l) - 1U : NULL; \
}); \
(l) && ((s) >= (l)); \
(s)--)
#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_PAIR(x, y, l) \
for ((x) = (l), (y) = (x) ? (x+1) : NULL; (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
#define STRV_FOREACH_BACKWARDS(s, l) \
_STRV_FOREACH_BACKWARDS(s, l, UNIQ_T(h, UNIQ), UNIQ_T(i, UNIQ))
#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) \
_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) \

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -416,7 +416,6 @@ 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;
CGroupContext *c;
struct in_addr_prefix *iaai;
char **path;
char cda[FORMAT_CGROUP_DIFF_MAX];
char cdb[FORMAT_CGROUP_DIFF_MAX];

View File

@ -634,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)
@ -2024,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;

View File

@ -74,7 +74,6 @@ static int property_get_environment_files(
sd_bus_error *error) {
ExecContext *c = userdata;
char **j;
int r;
assert(bus);
@ -1138,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);
}
@ -2016,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;
@ -2062,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)
@ -2427,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;
@ -2512,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;
@ -2564,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;
@ -2579,8 +2569,6 @@ int bus_exec_context_set_transient_property(
return r;
}
}
joined = strv_join(l, " ");
if (!joined)
return -ENOMEM;
@ -2612,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;
@ -3141,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)
@ -3260,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)
@ -3314,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);
@ -3344,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)
@ -3373,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);

View File

@ -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);

View File

@ -325,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)) {

View File

@ -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)

View File

@ -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);
}

View File

@ -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;
@ -5520,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);
@ -5627,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)
@ -5648,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);
@ -6271,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)

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -3634,7 +3634,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

View File

@ -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) {

View File

@ -2650,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);
@ -4085,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);

View File

@ -776,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);
@ -918,8 +916,6 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) {
}
static void socket_close_fds(Socket *s) {
char **i;
assert(s);
LIST_FOREACH(port, p, s->ports) {
@ -1265,7 +1261,6 @@ static int mq_address_create(
static int socket_symlink(Socket *s) {
const char *p;
char **i;
int r;
assert(s);

View File

@ -324,7 +324,7 @@ _pure_ static bool unit_matters_to_anchor(Unit *u, Job *job) {
}
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) {
@ -361,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. */

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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),

View File

@ -12,7 +12,6 @@ int find_key_file(
void **ret_key,
size_t *ret_key_size) {
char **i;
int r;
assert(key_file);

View File

@ -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);

View File

@ -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))

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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();

View File

@ -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)

View File

@ -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)

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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);
@ -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);

View File

@ -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;

View File

@ -417,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);
@ -450,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);

View File

@ -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);

View File

@ -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);

View File

@ -799,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);

View File

@ -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)

View File

@ -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) {

View File

@ -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);

View File

@ -108,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)
@ -2061,7 +2061,6 @@ static int emit_properties_changed_on_interface(
bool has_invalidating = false, has_changing = false;
struct vtable_member key = {};
struct node *n;
char **property;
void *u = NULL;
int r;
@ -2840,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);

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -2031,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);

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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);

Some files were not shown because too many files have changed in this diff Show More