if (r < 0)
return r;
- for (int i = 0; i < n; i++) {
+ FOREACH_ARRAY(i, list, n) {
_cleanup_free_ char *unit_path = NULL, *job_path = NULL;
+ Job *job = *i;
- job_path = job_dbus_path(list[i]);
+ job_path = job_dbus_path(job);
if (!job_path)
return -ENOMEM;
- unit_path = unit_dbus_path(list[i]->unit);
+ unit_path = unit_dbus_path(job->unit);
if (!unit_path)
return -ENOMEM;
r = sd_bus_message_append(reply, "(usssoo)",
- list[i]->id,
- list[i]->unit->id,
- job_type_to_string(list[i]->type),
- job_state_to_string(list[i]->state),
+ job->id,
+ job->unit->id,
+ job_type_to_string(job->type),
+ job_state_to_string(job->state),
job_path,
unit_path);
if (r < 0)
#include "string-util.h"
CompareOperator parse_compare_operator(const char **s, CompareOperatorParseFlags flags) {
+
static const struct {
CompareOperator op;
const char *str;
* parse_compare_operator() are use on the same string? */
return _COMPARE_OPERATOR_INVALID;
- for (size_t i = 0; i < ELEMENTSOF(table); i++) {
+ FOREACH_ARRAY(i, table, ELEMENTSOF(table)) {
const char *e;
- if (table[i].need_mask != 0 && !FLAGS_SET(flags, table[i].need_mask))
+ if (i->need_mask != 0 && !FLAGS_SET(flags, i->need_mask))
continue;
- e = startswith(*s, table[i].str);
+ e = startswith(*s, i->str);
if (e) {
- if (table[i].valid_mask != 0 && !FLAGS_SET(flags, table[i].valid_mask))
+ if (i->valid_mask != 0 && !FLAGS_SET(flags, i->valid_mask))
return _COMPARE_OPERATOR_INVALID;
*s = e;
- return table[i].op;
+ return i->op;
}
}
/* Checks if this mount point is considered "API", and hence
* should be ignored */
- for (size_t i = 0; i < ELEMENTSOF(mount_table); i++)
- if (path_equal(path, mount_table[i].where))
+ FOREACH_ARRAY(i, mount_table, ELEMENTSOF(mount_table))
+ if (path_equal(path, i->where))
return true;
return path_startswith(path, "/sys/fs/cgroup/");