summaryrefslogtreecommitdiffstats
path: root/src/tmpfiles
diff options
context:
space:
mode:
Diffstat (limited to 'src/tmpfiles')
-rw-r--r--src/tmpfiles/tmpfiles.c57
1 files changed, 15 insertions, 42 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index a2eb05c6a6..ab9ea2768a 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -449,17 +449,10 @@ static bool takes_ownership(ItemType t) {
static struct Item* find_glob(OrderedHashmap *h, const char *match) {
ItemArray *j;
- ORDERED_HASHMAP_FOREACH(j, h) {
- size_t n;
-
- for (n = 0; n < j->n_items; n++) {
- Item *item = j->items + n;
-
+ ORDERED_HASHMAP_FOREACH(j, h)
+ FOREACH_ARRAY(item, j->items, j->n_items)
if (fnmatch(item->path, match, FNM_PATHNAME|FNM_PERIOD) == 0)
return item;
- }
- }
-
return NULL;
}
@@ -3121,7 +3114,6 @@ static int process_item_array(
OperationMask operation) {
int r = 0;
- size_t n;
assert(c);
assert(array);
@@ -3134,22 +3126,12 @@ static int process_item_array(
if ((operation & (OPERATION_REMOVE|OPERATION_CLEAN|OPERATION_PURGE)) && !set_isempty(array->children)) {
ItemArray *cc;
- SET_FOREACH(cc, array->children) {
- int k;
-
- k = process_item_array(c, cc, operation & (OPERATION_REMOVE|OPERATION_CLEAN|OPERATION_PURGE));
- if (k < 0 && r == 0)
- r = k;
- }
+ SET_FOREACH(cc, array->children)
+ RET_GATHER(r, process_item_array(c, cc, operation & (OPERATION_REMOVE|OPERATION_CLEAN|OPERATION_PURGE)));
}
- for (n = 0; n < array->n_items; n++) {
- int k;
-
- k = process_item(c, array->items + n, operation);
- if (k < 0 && r == 0)
- r = k;
- }
+ FOREACH_ARRAY(item, array->items, array->n_items)
+ RET_GATHER(r, process_item(c, item, operation));
return r;
}
@@ -3174,13 +3156,11 @@ static void item_free_contents(Item *i) {
}
static ItemArray* item_array_free(ItemArray *a) {
- size_t n;
-
if (!a)
return NULL;
- for (n = 0; n < a->n_items; n++)
- item_free_contents(a->items + n);
+ FOREACH_ARRAY(item, a->items, a->n_items)
+ item_free_contents(item);
set_free(a->children);
free(a->items);
@@ -3443,13 +3423,10 @@ static int parse_age_by_from_arg(const char *age_by_str, Item *item) {
}
static bool is_duplicated_item(ItemArray *existing, const Item *i) {
-
assert(existing);
assert(i);
- for (size_t n = 0; n < existing->n_items; n++) {
- const Item *e = existing->items + n;
-
+ FOREACH_ARRAY(e, existing->items, existing->n_items) {
if (item_compatible(e, i))
continue;
@@ -3478,9 +3455,9 @@ static int parse_line(
};
ItemArray *existing;
OrderedHashmap *h;
- int r, pos;
bool append_or_force = false, boot = false, allow_failure = false, try_replace = false,
unbase64 = false, from_cred = false, missing_user_or_group = false;
+ int r;
assert(fname);
assert(line >= 1);
@@ -3542,7 +3519,7 @@ static int parse_line(
return log_syntax(NULL, LOG_ERR, fname, line, SYNTHETIC_ERRNO(EBADMSG), "Command too short '%s'.", action);
}
- for (pos = 1; action[pos]; pos++) {
+ for (int pos = 1; action[pos]; pos++)
if (action[pos] == '!' && !boot)
boot = true;
else if (action[pos] == '+' && !append_or_force)
@@ -3559,7 +3536,6 @@ static int parse_line(
*invalid_config = true;
return log_syntax(NULL, LOG_ERR, fname, line, SYNTHETIC_ERRNO(EBADMSG), "Unknown modifiers in command '%s'", action);
}
- }
if (boot && !arg_boot) {
log_syntax(NULL, LOG_DEBUG, fname, line, 0, "Ignoring entry %s \"%s\" because --boot is not specified.", action, path);
@@ -3864,14 +3840,13 @@ static int parse_line(
const char *mm;
unsigned m;
- for (mm = mode;; mm++) {
+ for (mm = mode;; mm++)
if (*mm == '~')
i.mask_perms = true;
else if (*mm == ':')
i.mode_only_create = true;
else
break;
- }
r = parse_mode(mm, &m);
if (r < 0) {
@@ -4238,17 +4213,15 @@ static int read_config_file(
/* we have to determine age parameter for each entry of type X */
ORDERED_HASHMAP_FOREACH(ia, c->globs)
- for (size_t ni = 0; ni < ia->n_items; ni++) {
+ FOREACH_ARRAY(i, ia->items, ia->n_items) {
ItemArray *ja;
- Item *i = ia->items + ni, *candidate_item = NULL;
+ Item *candidate_item = NULL;
if (i->type != IGNORE_DIRECTORY_PATH)
continue;
ORDERED_HASHMAP_FOREACH(ja, c->items)
- for (size_t nj = 0; nj < ja->n_items; nj++) {
- Item *j = ja->items + nj;
-
+ FOREACH_ARRAY(j, ja->items, ja->n_items) {
if (!IN_SET(j->type, CREATE_DIRECTORY,
TRUNCATE_DIRECTORY,
CREATE_SUBVOLUME,