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
@@ -559,7 +559,6 @@ static int device_update_properties_bufs(sd_device *device) {
return -ENOMEM;
size_t i = 0;
char *p;
NULSTR_FOREACH(p, buf_nulstr)
buf_strv[i++] = p;
assert(i == num);
+1 -1
View File
@@ -534,7 +534,7 @@ TEST(sd_device_new_from_nulstr) {
_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);
+7 -5
View File
@@ -300,13 +300,15 @@ static int hwdb_new(const char *path, sd_hwdb **ret) {
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)
-1
View File
@@ -1828,7 +1828,6 @@ static int add_search_paths(sd_journal *j) {
static const char search_paths[] =
"/run/log/journal\0"
"/var/log/journal\0";
const char *p;
assert(j);