nulstr-util: Declare NULSTR_FOREACH() iterator inline

This commit is contained in:
Daan De Meyer
2022-11-11 16:31:32 +01:00
parent 5ea173a91b
commit 12e2b70f9b
44 changed files with 26 additions and 78 deletions
-1
View File
@@ -28,7 +28,6 @@ int fs_type_from_string(const char *name, const statfs_f_type_t **ret) {
}
bool fs_in_group(const struct statfs *s, FilesystemGroups fs_group) {
const char *fs;
int r;
NULSTR_FOREACH(fs, filesystem_sets[fs_group].value) {
-2
View File
@@ -4,8 +4,6 @@
#include "string-util.h"
const char* nulstr_get(const char *nulstr, const char *needle) {
const char *i;
if (!nulstr)
return NULL;
+2 -2
View File
@@ -5,10 +5,10 @@
#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);
+1 -1
View File
@@ -880,7 +880,7 @@ char **env_generator_binary_paths(bool is_system) {
}
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);
-1
View File
@@ -679,7 +679,6 @@ char** strv_parse_nulstr(const char *s, size_t l) {
}
char** strv_split_nulstr(const char *s) {
const char *i;
char **r = NULL;
NULSTR_FOREACH(i, s)