#define LIST_JUST_US(name,item) \
(!(item)->name##_prev && !(item)->name##_next)
+/* The type of the iterator 'i' is automatically determined by the type of 'head', and declared in the
+ * loop. Hence, do not declare the same variable in the outer scope. Sometimes, we set 'head' through
+ * hashmap_get(). In that case, you need to explicitly cast the result. */
#define LIST_FOREACH(name,i,head) \
- for ((i) = (head); (i); (i) = (i)->name##_next)
+ for (typeof(*(head)) *i = (head); i; i = i->name##_next)
#define LIST_FOREACH_SAFE(name,i,n,head) \
- for ((i) = (head); (i) && (((n) = (i)->name##_next), 1); (i) = (n))
+ for (typeof(*(head)) *n, *i = (head); i && ((n = i->name##_next), 1); i = n)
#define LIST_FOREACH_BACKWARDS(name,i,p) \
- for ((i) = (p); (i); (i) = (i)->name##_prev)
+ for (typeof(*(p)) *i = (p); i; i = i->name##_prev)
/* Iterate through all the members of the list p is included in, but skip over p */
#define LIST_FOREACH_OTHERS(name,i,p) \
- for (({ \
- (i) = (p); \
- while ((i) && (i)->name##_prev) \
- (i) = (i)->name##_prev; \
- if ((i) == (p)) \
- (i) = (p)->name##_next; \
- }); \
- (i); \
- (i) = (i)->name##_next == (p) ? (p)->name##_next : (i)->name##_next)
-
-/* Loop starting from p->next until p->prev.
- p can be adjusted meanwhile. */
+ for (typeof(*(p)) *_p = (p), *i = ({ \
+ typeof(*_p) *_j = _p; \
+ while (_j && _j->name##_prev) \
+ _j = _j->name##_prev; \
+ if (_j == _p) \
+ _j = _p->name##_next; \
+ _j; \
+ }); \
+ i; \
+ i = i->name##_next == _p ? _p->name##_next : i->name##_next)
+
+/* Loop starting from p->next until p->prev. p can be adjusted meanwhile. */
#define LIST_LOOP_BUT_ONE(name,i,head,p) \
- for ((i) = (p)->name##_next ? (p)->name##_next : (head); \
- (i) != (p); \
- (i) = (i)->name##_next ? (i)->name##_next : (head))
+ for (typeof(*(p)) *i = (p)->name##_next ? (p)->name##_next : (head); \
+ i != (p); \
+ i = i->name##_next ? i->name##_next : (head))
#define LIST_IS_EMPTY(head) \
(!(head))
int bpf_foreign_install(Unit *u) {
_cleanup_free_ char *cgroup_path = NULL;
- CGroupBPFForeignProgram *p;
CGroupContext *cc;
int r;
int map_fd,
CGroupSocketBindItem *head) {
- CGroupSocketBindItem *item;
uint32_t i = 0;
assert(map_fd >= 0);
_cleanup_(socket_bind_bpf_freep) struct socket_bind_bpf *obj = NULL;
size_t allow_count = 0, deny_count = 0;
int allow_map_fd, deny_map_fd, r;
- CGroupSocketBindItem *item;
assert(ret_obj);
void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
_cleanup_free_ char *disable_controllers_str = NULL, *cpuset_cpus = NULL, *cpuset_mems = NULL, *startup_cpuset_cpus = NULL, *startup_cpuset_mems = NULL;
- CGroupIODeviceLimit *il;
- CGroupIODeviceWeight *iw;
- CGroupIODeviceLatency *l;
- CGroupBlockIODeviceBandwidth *b;
- CGroupBlockIODeviceWeight *w;
- CGroupBPFForeignProgram *p;
- CGroupDeviceAllow *a;
CGroupContext *c;
- CGroupSocketBindItem *bi;
struct in_addr_prefix *iaai;
char **path;
_cleanup_(bpf_program_freep) BPFProgram *prog = NULL;
const char *path;
CGroupContext *c;
- CGroupDeviceAllow *a;
CGroupDevicePolicy policy;
int r;
set_io_weight(u, weight);
if (has_io) {
- CGroupIODeviceLatency *latency;
- CGroupIODeviceLimit *limit;
- CGroupIODeviceWeight *w;
-
LIST_FOREACH(device_weights, w, c->io_device_weights)
cgroup_apply_io_device_weight(u, w->path, w->weight);
cgroup_apply_io_device_latency(u, latency->path, latency->target_usec);
} else if (has_blockio) {
- CGroupBlockIODeviceWeight *w;
- CGroupBlockIODeviceBandwidth *b;
-
LIST_FOREACH(device_weights, w, c->blockio_device_weights) {
weight = cgroup_weight_blkio_to_io(w->weight);
set_blkio_weight(u, weight);
- if (has_io) {
- CGroupIODeviceWeight *w;
-
+ if (has_io)
LIST_FOREACH(device_weights, w, c->io_device_weights) {
weight = cgroup_weight_io_to_blkio(w->weight);
cgroup_apply_blkio_device_weight(u, w->path, weight);
}
- } else if (has_blockio) {
- CGroupBlockIODeviceWeight *w;
-
+ else if (has_blockio)
LIST_FOREACH(device_weights, w, c->blockio_device_weights)
cgroup_apply_blkio_device_weight(u, w->path, w->weight);
- }
}
/* The bandwidth limits are something that make sense to be applied to the host's root but not container
* roots, as there we want the container manager to handle it */
if (is_host_root || !is_local_root) {
- if (has_io) {
- CGroupIODeviceLimit *l;
-
+ if (has_io)
LIST_FOREACH(device_limits, l, c->io_device_limits) {
log_cgroup_compat(u, "Applying IO{Read|Write}Bandwidth=%" PRIu64 " %" PRIu64 " as BlockIO{Read|Write}BandwidthMax= for %s",
l->limits[CGROUP_IO_RBPS_MAX], l->limits[CGROUP_IO_WBPS_MAX], l->path);
cgroup_apply_blkio_device_limit(u, l->path, l->limits[CGROUP_IO_RBPS_MAX], l->limits[CGROUP_IO_WBPS_MAX]);
}
- } else if (has_blockio) {
- CGroupBlockIODeviceBandwidth *b;
-
+ else if (has_blockio)
LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths)
cgroup_apply_blkio_device_limit(u, b->path, b->rbps, b->wbps);
- }
}
}
if (r < 0)
return r;
- for (size_t i = 0; i < ELEMENTSOF(supported_unit_types); i++) {
- Unit *u;
-
+ for (size_t i = 0; i < ELEMENTSOF(supported_unit_types); i++)
LIST_FOREACH(units_by_type, u, m->units_by_type[supported_unit_types[i]]) {
CGroupContext *c;
return r;
}
}
- }
r = json_build(&v, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("cgroups", JSON_BUILD_VARIANT(arr))));
if (r < 0)
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupIODeviceWeight *w;
int r;
assert(bus);
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupIODeviceLimit *l;
int r;
assert(bus);
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupIODeviceLatency *l;
int r;
assert(bus);
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupBlockIODeviceWeight *w;
int r;
assert(bus);
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupBlockIODeviceBandwidth *b;
int r;
assert(bus);
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupDeviceAllow *a;
int r;
assert(bus);
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
- CGroupBPFForeignProgram *p;
int r;
r = sd_bus_message_open_container(reply, 'a', "(ss)");
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
- CGroupSocketBindItem **items = userdata, *i;
+
+ CGroupSocketBindItem **items = userdata;
int r;
assert(items);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupBPFForeignProgram *fp;
size_t size = 0;
if (n == 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupIODeviceLimit *a = NULL, *b;
+ CGroupIODeviceLimit *a = NULL;
- LIST_FOREACH(device_limits, b, c->io_device_limits) {
+ LIST_FOREACH(device_limits, b, c->io_device_limits)
if (path_equal(path, b->path)) {
a = b;
break;
}
- }
if (!a) {
CGroupIOLimitType type;
return r;
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupIODeviceLimit *a;
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
LIST_FOREACH(device_limits, a, c->io_device_limits)
a->limits[iol_type] = cgroup_io_limit_defaults[iol_type];
- }
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
fprintf(f, "%s=\n", name);
LIST_FOREACH(device_limits, a, c->io_device_limits)
- if (a->limits[iol_type] != cgroup_io_limit_defaults[iol_type])
- fprintf(f, "%s=%s %" PRIu64 "\n", name, a->path, a->limits[iol_type]);
+ if (a->limits[iol_type] != cgroup_io_limit_defaults[iol_type])
+ fprintf(f, "%s=%s %" PRIu64 "\n", name, a->path, a->limits[iol_type]);
r = fflush_and_check(f);
if (r < 0)
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "IODeviceWeight= value out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupIODeviceWeight *a = NULL, *b;
+ CGroupIODeviceWeight *a = NULL;
- LIST_FOREACH(device_weights, b, c->io_device_weights) {
+ LIST_FOREACH(device_weights, b, c->io_device_weights)
if (path_equal(b->path, path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupIODeviceWeight, 1);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupIODeviceWeight *a;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
while (c->io_device_weights)
cgroup_context_free_io_device_weight(c, c->io_device_weights);
- }
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupIODeviceLatency *a = NULL, *b;
+ CGroupIODeviceLatency *a = NULL;
- LIST_FOREACH(device_latencies, b, c->io_device_latencies) {
+ LIST_FOREACH(device_latencies, b, c->io_device_latencies)
if (path_equal(b->path, path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupIODeviceLatency, 1);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupIODeviceLatency *a;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
while (c->io_device_latencies)
cgroup_context_free_io_device_latency(c, c->io_device_latencies);
- }
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupBlockIODeviceBandwidth *a = NULL, *b;
+ CGroupBlockIODeviceBandwidth *a = NULL;
- LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) {
+ LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths)
if (path_equal(path, b->path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupBlockIODeviceBandwidth, 1);
return r;
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupBlockIODeviceBandwidth *a;
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths) {
if (read)
a->rbps = CGROUP_LIMIT_MAX;
else
a->wbps = CGROUP_LIMIT_MAX;
}
- }
unit_invalidate_cgroup(u, CGROUP_MASK_BLKIO);
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "BlockIODeviceWeight= out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupBlockIODeviceWeight *a = NULL, *b;
+ CGroupBlockIODeviceWeight *a = NULL;
- LIST_FOREACH(device_weights, b, c->blockio_device_weights) {
+ LIST_FOREACH(device_weights, b, c->blockio_device_weights)
if (path_equal(b->path, path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupBlockIODeviceWeight, 1);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupBlockIODeviceWeight *a;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
while (c->blockio_device_weights)
cgroup_context_free_blockio_device_weight(c, c->blockio_device_weights);
- }
unit_invalidate_cgroup(u, CGROUP_MASK_BLKIO);
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "DeviceAllow= requires combination of rwm flags");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- CGroupDeviceAllow *a = NULL, *b;
+ CGroupDeviceAllow *a = NULL;
- LIST_FOREACH(device_allow, b, c->device_allow) {
+ LIST_FOREACH(device_allow, b, c->device_allow)
if (path_equal(b->path, path)) {
a = b;
break;
}
- }
if (!a) {
a = new0(CGroupDeviceAllow, 1);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupDeviceAllow *a;
size_t size = 0;
- if (n == 0) {
+ if (n == 0)
while (c->device_allow)
cgroup_context_free_device_allow(c, c->device_allow);
- }
unit_invalidate_cgroup(u, CGROUP_MASK_DEVICES);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- CGroupSocketBindItem *item;
size_t size = 0;
if (n == 0)
sd_bus_error *error) {
ExecContext *c = userdata;
- MountOptions *m;
int r;
assert(bus);
return r;
for (size_t i = 0; i < c->n_mount_images; i++) {
- MountOptions *m;
-
r = sd_bus_message_open_container(reply, SD_BUS_TYPE_STRUCT, "ssba(ss)");
if (r < 0)
return r;
return r;
for (size_t i = 0; i < c->n_extension_images; i++) {
- MountOptions *m;
-
r = sd_bus_message_open_container(reply, SD_BUS_TYPE_STRUCT, "sba(ss)");
if (r < 0)
return r;
void *userdata,
sd_bus_error *ret_error) {
- ExecCommand *c = *(ExecCommand**) userdata;
+ ExecCommand *exec_command = *(ExecCommand**) userdata;
int r;
assert(bus);
if (r < 0)
return r;
- LIST_FOREACH(command, c, c) {
+ LIST_FOREACH(command, c, exec_command) {
r = append_exec_command(reply, c);
if (r < 0)
return r;
void *userdata,
sd_bus_error *ret_error) {
- ExecCommand *c, *exec_command = *(ExecCommand**) userdata;
+ ExecCommand *exec_command = *(ExecCommand**) userdata;
int r;
assert(bus);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *buf = NULL;
_cleanup_fclose_ FILE *f = NULL;
- ExecCommand *c;
size_t size = 0;
if (n == 0)
sd_bus_error *error) {
Path *p = userdata;
- PathSpec *k;
int r;
assert(bus);
sd_bus_error *error) {
Socket *s = SOCKET(userdata);
- SocketPort *p;
int r;
assert(bus);
sd_bus_error *error) {
Timer *t = userdata;
- TimerValue *v;
int r;
assert(bus);
sd_bus_error *error) {
Timer *t = userdata;
- TimerValue *v;
int r;
assert(bus);
sd_bus_error *error) {
const char *(*to_string)(ConditionType type) = NULL;
- Condition **list = userdata, *c;
+ Condition **list = userdata;
int r;
assert(bus);
}
static void device_update_found_by_sysfs(Manager *m, const char *sysfs, DeviceFound found, DeviceFound mask) {
- Device *d, *l, *n;
+ Device *l;
assert(m);
assert(sysfs);
static Unit *device_following(Unit *u) {
Device *d = DEVICE(u);
- Device *other, *first = NULL;
+ Device *first = NULL;
assert(d);
}
static int device_following_set(Unit *u, Set **_set) {
- Device *d = DEVICE(u), *other;
+ Device *d = DEVICE(u);
_cleanup_set_free_ Set *set = NULL;
int r;
}
static void device_propagate_reload_by_sysfs(Manager *m, const char *sysfs) {
- Device *d, *l, *n;
+ Device *l;
int r;
assert(m);
}
void exec_command_reset_status_list_array(ExecCommand **c, size_t n) {
- for (size_t i = 0; i < n; i++) {
- ExecCommand *z;
-
+ for (size_t i = 0; i < n; i++)
LIST_FOREACH(command, z, c[i])
exec_status_reset(&z->exec_status);
- }
}
typedef struct InvalidEnvInfo {
fprintf(f, "%sRootImage: %s\n", prefix, c->root_image);
if (c->root_image_options) {
- MountOptions *o;
-
fprintf(f, "%sRootImageOptions:", prefix);
LIST_FOREACH(mount_options, o, c->root_image_options)
if (!isempty(o->options))
}
for (size_t i = 0; i < c->n_mount_images; i++) {
- MountOptions *o;
-
fprintf(f, "%sMountImages: %s%s:%s", prefix,
c->mount_images[i].ignore_enoent ? "-": "",
c->mount_images[i].source,
}
for (size_t i = 0; i < c->n_extension_images; i++) {
- MountOptions *o;
-
fprintf(f, "%sExtensionImages: %s%s", prefix,
c->extension_images[i].ignore_enoent ? "-": "",
c->extension_images[i].source);
prefix = strempty(prefix);
- LIST_FOREACH(command, c, c)
- exec_command_dump(c, f, prefix);
+ LIST_FOREACH(command, i, c)
+ exec_command_dump(i, f, prefix);
}
void exec_command_append_list(ExecCommand **l, ExecCommand *e) {
void *userdata) {
_cleanup_free_ char *path = NULL, *resolved = NULL;
- CGroupIODeviceLimit *l = NULL, *t;
+ CGroupIODeviceLimit *l = NULL;
CGroupContext *c = data;
CGroupIOLimitType type;
const char *p = rvalue;
assert(type >= 0);
if (isempty(rvalue)) {
- LIST_FOREACH(device_limits, l, c->io_device_limits)
- l->limits[type] = cgroup_io_limit_defaults[type];
+ LIST_FOREACH(device_limits, t, c->io_device_limits)
+ t->limits[type] = cgroup_io_limit_defaults[type];
return 0;
}
}
}
- LIST_FOREACH(device_limits, t, c->io_device_limits) {
+ LIST_FOREACH(device_limits, t, c->io_device_limits)
if (path_equal(resolved, t->path)) {
l = t;
break;
}
- }
if (!l) {
CGroupIOLimitType ttype;
void *userdata) {
_cleanup_free_ char *path = NULL, *resolved = NULL;
- CGroupBlockIODeviceBandwidth *b = NULL, *t;
+ CGroupBlockIODeviceBandwidth *b = NULL;
CGroupContext *c = data;
const char *p = rvalue;
uint64_t bytes;
read = streq("BlockIOReadBandwidth", lvalue);
if (isempty(rvalue)) {
- LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) {
- b->rbps = CGROUP_LIMIT_MAX;
- b->wbps = CGROUP_LIMIT_MAX;
+ LIST_FOREACH(device_bandwidths, t, c->blockio_device_bandwidths) {
+ t->rbps = CGROUP_LIMIT_MAX;
+ t->wbps = CGROUP_LIMIT_MAX;
}
return 0;
}
return 0;
}
- LIST_FOREACH(device_bandwidths, t, c->blockio_device_bandwidths) {
+ LIST_FOREACH(device_bandwidths, t, c->blockio_device_bandwidths)
if (path_equal(resolved, t->path)) {
b = t;
break;
}
- }
- if (!t) {
+ if (!b) {
b = new0(CGroupBlockIODeviceBandwidth, 1);
if (!b)
return log_oom();
is_bad = false;
}
- const UnitRef *ref;
LIST_FOREACH(refs_by_target, ref, u->refs_by_target) {
unit_gc_sweep(ref->source, gc_marker);
static int mount_process_proc_self_mountinfo(Manager *m) {
_cleanup_set_free_free_ Set *around = NULL, *gone = NULL;
const char *what;
- Unit *u;
int r;
assert(m);
int mount_image_add(MountImage **m, size_t *n, const MountImage *item) {
_cleanup_free_ char *s = NULL, *d = NULL;
_cleanup_(mount_options_free_allp) MountOptions *options = NULL;
- MountOptions *i;
MountImage *c;
assert(m);
}
static int path_add_mount_dependencies(Path *p) {
- PathSpec *s;
int r;
assert(p);
static void path_dump(Unit *u, FILE *f, const char *prefix) {
Path *p = PATH(u);
Unit *trigger;
- PathSpec *s;
assert(p);
assert(f);
}
static void path_unwatch(Path *p) {
- PathSpec *s;
-
assert(p);
LIST_FOREACH(spec, s, p->specs)
static int path_watch(Path *p) {
int r;
- PathSpec *s;
assert(p);
}
static bool path_check_good(Path *p, bool initial, bool from_trigger_notify) {
- PathSpec *s;
-
assert(p);
LIST_FOREACH(spec, s, p->specs)
}
static void path_mkdir(Path *p) {
- PathSpec *s;
-
assert(p);
if (!p->make_directory)
static int path_serialize(Unit *u, FILE *f, FDSet *fds) {
Path *p = PATH(u);
- PathSpec *s;
assert(u);
assert(f);
_cleanup_free_ char *unescaped = NULL;
ssize_t l;
PathType type;
- PathSpec *s;
type = path_type_from_string(type_str);
if (type < 0) {
}
static int path_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
- PathSpec *s = userdata;
+ PathSpec *s = userdata, *found = NULL;
Path *p;
int changed;
if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING))
return 0;
- /* log_debug("inotify wakeup on %s.", UNIT(p)->id); */
-
- LIST_FOREACH(spec, s, p->specs)
- if (path_spec_owns_inotify_fd(s, fd))
+ LIST_FOREACH(spec, i, p->specs)
+ if (path_spec_owns_inotify_fd(i, fd)) {
+ found = i;
break;
+ }
- if (!s) {
+ if (!found) {
log_error("Got event on unknown fd.");
goto fail;
}
- changed = path_spec_fd_event(s, revents);
+ changed = path_spec_fd_event(found, revents);
if (changed < 0)
goto fail;
* Use this errno rather than E[NM]FILE to distinguish from
* the case where systemd itself hits the file limit. */
- LIST_FOREACH(fd_store, fs, s->fd_store) {
- r = same_fd(fs->fd, fd);
+ LIST_FOREACH(fd_store, i, s->fd_store) {
+ r = same_fd(i->fd, fd);
if (r < 0)
return r;
if (r > 0) {
}
static void service_remove_fd_store(Service *s, const char *name) {
- ServiceFDStore *fs, *n;
-
assert(s);
assert(name);
assert(s);
assert(UNIT(s)->load_state == UNIT_LOADED);
- for (ServiceExecCommand c = 0; c < _SERVICE_EXEC_COMMAND_MAX; c++) {
- ExecCommand *command;
-
+ for (ServiceExecCommand c = 0; c < _SERVICE_EXEC_COMMAND_MAX; c++)
LIST_FOREACH(command, command, s->exec_command[c]) {
if (!path_is_absolute(command->path) && !filename_is_valid(command->path))
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC),
"Service has an empty argv in %s=. Refusing.",
service_exec_command_to_string(c));
}
- }
if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP] &&
UNIT(s)->success_action == EMERGENCY_ACTION_NONE)
}
if (s->n_fd_store > 0) {
- ServiceFDStore *fs;
size_t n_fds;
char **nl;
int *t;
static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
Service *s = SERVICE(u);
- ServiceFDStore *fs;
int r;
assert(u);
}
static bool have_non_accept_socket(Socket *s) {
- SocketPort *p;
-
assert(s);
if (!s->accept)
}
static int socket_add_mount_dependencies(Socket *s) {
- SocketPort *p;
int r;
assert(s);
static const char *socket_find_symlink_target(Socket *s) {
const char *found = NULL;
- SocketPort *p;
LIST_FOREACH(port, p, s->ports) {
const char *f = NULL;
static void socket_dump(Unit *u, FILE *f, const char *prefix) {
Socket *s = SOCKET(u);
- SocketPort *p;
const char *prefix2, *str;
assert(s);
}
static void socket_close_fds(Socket *s) {
- SocketPort *p;
char **i;
assert(s);
_cleanup_(socket_close_fdsp) Socket *s = orig_s;
_cleanup_(mac_selinux_freep) char *label = NULL;
bool know_label = false;
- SocketPort *p;
int r;
assert(s);
}
static void socket_unwatch_fds(Socket *s) {
- SocketPort *p;
int r;
assert(s);
}
static int socket_watch_fds(Socket *s) {
- SocketPort *p;
int r;
assert(s);
static int socket_check_open(Socket *s) {
bool have_open = false, have_closed = false;
- SocketPort *p;
assert(s);
if (r == 0) {
uid_t uid = UID_INVALID;
gid_t gid = GID_INVALID;
- SocketPort *p;
/* Child */
}
static void flush_ports(Socket *s) {
- SocketPort *p;
+ assert(s);
/* Flush all incoming traffic, regardless if actual bytes or new connections, so that this socket isn't busy
* anymore */
static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
Socket *s = SOCKET(u);
- SocketPort *p;
int r;
assert(u);
}
} else if (streq(key, "fifo")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse fifo value: %s", value);
} else if (streq(key, "special")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse special value: %s", value);
} else if (streq(key, "mqueue")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse mqueue value: %s", value);
} else if (streq(key, "socket")) {
int fd, type, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %i %n", &fd, &type, &skip) < 2 || fd < 0 || type < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse socket value: %s", value);
} else if (streq(key, "netlink")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse socket value: %s", value);
} else if (streq(key, "ffs")) {
int fd, skip = 0;
- SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
log_unit_debug(u, "Failed to parse ffs value: %s", value);
static void socket_distribute_fds(Unit *u, FDSet *fds) {
Socket *s = SOCKET(u);
- SocketPort *p;
assert(u);
int socket_collect_fds(Socket *s, int **fds) {
size_t k = 0, n = 0;
- SocketPort *p;
int *rfds;
assert(s);
static void swap_set_state(Swap *s, SwapState state) {
SwapState old_state;
- Swap *other;
assert(s);
assert(s);
if (s->from_proc_swaps) {
- Swap *other;
-
swap_enter_active(s, f);
LIST_FOREACH_OTHERS(same_devnode, other, s)
}
static int swap_start(Unit *u) {
- Swap *s = SWAP(u), *other;
+ Swap *s = SWAP(u);
int r;
assert(s);
}
static int swap_process_proc_swaps(Manager *m) {
- Unit *u;
int r;
assert(m);
static Unit *swap_following(Unit *u) {
Swap *s = SWAP(u);
- Swap *other, *first = NULL;
+ Swap *first = NULL;
assert(s);
}
static int swap_following_set(Unit *u, Set **_set) {
- Swap *s = SWAP(u), *other;
+ Swap *s = SWAP(u);
_cleanup_set_free_ Set *set = NULL;
int r;
static int timer_add_default_dependencies(Timer *t) {
int r;
- TimerValue *v;
assert(t);
static void timer_dump(Unit *u, FILE *f, const char *prefix) {
Timer *t = TIMER(u);
Unit *trigger;
- TimerValue *v;
trigger = UNIT_TRIGGER(u);
bool found_monotonic = false, found_realtime = false;
bool leave_around = false;
triple_timestamp ts;
- TimerValue *v;
Unit *trigger;
int r;
static int timer_start(Unit *u) {
Timer *t = TIMER(u);
- TimerValue *v;
int r;
assert(t);
static void timer_trigger_notify(Unit *u, Unit *other) {
Timer *t = TIMER(u);
- TimerValue *v;
assert(u);
assert(other);
}
static void transaction_find_jobs_that_matter_to_anchor(Job *j, unsigned generation) {
- JobDependency *l;
+ assert(j);
/* A recursive sweep through the graph that marks all units
* that matter to the anchor job, i.e. are directly or
}
static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other, JobType t) {
- JobDependency *l, *last;
+ JobDependency *last;
assert(j);
assert(other);
}
_pure_ static bool job_is_conflicted_by(Job *j) {
- JobDependency *l;
-
assert(j);
/* Returns true if this job is pulled in by a least one
return false;
}
-static int delete_one_unmergeable_job(Transaction *tr, Job *j) {
- Job *k;
-
- assert(j);
+static int delete_one_unmergeable_job(Transaction *tr, Job *job) {
+ assert(job);
/* Tries to delete one item in the linked list
* j->transaction_next->transaction_next->... that conflicts
/* We rely here on the fact that if a merged with b does not
* merge with c, either a or b merge with c neither */
- LIST_FOREACH(transaction, j, j)
+ LIST_FOREACH(transaction, j, job)
LIST_FOREACH(transaction, k, j->transaction_next) {
Job *d;
* task conflict. If so, try to drop one of them. */
HASHMAP_FOREACH(j, tr->jobs) {
JobType t;
- Job *k;
t = j->type;
LIST_FOREACH(transaction, k, j->transaction_next) {
/* Second step, merge the jobs. */
HASHMAP_FOREACH(j, tr->jobs) {
JobType t = j->type;
- Job *k;
/* Merge all transaction jobs for j->unit */
LIST_FOREACH(transaction, k, j->transaction_next)
assert_se(job_type_merge_and_collapse(&t, k->type, j->unit) == 0);
+ Job *k;
while ((k = j->transaction_next)) {
if (tr->anchor_job == k) {
transaction_merge_and_delete_job(tr, k, j, t);
HASHMAP_FOREACH(j, tr->jobs) {
bool keep = false;
- Job *k;
LIST_FOREACH(transaction, k, j)
if (tr->anchor_job == k ||
} while (again);
}
-_pure_ static bool unit_matters_to_anchor(Unit *u, Job *j) {
+_pure_ static bool unit_matters_to_anchor(Unit *u, Job *job) {
assert(u);
- assert(!j->transaction_prev);
+ assert(job);
+ assert(!job->transaction_prev);
/* Checks whether at least one of the jobs for this unit
* matters to the anchor. */
- LIST_FOREACH(transaction, j, j)
+ LIST_FOREACH(transaction, j, job)
if (j->matters_to_anchor)
return true;
}
static void transaction_minimize_impact(Transaction *tr) {
- Job *j;
+ Job *head;
assert(tr);
* or that stop a running service. */
rescan:
- HASHMAP_FOREACH(j, tr->jobs) {
- LIST_FOREACH(transaction, j, j) {
+ HASHMAP_FOREACH(head, tr->jobs) {
+ LIST_FOREACH(transaction, j, head) {
bool stops_running_service, changes_existing_job;
/* If it matters, we shouldn't drop it */
f = hashmap_get(tr->jobs, unit);
- LIST_FOREACH(transaction, j, f) {
- assert(j->unit == unit);
+ LIST_FOREACH(transaction, i, f) {
+ assert(i->unit == unit);
- if (j->type == type) {
+ if (i->type == type) {
if (is_new)
*is_new = false;
- return j;
+ return i;
}
}
}
Condition *unit_find_failed_condition(Unit *u) {
- Condition *c, *failed_trigger = NULL;
+ Condition *failed_trigger = NULL;
bool has_succeeded_trigger = false;
if (u->condition_result)
bool skip_once;
int r, count = 0;
- BootId *head = NULL, *tail = NULL, *id;
+ BootId *head = NULL, *tail = NULL;
const bool advance_older = boot_id && offset <= 0;
sd_id128_t previous_boot_id;
static int list_boots(sd_journal *j) {
_cleanup_(table_unrefp) Table *table = NULL;
- BootId *id, *all_ids;
+ BootId *all_ids;
int count, i, r;
assert(j);
}
int journal_ratelimit_test(JournalRateLimit *r, const char *id, usec_t rl_interval, unsigned rl_burst, int priority, uint64_t available) {
- uint64_t h;
- JournalRateLimitGroup *g;
+ JournalRateLimitGroup *g, *found = NULL;
JournalRateLimitPool *p;
unsigned burst;
+ uint64_t h;
usec_t ts;
assert(id);
h = siphash24_string(id, r->hash_key);
g = r->buckets[h % BUCKETS_MAX];
- LIST_FOREACH(bucket, g, g)
- if (streq(g->id, id))
+ LIST_FOREACH(bucket, i, g)
+ if (streq(i->id, id)) {
+ found = i;
break;
+ }
- if (!g) {
- g = journal_ratelimit_group_new(r, id, rl_interval, ts);
- if (!g)
+ if (!found) {
+ found = journal_ratelimit_group_new(r, id, rl_interval, ts);
+ if (!found)
return -ENOMEM;
} else
- g->interval = rl_interval;
+ found->interval = rl_interval;
if (rl_interval == 0 || rl_burst == 0)
return 1;
burst = burst_modulate(rl_burst, available);
- p = &g->pools[priority_map[priority]];
+ p = &found->pools[priority_map[priority]];
if (p->begin <= 0) {
p->suppressed = 0;
int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia) {
struct ia_header header;
- const DHCP6Address *addr;
size_t ia_buflen;
uint8_t *ia_hdr;
uint16_t len;
}
int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len) {
- struct sd_dhcp_raw_option *cur, *option;
+ struct sd_dhcp_raw_option *option, *before = NULL;
assert(lease);
LIST_FOREACH(options, cur, lease->private_options) {
- if (tag < cur->tag)
+ if (tag < cur->tag) {
+ before = cur;
break;
+ }
if (tag == cur->tag) {
log_debug("Ignoring duplicate option, tagged %i.", tag);
return 0;
return -ENOMEM;
}
- LIST_INSERT_BEFORE(options, lease->private_options, cur, option);
+ LIST_INSERT_BEFORE(options, lease->private_options, before, option);
return 0;
}
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
_cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
- struct sd_dhcp_raw_option *option;
struct in_addr address;
const struct in_addr *addresses;
const void *client_id, *data;
static void dhcp6_lease_set_lifetime(sd_dhcp6_lease *lease) {
uint32_t t1 = UINT32_MAX, t2 = UINT32_MAX, min_valid_lt = UINT32_MAX;
- DHCP6Address *a;
assert(lease);
assert(lease->ia_na || lease->ia_pd);
}
void dhcp6_ia_clear_addresses(DHCP6IA *ia) {
- DHCP6Address *a, *n;
-
assert(ia);
LIST_FOREACH_SAFE(addresses, a, n, ia->addresses)
}
static int radv_send(sd_radv *ra, const struct in6_addr *dst, usec_t lifetime_usec) {
- sd_radv_route_prefix *rt;
- sd_radv_prefix *p;
struct sockaddr_in6 dst_addr = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_ALL_NODES_MULTICAST_INIT,
int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
_cleanup_free_ char *addr_p = NULL;
- sd_radv_prefix *cur, *found = NULL;
+ sd_radv_prefix *found = NULL;
int r;
assert_return(ra, -EINVAL);
const struct in6_addr *prefix,
unsigned char prefixlen) {
- sd_radv_prefix *cur;
-
if (!ra)
return;
int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) {
_cleanup_free_ char *addr_p = NULL;
- sd_radv_route_prefix *cur, *found = NULL;
+ sd_radv_route_prefix *found = NULL;
int r;
assert_return(ra, -EINVAL);
OrderedSet *s,
sd_bus_error *error) {
- struct node_enumerator *c;
int r;
assert(bus);
OrderedSet *s,
sd_bus_error *error) {
- struct node *i;
int r;
assert(bus);
bool require_fallback,
bool *found_object) {
- struct node_callback *c;
int r;
assert(bus);
bool *found_object) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
- struct node_vtable *c;
bool found_interface;
int r;
const char *path,
bool require_fallback) {
- struct node_vtable *c;
- struct node_callback *k;
int r;
assert(bus);
_cleanup_ordered_set_free_ OrderedSet *s = NULL;
_cleanup_(introspect_free) struct introspect intro = {};
- struct node_vtable *c;
bool empty;
int r;
const char *previous_interface = NULL;
bool found_something = false;
- struct node_vtable *i;
struct node *n;
int r;
void *userdata) {
sd_bus_slot *s = NULL;
- struct node_vtable *i, *existing = NULL;
+ struct node_vtable *existing = NULL;
const sd_bus_vtable *v;
struct node *n;
int r;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
bool has_invalidating = false, has_changing = false;
struct vtable_member key = {};
- struct node_vtable *c;
struct node *n;
char **property;
void *u = NULL;
bool require_fallback) {
const char *previous_interface = NULL;
- struct node_vtable *c;
struct node *n;
int r;
bool require_fallback) {
const char *previous_interface = NULL;
- struct node_vtable *c;
struct node *n;
int r;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
bool found_interface = false;
- struct node_vtable *c;
struct node *n;
void *u = NULL;
int r;
static int process_filter(sd_bus *bus, sd_bus_message *m) {
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
- struct filter_callback *l;
int r;
assert(bus);
static uint32_t inode_data_determine_mask(struct inode_data *d) {
bool excl_unlink = true;
uint32_t combined = 0;
- sd_event_source *s;
assert(d);
/* The queue overran, let's pass this event to all event sources connected to this inotify
* object */
- HASHMAP_FOREACH(inode_data, d->inodes) {
- sd_event_source *s;
-
+ HASHMAP_FOREACH(inode_data, d->inodes)
LIST_FOREACH(inotify.by_inode_data, s, inode_data->event_sources) {
if (event_source_is_offline(s))
if (r < 0)
return r;
}
- }
} else {
struct inode_data *inode_data;
- sd_event_source *s;
/* Find the inode object for this watch descriptor. If IN_IGNORED is set we also remove it from
* our watch descriptor table. */
}
static int process_inotify(sd_event *e) {
- struct inotify_data *d;
int r, done = 0;
assert(e);
}
static void window_unlink(Window *w) {
- Context *c;
assert(w);
size_t size,
void **ret) {
- Window *w;
+ Window *found = NULL;
assert(f);
assert(f->cache);
return -EIO;
LIST_FOREACH(by_fd, w, f->windows)
- if (window_matches(w, offset, size))
+ if (window_matches(w, offset, size)) {
+ found = w;
break;
+ }
- if (!w)
+ if (!found)
return 0;
- context_attach_window(f->cache, c, w);
- w->keep_always = w->keep_always || keep_always;
+ context_attach_window(f->cache, c, found);
+ found->keep_always = found->keep_always || keep_always;
- *ret = (uint8_t*) w->ptr + (offset - w->offset);
+ *ret = (uint8_t*) found->ptr + (offset - found->offset);
f->cache->n_window_list_hit++;
return 1;
ours = false;
HASHMAP_FOREACH(f, m->fds) {
- Window *w;
-
LIST_FOREACH(by_fd, w, f->windows) {
if ((uint8_t*) addr >= (uint8_t*) w->ptr &&
(uint8_t*) addr < (uint8_t*) w->ptr + w->size) {
return;
HASHMAP_FOREACH(f, m->fds) {
- Window *w;
-
if (!f->sigbus)
continue;
}
_public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size) {
- Match *l3, *l4, *add_here = NULL, *m = NULL;
+ Match *add_here = NULL, *m = NULL;
uint64_t hash;
assert_return(j, -EINVAL);
static char *match_make_string(Match *m) {
char *p = NULL, *r;
- Match *i;
bool enclose = false;
if (!m)
return journal_file_move_to_entry_by_offset_for_data(f, d, after_offset, direction, ret, offset);
} else if (m->type == MATCH_OR_TERM) {
- Match *i;
/* Find the earliest match beyond after_offset */
return 0;
} else if (m->type == MATCH_AND_TERM) {
- Match *i, *last_moved;
+ Match *last_moved;
/* Always jump to the next matching entry and repeat
* this until we find an offset that matches for all
} else if (m->type == MATCH_OR_TERM) {
uint64_t np = 0;
Object *n;
- Match *i;
/* Find the earliest match */
return 1;
} else {
- Match *i;
uint64_t np = 0;
assert(m->type == MATCH_AND_TERM);
}
static int process_match(sd_netlink *nl, sd_netlink_message *m) {
- struct match_callback *c;
uint16_t type;
uint8_t cmd;
int r;
}
void udev_list_cleanup(struct udev_list *list) {
- struct udev_list_entry *i, *n;
-
if (!list)
return;
if (streq_ptr(path, user->service_job)) {
user->service_job = mfree(user->service_job);
- LIST_FOREACH(sessions_by_user, session, user->sessions)
- (void) session_jobs_reply(session, id, unit, NULL /* don't propagate user service failures to the client */);
+ LIST_FOREACH(sessions_by_user, s, user->sessions)
+ (void) session_jobs_reply(s, id, unit, NULL /* don't propagate user service failures to the client */);
user_save(user);
}
}
void device_attach(Device *d, Seat *s) {
- Device *i;
bool had_master;
assert(d);
sd_bus_error *error) {
Seat *s = userdata;
- Session *session;
int r;
assert(bus);
}
if (s->sessions) {
- Session *i;
-
fputs("SESSIONS=", f);
LIST_FOREACH(sessions_by_seat, i, s->sessions) {
fprintf(f,
}
int seat_active_vt_changed(Seat *s, unsigned vtnr) {
- Session *i, *new_active = NULL;
+ Session *new_active = NULL;
int r;
assert(s);
break;
}
- if (!new_active) {
+ if (!new_active)
/* no running one? then we can't decide which one is the
* active one, let the first one win */
LIST_FOREACH(sessions_by_seat, i, s->sessions)
new_active = i;
break;
}
- }
r = seat_set_active(s, new_active);
manager_spawn_autovt(s->manager, vtnr);
}
int seat_stop_sessions(Seat *s, bool force) {
- Session *session;
int r = 0, k;
assert(s);
}
void seat_evict_position(Seat *s, Session *session) {
- Session *iter;
unsigned pos = session->position;
session->position = 0;
/* There might be another session claiming the same
* position (eg., during gdm->session transition), so let's look
* for it and set it on the free slot. */
- LIST_FOREACH(sessions_by_seat, iter, s->sessions) {
+ LIST_FOREACH(sessions_by_seat, iter, s->sessions)
if (iter->position == pos && session_get_state(iter) != SESSION_CLOSING) {
s->positions[pos] = iter;
break;
}
- }
}
}
}
int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
- Session *session;
bool idle_hint = true;
dual_timestamp ts = DUAL_TIMESTAMP_NULL;
sd_bus_error *error) {
User *u = userdata;
- Session *session;
int r;
assert(bus);
u->last_session_timestamp);
if (u->sessions) {
- Session *i;
bool first;
fputs("SESSIONS=", f);
}
int user_stop(User *u, bool force) {
- Session *s;
int r = 0;
+
assert(u);
/* This is called whenever we begin with tearing down a user record. It's called in two cases: explicit API
}
int user_finalize(User *u) {
- Session *s;
int r = 0, k;
assert(u);
}
int user_get_idle_hint(User *u, dual_timestamp *t) {
- Session *s;
bool idle_hint = true;
dual_timestamp ts = DUAL_TIMESTAMP_NULL;
}
UserState user_get_state(User *u) {
- Session *i;
-
assert(u);
if (u->stopping)
}
void user_elect_display(User *u) {
- Session *s;
-
assert(u);
/* This elects a primary session for each user, which we call the "display". We try to keep the assignment
static int manager_vt_switch(sd_event_source *src, const struct signalfd_siginfo *si, void *data) {
Manager *m = data;
- Session *active, *iter;
+ Session *active;
/*
* We got a VT-switch signal and we have to acknowledge it immediately.
return 0;
}
- if (active->vtfd >= 0) {
+ if (active->vtfd >= 0)
session_leave_vt(active);
- } else {
- LIST_FOREACH(sessions_by_seat, iter, m->seat0->sessions) {
+ else
+ LIST_FOREACH(sessions_by_seat, iter, m->seat0->sessions)
if (iter->vtnr == active->vtnr && iter->vtfd >= 0) {
session_leave_vt(iter);
break;
}
- }
- }
return 0;
}
int context_merge_networks(Context *context) {
Network *all, *network;
- Route *route;
int r;
assert(context);
}
void network_dump(Network *network, FILE *f) {
- Address *address;
- Route *route;
const char *dhcp;
char **dns;
}
static int wireguard_set_peer_one(NetDev *netdev, sd_netlink_message *message, const WireguardPeer *peer, uint16_t index, WireguardIPmask **mask_start) {
- WireguardIPmask *mask, *start;
+ WireguardIPmask *start, *last = NULL;
uint16_t j = 0;
int r;
r = wireguard_set_ipmask_one(netdev, message, mask, ++j);
if (r < 0)
return r;
- if (r == 0)
+ if (r == 0) {
+ last = mask;
break;
+ }
}
r = sd_netlink_message_close_container(message);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not add wireguard peer: %m");
- *mask_start = mask; /* Start next cycle from this mask. */
- return !mask;
+ *mask_start = last; /* Start next cycle from this mask. */
+ return !last;
cancel:
r = sd_netlink_message_cancel_array(message);
static int wireguard_set_interface(NetDev *netdev) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
WireguardIPmask *mask_start = NULL;
- WireguardPeer *peer, *peer_start;
+ WireguardPeer *peer_start;
bool sent_once = false;
uint32_t serial;
Wireguard *w;
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append wireguard peer attributes: %m");
+ WireguardPeer *peer_last = NULL;
LIST_FOREACH(peers, peer, peer_start) {
r = wireguard_set_peer_one(netdev, message, peer, ++i, &mask_start);
if (r < 0)
return r;
- if (r == 0)
+ if (r == 0) {
+ peer_last = peer;
break;
+ }
}
- peer_start = peer; /* Start next cycle from this peer. */
+ peer_start = peer_last; /* Start next cycle from this peer. */
r = sd_netlink_message_close_container(message);
if (r < 0)
}
static void wireguard_resolve_endpoints(NetDev *netdev) {
- WireguardPeer *peer;
Wireguard *w;
assert(netdev);
}
static int wireguard_verify(NetDev *netdev, const char *filename) {
- WireguardPeer *peer, *peer_next;
Wireguard *w;
int r;
"Ignoring network device.", filename);
LIST_FOREACH_SAFE(peers, peer, peer_next, w->peers) {
- WireguardIPmask *ipmask;
-
if (wireguard_peer_verify(peer) < 0) {
wireguard_peer_free(peer);
continue;
#include "util.h"
int expose_port_parse(ExposePort **l, const char *s) {
-
const char *split, *e;
uint16_t container_port, host_port;
+ ExposePort *port;
int protocol;
- ExposePort *p;
int r;
assert(l);
if (p->protocol == protocol && p->host_port == host_port)
return -EEXIST;
- p = new(ExposePort, 1);
- if (!p)
+ port = new(ExposePort, 1);
+ if (!port)
return -ENOMEM;
- *p = (ExposePort) {
+ *port = (ExposePort) {
.protocol = protocol,
.host_port = host_port,
.container_port = container_port,
};
- LIST_PREPEND(ports, *l, p);
+ LIST_PREPEND(ports, *l, port);
return 0;
}
}
int expose_port_flush(FirewallContext **fw_ctx, ExposePort* l, int af, union in_addr_union *exposed) {
- ExposePort *p;
int r;
assert(exposed);
int expose_port_execute(sd_netlink *rtnl, FirewallContext **fw_ctx, ExposePort *l, int af, union in_addr_union *exposed) {
_cleanup_free_ struct local_address *addresses = NULL;
union in_addr_union new_exposed;
- ExposePort *p;
bool add;
int r;
static bool context_drop_one_priority(Context *context) {
int32_t priority = 0;
- Partition *p;
bool exists = false;
LIST_FOREACH(partitions, p, context->partitions) {
}
static bool context_allocate_partitions(Context *context, uint64_t *ret_largest_free_area) {
- Partition *p;
-
assert(context);
/* Sort free areas by size, putting smallest first */
static int context_sum_weights(Context *context, FreeArea *a, uint64_t *ret) {
uint64_t weight_sum = 0;
- Partition *p;
assert(context);
assert(a);
uint64_t *span,
uint64_t *weight_sum) {
- Partition *p;
int r;
assert(context);
/* What? Even still some space left (maybe because there was no preceding partition, or it had a
* size limit), then let's donate it to whoever wants it. */
- if (span > 0) {
- Partition *p;
-
+ if (span > 0)
LIST_FOREACH(partitions, p, context->partitions) {
uint64_t m, xsz;
if (span == 0)
break;
}
- }
/* Yuck, still no one? Then make it padding */
if (span > 0 && a->after) {
}
static int context_grow_partitions(Context *context) {
- Partition *p;
int r;
assert(context);
static void context_place_partitions(Context *context) {
uint64_t partno = 0;
- Partition *p;
assert(context);
n_partitions = fdisk_table_get_nents(t);
for (size_t i = 0; i < n_partitions; i++) {
_cleanup_free_ char *label_copy = NULL;
- Partition *pp, *last = NULL;
+ Partition *last = NULL;
struct fdisk_partition *p;
struct fdisk_parttype *pt;
const char *pts, *ids, *label;
}
static void context_unload_partition_table(Context *context) {
- Partition *p, *next;
-
assert(context);
LIST_FOREACH_SAFE(partitions, p, next, context->partitions) {
static int context_dump_partitions(Context *context, const char *node) {
_cleanup_(table_unrefp) Table *t = NULL;
uint64_t sum_padding = 0, sum_size = 0;
- Partition *p;
int r;
if ((arg_json_format_flags & JSON_FORMAT_OFF) && context->n_partitions == 0) {
static int context_dump_partition_bar(Context *context, const char *node) {
_cleanup_free_ Partition **bar = NULL;
_cleanup_free_ size_t *start_array = NULL;
- Partition *p, *last = NULL;
+ Partition *last = NULL;
bool z = false;
size_t c, j = 0;
}
static bool context_changed(const Context *context) {
- Partition *p;
+ assert(context);
LIST_FOREACH(partitions, p, context->partitions) {
if (p->dropped)
static int context_discard_gap_after(Context *context, Partition *p) {
uint64_t gap, next = UINT64_MAX;
- Partition *q;
int r;
assert(context);
}
static int context_wipe_and_discard(Context *context, bool from_scratch) {
- Partition *p;
int r;
assert(context);
}
static int context_copy_blocks(Context *context) {
- Partition *p;
int whole_fd = -1, r;
assert(context);
}
static int context_mkfs(Context *context) {
- Partition *p;
int fd = -1, r;
assert(context);
} result;
uint64_t k = 0;
- Partition *q;
int r;
assert(context);
for (;;) {
const char *ll = label ?: prefix;
bool retry = false;
- Partition *q;
LIST_FOREACH(partitions, q, context->partitions) {
if (p == q)
}
static int context_acquire_partition_uuids_and_labels(Context *context) {
- Partition *p;
int r;
assert(context);
}
static int context_mangle_partitions(Context *context) {
- Partition *p;
int r;
assert(context);
}
static int context_factory_reset(Context *context, bool from_scratch) {
- Partition *p;
size_t n = 0;
int r;
}
static int context_can_factory_reset(Context *context) {
- Partition *p;
-
assert(context);
LIST_FOREACH(partitions, p, context->partitions)
const char *root,
dev_t restrict_devno) {
- Partition *p;
int r;
assert(context);
static int determine_auto_size(Context *c) {
uint64_t sum;
- Partition *p;
assert(c);
static int append_srv(DnsQuery *q, sd_bus_message *reply, DnsResourceRecord *rr) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *canonical = NULL;
_cleanup_free_ char *normalized = NULL;
- DnsQuery *aux;
int r;
assert(q);
}
static int append_txt(sd_bus_message *reply, DnsResourceRecord *rr) {
- DnsTxtItem *i;
int r;
assert(reply);
DnsQuestion *question;
DnsResourceRecord *rr;
unsigned added = 0;
- DnsQuery *aux;
int r;
assert(q);
bool extended) {
Manager *m = userdata;
- DnsServer *s;
Link *l;
int r;
sd_bus_error *error,
bool extended) {
- DnsServer *s, **f = userdata;
+ DnsServer **f = userdata;
int r;
assert(reply);
sd_bus_error *error) {
Manager *m = userdata;
- DnsSearchDomain *d;
Link *l;
int r;
uint64_t size = 0, hit = 0, miss = 0;
Manager *m = userdata;
- DnsScope *s;
assert(reply);
assert(m);
static int bus_method_reset_statistics(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
- DnsScope *s;
assert(message);
assert(m);
}
static bool dns_cache_remove_by_rr(DnsCache *c, DnsResourceRecord *rr) {
- DnsCacheItem *first, *i;
+ DnsCacheItem *first;
int r;
first = hashmap_get(c->by_key, rr->key);
}
static bool dns_cache_remove_by_key(DnsCache *c, DnsResourceKey *key) {
- DnsCacheItem *first, *i, *n;
+ DnsCacheItem *first;
assert(c);
assert(key);
}
static DnsCacheItem* dns_cache_get(DnsCache *c, DnsResourceRecord *rr) {
- DnsCacheItem *i;
-
assert(c);
assert(rr);
- LIST_FOREACH(by_key, i, hashmap_get(c->by_key, rr->key))
+ LIST_FOREACH(by_key, i, (DnsCacheItem*) hashmap_get(c->by_key, rr->key))
if (i->rr && dns_resource_record_equal(i->rr, rr) > 0)
return i;
unsigned n = 0;
int r;
bool nxdomain = false;
- DnsCacheItem *j, *first, *nsec = NULL;
+ DnsCacheItem *first, *nsec = NULL;
bool have_authenticated = false, have_non_authenticated = false, have_confidential = false, have_non_confidential = false;
usec_t current = 0;
int found_rcode = -1;
}
int dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_family, const union in_addr_union *owner_address) {
- DnsCacheItem *i, *first;
+ DnsCacheItem *first;
bool same_owner = true;
assert(cache);
assert(cache);
assert(p);
- HASHMAP_FOREACH(i, cache->by_key) {
- DnsCacheItem *j;
-
+ HASHMAP_FOREACH(i, cache->by_key)
LIST_FOREACH(by_key, j, i) {
if (!j->rr)
continue;
ancount++;
}
- }
DNS_PACKET_HEADER(p)->ancount = htobe16(ancount);
if (!f)
f = stdout;
- HASHMAP_FOREACH(i, cache->by_key) {
- DnsCacheItem *j;
-
+ HASHMAP_FOREACH(i, cache->by_key)
LIST_FOREACH(by_key, j, i) {
fputc('\t', f);
fputc('\n', f);
}
}
- }
}
bool dns_cache_is_empty(DnsCache *cache) {
r = dns_packet_append_raw_string(p, NULL, 0, NULL);
if (r < 0)
goto fail;
- } else {
- DnsTxtItem *i;
-
+ } else
LIST_FOREACH(items, i, rr->txt.items) {
r = dns_packet_append_raw_string(p, i->data, i->length, NULL);
if (r < 0)
goto fail;
}
- }
r = 0;
break;
}
static void dns_query_stop(DnsQuery *q) {
- DnsQueryCandidate *c;
-
assert(q);
event_source_disable(q->timeout_event_source);
int dns_query_go(DnsQuery *q) {
DnsScopeMatch found = DNS_SCOPE_NO;
- DnsScope *s, *first = NULL;
- DnsQueryCandidate *c;
+ DnsScope *first = NULL;
int r;
assert(q);
}
void dns_query_ready(DnsQuery *q) {
-
- DnsQueryCandidate *bad = NULL, *c;
+ DnsQueryCandidate *bad = NULL;
bool pending = false;
assert(q);
}
static char *format_txt(DnsTxtItem *first) {
- DnsTxtItem *i;
size_t c = 1;
char *p, *s;
case DNS_TYPE_TXT:
case DNS_TYPE_SPF: {
- DnsTxtItem *j;
-
LIST_FOREACH(items, j, rr->txt.items) {
siphash24_compress_safe(j->data, j->length, state);
}
DnsTxtItem *dns_txt_item_copy(DnsTxtItem *first) {
- DnsTxtItem *i, *copy = NULL, *end = NULL;
+ DnsTxtItem *copy = NULL, *end = NULL;
LIST_FOREACH(items, i, first) {
DnsTxtItem *j;
bool exclude_own) {
union in_addr_union ia;
- LinkAddress *a;
int f, r;
assert(s);
DnsQuery *q) {
DnsQuestion *question;
- DnsSearchDomain *d;
const char *domain;
uint64_t flags;
int ifindex;
DnsResourceKey *key,
uint64_t query_flags) {
- DnsTransaction *first, *t;
+ DnsTransaction *first;
assert(scope);
assert(key);
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
_cleanup_set_free_ Set *types = NULL;
- DnsTransaction *t;
- DnsZoneItem *z, *i;
+ DnsZoneItem *z;
unsigned size = 0;
char *service_type;
int r;
int dns_scope_add_dnssd_services(DnsScope *scope) {
DnssdService *service;
- DnssdTxtData *txt_data;
int r;
assert(scope);
int dns_scope_remove_dnssd_services(DnsScope *scope) {
_cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
DnssdService *service;
- DnssdTxtData *txt_data;
int r;
assert(scope);
}
static bool dns_scope_has_route_only_domains(DnsScope *scope) {
- DnsSearchDomain *domain, *first;
+ DnsSearchDomain *first;
bool route_only = false;
assert(scope);
}
int dns_search_domain_find(DnsSearchDomain *first, const char *name, DnsSearchDomain **ret) {
- DnsSearchDomain *d;
int r;
assert(name);
}
DnsServer *dns_server_find(DnsServer *first, int family, const union in_addr_union *in_addr, uint16_t port, int ifindex, const char *name) {
- DnsServer *s;
-
LIST_FOREACH(servers, s, first)
if (s->family == family &&
in_addr_equal(family, &s->address, in_addr) > 0 &&
}
void dns_server_reset_features_all(DnsServer *s) {
- DnsServer *i;
-
LIST_FOREACH(servers, i, s)
dns_server_reset_features(i);
}
}
}
- if (error != 0) {
- DnsTransaction *t, *n;
-
+ if (error != 0)
LIST_FOREACH_SAFE(transactions_by_stream, t, n, s->transactions)
on_transaction_stream_error(t, error);
- }
return 0;
}
static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
bool add_known_answers = false;
- DnsTransaction *other;
DnsResourceKey *tkey;
_cleanup_set_free_ Set *keys = NULL;
unsigned qdcount;
}
DnsZoneItem* dns_zone_get(DnsZone *z, DnsResourceRecord *rr) {
- DnsZoneItem *i;
-
assert(z);
assert(rr);
- LIST_FOREACH(by_key, i, hashmap_get(z->by_key, rr->key))
+ LIST_FOREACH(by_key, i, (DnsZoneItem*) hashmap_get(z->by_key, rr->key))
if (dns_resource_record_equal(i->rr, rr) > 0)
return i;
return r;
if (probe) {
- DnsZoneItem *first, *j;
bool established = false;
/* Check if there's already an RR with the same name
* established. If so, it has been probed already, and
* we don't need to probe again. */
- LIST_FIND_HEAD(by_name, i, first);
- LIST_FOREACH(by_name, j, first) {
- if (i == j)
- continue;
-
+ LIST_FOREACH_OTHERS(by_name, j, i)
if (j->state == DNS_ZONE_ITEM_ESTABLISHED)
established = true;
- }
if (established)
i->state = DNS_ZONE_ITEM_ESTABLISHED;
int dns_zone_lookup(DnsZone *z, DnsResourceKey *key, int ifindex, DnsAnswer **ret_answer, DnsAnswer **ret_soa, bool *ret_tentative) {
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL, *soa = NULL;
unsigned n_answer = 0;
- DnsZoneItem *j, *first;
+ DnsZoneItem *first;
bool tentative = true, need_soa = false;
int r;
}
int dns_zone_check_conflicts(DnsZone *zone, DnsResourceRecord *rr) {
- DnsZoneItem *i, *first;
+ DnsZoneItem *first;
int c = 0;
assert(zone);
}
int dns_zone_verify_conflicts(DnsZone *zone, DnsResourceKey *key) {
- DnsZoneItem *i, *first;
+ DnsZoneItem *first;
int c = 0;
assert(zone);
assert(zone);
- HASHMAP_FOREACH(i, zone->by_key) {
- DnsZoneItem *j;
-
+ HASHMAP_FOREACH(i, zone->by_key)
LIST_FOREACH(by_key, j, i)
dns_zone_item_verify(j);
- }
}
void dns_zone_dump(DnsZone *zone, FILE *f) {
if (!f)
f = stdout;
- HASHMAP_FOREACH(i, zone->by_key) {
- DnsZoneItem *j;
-
+ HASHMAP_FOREACH(i, zone->by_key)
LIST_FOREACH(by_key, j, i) {
const char *t;
fputs(t, f);
fputc('\n', f);
}
- }
}
bool dns_zone_is_empty(DnsZone *zone) {
}
bool dns_zone_contains_name(DnsZone *z, const char *name) {
- DnsZoneItem *i, *first;
+ DnsZoneItem *first;
first = hashmap_get(z->by_name, name);
if (!first)
int bus_dnssd_method_unregister(sd_bus_message *message, void *userdata, sd_bus_error *error) {
DnssdService *s = userdata;
- DnssdTxtData *txt_data;
Manager *m;
Link *l;
int r;
_cleanup_free_ char *n = NULL;
_cleanup_free_ char *service_name = NULL;
_cleanup_free_ char *full_name = NULL;
- DnssdTxtData *txt_data;
int r;
assert(s);
bool extended) {
Link *l = userdata;
- DnsServer *s;
int r;
assert(reply);
sd_bus_error *error) {
Link *l = userdata;
- DnsSearchDomain *d;
int r;
assert(reply);
}
void link_add_rrs(Link *l, bool force_remove) {
- LinkAddress *a;
int r;
LIST_FOREACH(addresses, a, l->addresses)
}
bool link_relevant(Link *l, int family, bool local_multicast) {
- LinkAddress *a;
-
assert(l);
/* A link is relevant for local multicast traffic if it isn't a loopback device, has a link
}
LinkAddress *link_find_address(Link *l, int family, const union in_addr_union *in_addr) {
- LinkAddress *a;
-
assert(l);
if (!IN_SET(family, AF_INET, AF_INET6))
fprintf(f, "DEFAULT_ROUTE=%s\n", yes_no(l->default_route));
if (l->dns_servers) {
- DnsServer *server;
-
fputs("SERVERS=", f);
LIST_FOREACH(servers, server, l->dns_servers) {
}
if (l->search_domains) {
- DnsSearchDomain *domain;
-
fputs("DOMAINS=", f);
LIST_FOREACH(domains, domain, l->search_domains) {
_cleanup_free_ char *buffer = NULL;
_cleanup_fclose_ FILE *f = NULL;
Manager *m = userdata;
- DnsServer *server;
size_t size = 0;
- DnsScope *scope;
Link *l;
assert(s);
}
void manager_verify_all(Manager *m) {
- DnsScope *s;
-
assert(m);
LIST_FOREACH(scopes, s, m->dns_scopes)
}
int manager_compile_dns_servers(Manager *m, OrderedSet **dns) {
- DnsServer *s;
Link *l;
int r;
* > 0 or true: return only domains which are for routing only
*/
int manager_compile_search_domains(Manager *m, OrderedSet **domains, int filter_route) {
- DnsSearchDomain *d;
Link *l;
int r;
}
void manager_flush_caches(Manager *m, int log_level) {
- DnsScope *scope;
-
assert(m);
LIST_FOREACH(scopes, scope, m->dns_scopes)
}
static bool sender_on_local_subnet(DnsScope *s, DnsPacket *p) {
- LinkAddress *a;
int r;
/* Check whether the sender is on a local subnet. */
if (dns_packet_validate_reply(p) > 0) {
DnsResourceRecord *rr;
- DnsTransaction *t;
log_debug("Got mDNS reply packet");
}
static void save_state_queue_remove(Context *c, int idx, const char *state_file) {
- struct write_queue_item *item, *tmp;
-
assert(c);
- LIST_FOREACH_SAFE(queue, item, tmp, c->write_queue) {
+ LIST_FOREACH_SAFE(queue, item, tmp, c->write_queue)
if ((state_file && streq(item->file, state_file)) || idx == item->rfkill_idx) {
log_debug("Canceled previous save state of '%s' to %s.", one_zero(item->state), item->file);
LIST_REMOVE(queue, c->write_queue, item);
write_queue_item_free(item);
}
- }
}
static int save_state_queue(Context *c, const struct rfkill_event *event) {
}
if (cg->children) {
- struct CGroupInfo **children, *child;
+ struct CGroupInfo **children;
size_t n = 0, i;
/* Order subcgroups by their name */
const char *name, *special;
bool more;
- child = children[i];
-
- name = strrchr(child->cgroup_path, '/');
+ name = strrchr(children[i]->cgroup_path, '/');
if (!name)
return -EINVAL;
name++;
if (!pp)
return -ENOMEM;
- r = dump_processes(cgroups, child->cgroup_path, pp, n_columns, flags);
+ r = dump_processes(cgroups, children[i]->cgroup_path, pp, n_columns, flags);
if (r < 0)
return r;
}
}
Condition* condition_free_list_type(Condition *head, ConditionType type) {
- Condition *c, *n;
-
LIST_FOREACH_SAFE(conditions, c, n, head)
if (type < 0 || c->type == type) {
LIST_REMOVE(conditions, head, c);
condition_test_logger_t logger,
void *userdata) {
- Condition *c;
int triggered = -1;
assert(!!logger == !!to_string);
}
void condition_dump_list(Condition *first, FILE *f, const char *prefix, condition_to_string_t to_string) {
- Condition *c;
-
LIST_FOREACH(conditions, c, first)
condition_dump(c, f, prefix, to_string);
}
}
const char* mount_options_from_designator(const MountOptions *options, PartitionDesignator designator) {
- const MountOptions *m;
-
LIST_FOREACH(mount_options, m, options)
if (designator == m->partition_designator && !isempty(m->options))
return m->options;
}
int varlink_server_attach_event(VarlinkServer *s, sd_event *e, int64_t priority) {
- VarlinkServerSocket *ss;
int r;
assert_return(s, -EINVAL);
}
int varlink_server_detach_event(VarlinkServer *s) {
- VarlinkServerSocket *ss;
-
assert_return(s, -EINVAL);
LIST_FOREACH(sockets, ss, s->sockets)
static void test_mount_points_list_one(const char *fname) {
_cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head);
_cleanup_free_ char *testdata_fname = NULL;
- MountPoint *m;
log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/self/mountinfo");
static void test_swap_list_one(const char *fname) {
_cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head);
_cleanup_free_ char *testdata_fname = NULL;
- MountPoint *m;
int r;
log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/swaps");
/* This includes remounting readonly, which changes the kernel mount options. Therefore the list passed to
* this function is invalidated, and should not be reused. */
static int mount_points_list_umount(MountPoint **head, bool *changed, int umount_log_level) {
- MountPoint *m;
int n_failed = 0;
assert(head);
}
static int swap_points_list_off(MountPoint **head, bool *changed) {
- MountPoint *m, *n;
int n_failed = 0;
assert(head);
}
static int loopback_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
- MountPoint *m, *n;
int n_failed = 0, r;
dev_t rootdev = 0;
}
static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
- MountPoint *m, *n;
int n_failed = 0, r;
dev_t rootdev = 0;
}
static int md_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
- MountPoint *m, *n;
int n_failed = 0, r;
dev_t rootdev = 0;
const char *active_on, *active_off, *on, *off, *ss, *fs;
_cleanup_free_ char *formatted_path = NULL;
- ExecStatusInfo *p;
usec_t timestamp;
const char *path;
char **t, **t2;
}
if (!i->condition_result && i->condition_timestamp > 0) {
- UnitCondition *c;
int n = 0;
printf(" Condition: start %scondition failed%s at %s; %s\n",
LIST_HEAD(list_item, head);
LIST_HEAD(list_item, head2);
list_item items[4];
- list_item *cursor;
LIST_HEAD_INIT(head);
LIST_HEAD_INIT(head2);
assert_se(items[2].item_prev == &items[3]);
assert_se(items[3].item_prev == NULL);
+ list_item *cursor;
LIST_FIND_HEAD(item, &items[0], cursor);
assert_se(cursor == &items[3]);
char **deny_rules) {
_cleanup_free_ char *exec_start = NULL;
_cleanup_(unit_freep) Unit *u = NULL;
- CGroupSocketBindItem *bi;
CGroupContext *cc = NULL;
char **rule;
int cld_code, r;
static int context_add_ntp_service(Context *c, const char *s, const char *source) {
_cleanup_(unit_status_info_freep) UnitStatusInfo *unit = NULL;
- UnitStatusInfo *u;
assert(c);
assert(s);
}
static int context_ntp_service_is_active(Context *c) {
- UnitStatusInfo *info;
int count = 0;
assert(c);
}
static int context_ntp_service_exists(Context *c) {
- UnitStatusInfo *info;
int count = 0;
assert(c);
{ "UnitFileState", "s", NULL, offsetof(UnitStatusInfo, unit_file_state) },
{}
};
- UnitStatusInfo *u;
int r;
assert(c);
static int match_job_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) {
Context *c = userdata;
- UnitStatusInfo *u;
const char *path;
unsigned n = 0;
int r;
_cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL;
sd_bus *bus = sd_bus_message_get_bus(m);
Context *c = userdata;
- UnitStatusInfo *u;
const UnitStatusInfo *selected = NULL;
int enable, interactive, q, r;
void *userdata,
sd_bus_error *error) {
- ServerName *p, **s = userdata;
+ ServerName **s = userdata;
int r;
assert(s);
for (;;) {
_cleanup_free_ char *word = NULL;
bool found = false;
- ServerName *n;
r = extract_first_word(&string, &word, NULL, 0);
if (r < 0)
static int manager_network_read_link_servers(Manager *m) {
_cleanup_strv_free_ char **ntp = NULL;
- ServerName *n, *nx;
char **i;
bool changed = false;
int r;
DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfig*, link_config_free);
static void link_configs_free(LinkConfigContext *ctx) {
- LinkConfig *config, *config_next;
-
if (!ctx)
return;
}
int link_get_config(LinkConfigContext *ctx, Link *link) {
- LinkConfig *config;
int r;
assert(ctx);
}
static void udev_rule_line_clear_tokens(UdevRuleLine *rule_line) {
- UdevRuleToken *i, *next;
-
assert(rule_line);
LIST_FOREACH_SAFE(tokens, i, next, rule_line->tokens)
DEFINE_TRIVIAL_CLEANUP_FUNC(UdevRuleLine*, udev_rule_line_free);
static void udev_rule_file_free(UdevRuleFile *rule_file) {
- UdevRuleLine *i, *next;
-
if (!rule_file)
return;
}
UdevRules *udev_rules_free(UdevRules *rules) {
- UdevRuleFile *i, *next;
-
if (!rules)
return NULL;
rule_line->current_token = NULL;
while (!LIST_IS_EMPTY(head_old)) {
- UdevRuleToken *t, *min_token = NULL;
+ UdevRuleToken *min_token = NULL;
LIST_FOREACH(tokens, t, head_old)
if (!min_token || min_token->type > t->type)
}
static void rule_resolve_goto(UdevRuleFile *rule_file) {
- UdevRuleLine *line, *line_next, *i;
-
assert(rule_file);
/* link GOTOs to LABEL rules in this file to be able to fast-forward */
head = rules->current_file->current_line->current_token;
event->dev_parent = event->dev;
for (;;) {
- LIST_FOREACH(tokens, line->current_token, head) {
- if (!token_is_for_parents(line->current_token))
+ line->current_token = NULL;
+ LIST_FOREACH(tokens, token, head) {
+ if (!token_is_for_parents(token))
return true; /* All parent tokens match. */
+
+ line->current_token = token;
r = udev_rule_apply_token_to_event(rules, event->dev_parent, event, 0, timeout_signal, NULL);
if (r < 0)
return r;
UdevRuleLine *line = rules->current_file->current_line;
UdevRuleLineType mask = LINE_HAS_GOTO | LINE_UPDATE_SOMETHING;
- UdevRuleToken *token, *next_token;
bool parents_done = false;
sd_device_action_t action;
int r;
int timeout_signal,
Hashmap *properties_list) {
- UdevRuleFile *file;
- UdevRuleLine *next_line;
int r;
assert(rules);
LIST_FOREACH(rule_files, file, rules->rule_files) {
rules->current_file = file;
- LIST_FOREACH_SAFE(rule_lines, file->current_line, next_line, file->rule_lines) {
+ LIST_FOREACH_SAFE(rule_lines, line, next_line, file->rule_lines) {
+ file->current_line = line;
r = udev_rule_apply_line_to_event(rules, event, timeout_usec, timeout_signal, properties_list, &next_line);
if (r < 0)
return r;
}
static int udev_rule_line_apply_static_dev_perms(UdevRuleLine *rule_line) {
- UdevRuleToken *token;
_cleanup_strv_free_ char **tags = NULL;
uid_t uid = UID_INVALID;
gid_t gid = GID_INVALID;
}
int udev_rules_apply_static_dev_perms(UdevRules *rules) {
- UdevRuleFile *file;
- UdevRuleLine *line;
int r;
assert(rules);
}
static void event_queue_cleanup(Manager *manager, EventState match_state) {
- Event *event, *tmp;
-
LIST_FOREACH_SAFE(event, event, tmp, manager->events) {
if (match_state != EVENT_UNDEF && match_state != event->state)
continue;
static int event_is_blocked(Event *event) {
const char *subsystem, *devpath, *devpath_old = NULL;
dev_t devnum = makedev(0, 0);
- Event *loop_event;
+ Event *loop_event = NULL;
size_t devpath_len;
int r, ifindex = 0;
bool is_block;
/* we have checked previously and no blocker found */
return false;
- LIST_FOREACH(event, loop_event, event->manager->events) {
+ LIST_FOREACH(event, e, event->manager->events) {
+ loop_event = e;
+
/* we already found a later event, earlier cannot block us, no need to check again */
if (loop_event->seqnum < event->blocker_seqnum)
continue;
return r;
/* check if queue contains events we depend on */
- LIST_FOREACH(event, loop_event, loop_event) {
+ LIST_FOREACH(event, e, loop_event) {
size_t loop_devpath_len, common;
const char *loop_devpath;
+ loop_event = e;
+
/* found ourself, no later event can block us */
if (loop_event->seqnum >= event->seqnum)
goto no_blocker;
}
static int event_queue_start(Manager *manager) {
- Event *event, *event_next;
usec_t usec;
int r;