print_separator();
if (path_is_absolute(*arg)) {
- const char *dir;
-
NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) {
t = path_startswith(*arg, dir);
if (t)
}
static void filesystem_set_remove(Set *s, const FilesystemSet *set) {
- const char *filesystem;
-
NULSTR_FOREACH(filesystem, set->value) {
if (filesystem[0] == '@')
continue;
}
static void dump_filesystem_set(const FilesystemSet *set) {
- const char *filesystem;
int r;
if (!set)
if (strv_isempty(strv_skip(argv, 1))) {
_cleanup_set_free_ Set *kernel = NULL, *known = NULL;
- const char *fs;
int k;
NULSTR_FOREACH(fs, filesystem_sets[FILESYSTEM_SET_KNOWN].value)
}
static bool syscall_names_in_filter(Set *s, bool allow_list, const SyscallFilterSet *f, const char **ret_offending_syscall) {
- const char *syscall;
-
NULSTR_FOREACH(syscall, f->value) {
if (syscall[0] == '@') {
const SyscallFilterSet *g;
}
static void syscall_set_remove(Set *s, const SyscallFilterSet *set) {
- const char *syscall;
-
if (!set)
return;
}
static void dump_syscall_filter(const SyscallFilterSet *set) {
- const char *syscall;
-
printf("%s%s%s\n"
" # %s\n",
ansi_highlight(),
if (strv_isempty(strv_skip(argv, 1))) {
_cleanup_set_free_ Set *kernel = NULL, *known = NULL;
- const char *sys;
int k = 0; /* explicit initialization to appease gcc */
NULSTR_FOREACH(sys, syscall_filter_sets[SYSCALL_FILTER_SET_KNOWN].value)
}
bool fs_in_group(const struct statfs *s, FilesystemGroups fs_group) {
- const char *fs;
int r;
NULSTR_FOREACH(fs, filesystem_sets[fs_group].value) {
#include "string-util.h"
const char* nulstr_get(const char *nulstr, const char *needle) {
- const char *i;
-
if (!nulstr)
return NULL;
#include <string.h>
#define NULSTR_FOREACH(i, l) \
- for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
+ for (typeof(*(l)) *(i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
#define NULSTR_FOREACH_PAIR(i, j, l) \
- for ((i) = (l), (j) = strchr((i), 0)+1; (i) && *(i); (i) = strchr((j), 0)+1, (j) = *(i) ? strchr((i), 0)+1 : (i))
+ for (typeof(*(l)) *(i) = (l), *(j) = strchr((i), 0)+1; (i) && *(i); (i) = strchr((j), 0)+1, (j) = *(i) ? strchr((i), 0)+1 : (i))
const char* nulstr_get(const char *nulstr, const char *needle);
}
int find_portable_profile(const char *name, const char *unit, char **ret_path) {
- const char *p, *dot;
+ const char *dot;
assert(name);
assert(ret_path);
}
char** strv_split_nulstr(const char *s) {
- const char *i;
char **r = NULL;
NULSTR_FOREACH(i, s)
"/run/systemd/inaccessible/blk\0" "rwm\0";
int r = 0, k;
- const char *node, *acc;
NULSTR_FOREACH_PAIR(node, acc, auto_devices) {
k = bpf_devices_allow_list_device(prog, path, node, acc);
if (r >= 0 && k < 0)
if (name[0] == '@') {
const FilesystemSet *set;
- const char *i;
set = filesystem_set_find(name);
if (!set) {
};
const char *prev = NULL;
- const char *i;
assert(f);
"/dev/tty\0";
char temporary_mount[] = "/tmp/namespace-dev-XXXXXX";
- const char *d, *dev = NULL, *devpts = NULL, *devshm = NULL, *devhugepages = NULL, *devmqueue = NULL, *devlog = NULL, *devptmx = NULL;
+ const char *dev = NULL, *devpts = NULL, *devshm = NULL, *devhugepages = NULL, *devmqueue = NULL, *devlog = NULL, *devptmx = NULL;
bool can_mknod = true;
int r;
"ID_MODEL\0";
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
- const char *i, *name;
+ const char *name;
struct stat st;
assert(path);
static int should_skip_path(const char *prefix, const char *suffix) {
#if HAVE_SPLIT_USR
_cleanup_free_ char *target = NULL, *dirname = NULL;
- const char *p;
dirname = path_join(prefix, suffix);
if (!dirname)
}
static int process_suffix(const char *suffix, const char *onlyprefix) {
- const char *p;
char *f, *key;
OrderedHashmap *top, *bottom, *drops, *h;
int r = 0, k, n_found = 0;
}
static int process_suffixes(const char *onlyprefix) {
- const char *n;
int n_found = 0, r;
NULSTR_FOREACH(n, suffixes) {
}
static int process_suffix_chop(const char *arg) {
- const char *p;
-
assert(arg);
if (!path_is_absolute(arg))
size_t *ret_volume_key_size) {
_cleanup_free_ char *xattr_buf = NULL;
- const char *xa;
int r;
assert(setup);
_cleanup_free_ char *xattr_buf = NULL;
size_t volume_key_size = 0;
uint32_t slot = 0;
- const char *xa;
int r;
assert(h);
Set **units) {
_cleanup_set_free_free_ Set *found = NULL;
- const char *field;
int r;
found = set_new(&string_hash_ops);
return -ENOMEM;
size_t i = 0;
- char *p;
NULSTR_FOREACH(p, buf_nulstr)
buf_strv[i++] = p;
assert(i == num);
_cleanup_(sd_device_unrefp) sd_device *device = NULL, *from_nulstr = NULL;
_cleanup_free_ char *nulstr_copy = NULL;
- const char *devlink, *nulstr;
+ const char *nulstr;
size_t len;
assert_se(sd_device_new_from_syspath(&device, "/sys/class/net/lo") >= 0);
if (!hwdb->f)
return log_debug_errno(errno, "Failed to open %s: %m", path);
} else {
- NULSTR_FOREACH(path, hwdb_bin_paths) {
- log_debug("Trying to open \"%s\"...", path);
- hwdb->f = fopen(path, "re");
- if (hwdb->f)
+ NULSTR_FOREACH(p, hwdb_bin_paths) {
+ log_debug("Trying to open \"%s\"...", p);
+ hwdb->f = fopen(p, "re");
+ if (hwdb->f) {
+ path = p;
break;
+ }
if (errno != ENOENT)
- return log_debug_errno(errno, "Failed to open %s: %m", path);
+ return log_debug_errno(errno, "Failed to open %s: %m", p);
}
if (!hwdb->f)
static const char search_paths[] =
"/run/log/journal\0"
"/var/log/journal\0";
- const char *p;
assert(j);
}
int find_converted_keymap(const char *x11_layout, const char *x11_variant, char **new_keymap) {
- const char *dir;
_cleanup_free_ char *n = NULL;
if (x11_variant)
static int call_get_os_release(sd_bus *bus, const char *method, const char *name, const char *query, ...) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
- const char *k, *v, *iter, **query_res = NULL;
+ const char *k, *v, **query_res = NULL;
size_t count = 0, awaited_args = 0;
va_list ap;
int r;
"tty\0"
"net/tun\0";
- const char *d;
int r = 0;
assert(dest);
/* Defined by RFC 8375. The most official choice. */
"home.arpa\0";
- const char *name;
int r;
assert(d);
continue;
if (table[i].target) {
- const char *target = NULL, *s;
+ const char *target = NULL;
/* check if one of the targets exists */
NULSTR_FOREACH(s, table[i].target) {
if (FLAGS_SET(flags, OUTPUT_CGROUP_XATTRS) && fd >= 0) {
_cleanup_free_ char *nl = NULL;
- char *xa;
r = flistxattr_malloc(fd, &nl);
if (r < 0)
if (sections && !nulstr_contains(sections, n)) {
bool ignore;
- const char *t;
ignore = (flags & CONFIG_PARSE_RELAXED) || startswith(n, "X-");
int copy_xattr(int fdf, int fdt, CopyFlags copy_flags) {
_cleanup_free_ char *names = NULL;
int ret = 0, r;
- const char *p;
r = flistxattr_malloc(fdf, &names);
if (r < 0)
"/proc/self/fd/1\0" "/dev/stdout\0"
"/proc/self/fd/2\0" "/dev/stderr\0";
- const char *j, *k;
int r;
NULSTR_FOREACH_PAIR(j, k, symlinks) {
const char *root,
Image **ret) {
- const char *path;
int r;
assert(class >= 0);
const char *root,
Hashmap *h) {
- const char *path;
int r;
assert(class >= 0);
const char *root,
const char *image) {
- const char *path;
-
assert(image);
NULSTR_FOREACH(path, image_search_path[class]) {
for (unsigned k = 0; k < _META_MAX; k++) {
_cleanup_close_ int fd = -ENOENT;
- const char *p;
if (!paths[k])
continue;
char ***ret_values,
char **ret_filtered) {
- const char *name, *namefound = NULL, *x;
+ const char *namefound = NULL, *x;
_cleanup_strv_free_ char **stor = NULL, **values = NULL;
_cleanup_free_ char *value = NULL, **filtered = NULL;
int r;
if (!x)
continue;
/* Match name, but when ret_values, only when followed by assignment. */
- if (*x == '=' || (!ret_values && *x == '\0'))
+ if (*x == '=' || (!ret_values && *x == '\0')) {
+ /* Keep the last occurrence found */
+ namefound = name;
goto found;
+ }
}
*t = *s;
t++;
continue;
found:
- /* Keep the last occurrence found */
- namefound = name;
-
if (ret_value || ret_values) {
assert(IN_SET(*x, '=', '\0'));
int hwdb_query(const char *modalias, const char *root) {
_cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
- const char *key, *value, *p;
+ const char *key, *value;
int r;
assert(modalias);
bool hwdb_should_reload(sd_hwdb *hwdb) {
bool found = false;
- const char* p;
struct stat st;
if (!hwdb)
return -ENOMEM;
for (;;) {
- const char *sfx;
bool changed = false;
NULSTR_FOREACH(sfx, suffixes) {
if (!keymaps)
return -ENOMEM;
- const char *dir;
NULSTR_FOREACH(dir, KBD_KEYMAP_DIRS) {
r = recurse_dir_at(
AT_FDCWD,
if (!keymap_is_valid(name))
return -EINVAL;
- const char *dir;
NULSTR_FOREACH(dir, KBD_KEYMAP_DIRS) {
r = recurse_dir_at(
AT_FDCWD,
bool log_missing,
char ***added) {
- const char *sys;
int r;
/* Any syscalls that are handled are added to the *added strv. It needs to be initialized. */
if (name[0] == '@') {
const SyscallFilterSet *set;
- const char *i;
set = syscall_filter_set_find(name);
if (!set) {
}
int seccomp_filter_set_add(Hashmap *filter, bool add, const SyscallFilterSet *set) {
- const char *i;
int r;
assert(set);
SECCOMP_FOREACH_LOCAL_ARCH(arch) {
_cleanup_(seccomp_releasep) scmp_filter_ctx seccomp = NULL;
- const char *c;
r = seccomp_init_for_arch(&seccomp, arch, SCMP_ACT_ALLOW);
if (r < 0)
else
arg_start = getpid_cached();
- const char *i;
NULSTR_FOREACH(i, "zeros\0simple\0random\0") {
#if HAVE_XZ
test_compress_decompress("XZ", i, compress_blob_xz, decompress_blob_xz);
TEST(condition_test_virtualization) {
Condition *condition;
- const char *virt;
int r;
condition = condition_new(CONDITION_VIRTUALIZATION, "garbage oifdsjfoidsjoj", false, false);
m = hashmap_new(&string_hash_ops);
- NULSTR_FOREACH(key, key_table)
- hashmap_put(m, key, (void*) (const char*) "my dummy val");
+ NULSTR_FOREACH(k, key_table)
+ hashmap_put(m, k, (void*) (const char*) "my dummy val");
HASHMAP_FOREACH_KEY(s, key, m) {
assert_se(s);
TEST(sd_hwdb_new_from_path) {
_cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
- const char *hwdb_bin_path = NULL;
int r;
assert_se(sd_hwdb_new_from_path(NULL, &hwdb) == -EINVAL);
}
TEST(architecture_table) {
- const char *n, *n2;
+ const char *n2;
NULSTR_FOREACH(n,
"native\0"
assert_se(streq(syscall_filter_sets[SYSCALL_FILTER_SET_KNOWN].name, "@known"));
for (size_t i = 0; i < _SYSCALL_FILTER_SET_MAX; i++) {
- const char *k, *p = NULL;
+ const char *p = NULL;
/* Make sure each group has a description */
assert_se(!isempty(syscall_filter_sets[0].help));
static void test_strv_make_nulstr_one(char **l) {
_cleanup_free_ char *b = NULL, *c = NULL;
_cleanup_strv_free_ char **q = NULL;
- const char *s = NULL;
size_t n, m;
unsigned i = 0;
}
static bool token_match_string(UdevRuleToken *token, const char *str) {
- const char *i, *value;
+ const char *value;
bool match = false;
assert(token);