tree-wide: use LIST_CLEAR()
This commit is contained in:
+1
-5
@@ -247,11 +247,7 @@ void cgroup_context_remove_bpf_foreign_program(CGroupContext *c, CGroupBPFForeig
|
||||
void cgroup_context_remove_socket_bind(CGroupSocketBindItem **head) {
|
||||
assert(head);
|
||||
|
||||
while (*head) {
|
||||
CGroupSocketBindItem *h = *head;
|
||||
LIST_REMOVE(socket_bind_items, *head, h);
|
||||
free(h);
|
||||
}
|
||||
LIST_CLEAR(socket_bind_items, *head, free);
|
||||
}
|
||||
|
||||
void cgroup_context_done(CGroupContext *c) {
|
||||
|
||||
+1
-6
@@ -134,14 +134,9 @@ SocketPort *socket_port_free(SocketPort *p) {
|
||||
}
|
||||
|
||||
void socket_free_ports(Socket *s) {
|
||||
SocketPort *p;
|
||||
|
||||
assert(s);
|
||||
|
||||
while ((p = s->ports)) {
|
||||
LIST_REMOVE(port, s->ports, p);
|
||||
socket_port_free(p);
|
||||
}
|
||||
LIST_CLEAR(port, s->ports, socket_port_free);
|
||||
}
|
||||
|
||||
static void socket_done(Unit *u) {
|
||||
|
||||
@@ -99,19 +99,8 @@ static sd_radv *radv_free(sd_radv *ra) {
|
||||
if (!ra)
|
||||
return NULL;
|
||||
|
||||
while (ra->prefixes) {
|
||||
sd_radv_prefix *p = ra->prefixes;
|
||||
|
||||
LIST_REMOVE(prefix, ra->prefixes, p);
|
||||
sd_radv_prefix_unref(p);
|
||||
}
|
||||
|
||||
while (ra->route_prefixes) {
|
||||
sd_radv_route_prefix *p = ra->route_prefixes;
|
||||
|
||||
LIST_REMOVE(prefix, ra->route_prefixes, p);
|
||||
sd_radv_route_prefix_unref(p);
|
||||
}
|
||||
LIST_CLEAR(prefix, ra->prefixes, sd_radv_prefix_unref);
|
||||
LIST_CLEAR(prefix, ra->route_prefixes, sd_radv_route_prefix_unref);
|
||||
|
||||
free(ra->rdnss);
|
||||
free(ra->dnssl);
|
||||
|
||||
@@ -35,14 +35,9 @@ static void wireguard_resolve_endpoints(NetDev *netdev);
|
||||
static int peer_resolve_endpoint(WireguardPeer *peer);
|
||||
|
||||
static void wireguard_peer_clear_ipmasks(WireguardPeer *peer) {
|
||||
WireguardIPmask *mask;
|
||||
|
||||
assert(peer);
|
||||
|
||||
while ((mask = peer->ipmasks)) {
|
||||
LIST_REMOVE(ipmasks, peer->ipmasks, mask);
|
||||
free(mask);
|
||||
}
|
||||
LIST_CLEAR(ipmasks, peer->ipmasks, free);
|
||||
}
|
||||
|
||||
static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
|
||||
|
||||
@@ -73,12 +73,7 @@ int expose_port_parse(ExposePort **l, const char *s) {
|
||||
}
|
||||
|
||||
void expose_port_free_all(ExposePort *p) {
|
||||
|
||||
while (p) {
|
||||
ExposePort *q = p;
|
||||
LIST_REMOVE(ports, p, q);
|
||||
free(q);
|
||||
}
|
||||
LIST_CLEAR(ports, p, free);
|
||||
}
|
||||
|
||||
int expose_port_flush(FirewallContext **fw_ctx, ExposePort* l, int af, union in_addr_union *exposed) {
|
||||
|
||||
@@ -204,8 +204,6 @@ typedef struct AsyncPolkitQuery {
|
||||
} AsyncPolkitQuery;
|
||||
|
||||
static AsyncPolkitQuery *async_polkit_query_free(AsyncPolkitQuery *q) {
|
||||
AsyncPolkitQueryAction *a;
|
||||
|
||||
if (!q)
|
||||
return NULL;
|
||||
|
||||
@@ -220,8 +218,7 @@ static AsyncPolkitQuery *async_polkit_query_free(AsyncPolkitQuery *q) {
|
||||
|
||||
sd_event_source_disable_unref(q->defer_event_source);
|
||||
|
||||
while ((a = LIST_POP(authorized, q->authorized_actions)))
|
||||
async_polkit_query_action_free(a);
|
||||
LIST_CLEAR(authorized, q->authorized_actions, async_polkit_query_action_free);
|
||||
|
||||
async_polkit_query_action_free(q->denied_action);
|
||||
async_polkit_query_action_free(q->error_action);
|
||||
|
||||
@@ -132,12 +132,7 @@ OpenFile *open_file_free(OpenFile *of) {
|
||||
}
|
||||
|
||||
void open_file_free_many(OpenFile **head) {
|
||||
OpenFile *of;
|
||||
|
||||
while ((of = *head)) {
|
||||
LIST_REMOVE(open_files, *head, of);
|
||||
of = open_file_free(of);
|
||||
}
|
||||
LIST_CLEAR(open_files, *head, open_file_free);
|
||||
}
|
||||
|
||||
static const char * const open_file_flags_table[_OPENFILE_MAX] = {
|
||||
|
||||
@@ -473,12 +473,7 @@ static void varlink_clear(Varlink *v) {
|
||||
v->pushed_fds = mfree(v->pushed_fds);
|
||||
v->n_pushed_fds = 0;
|
||||
|
||||
while (v->output_queue) {
|
||||
VarlinkJsonQueueItem *q = v->output_queue;
|
||||
|
||||
LIST_REMOVE(queue, v->output_queue, q);
|
||||
varlink_json_queue_item_free(q);
|
||||
}
|
||||
LIST_CLEAR(queue, v->output_queue, varlink_json_queue_item_free);
|
||||
v->output_queue_tail = NULL;
|
||||
|
||||
v->event = sd_event_unref(v->event);
|
||||
|
||||
@@ -279,24 +279,14 @@ typedef struct UnitStatusInfo {
|
||||
} UnitStatusInfo;
|
||||
|
||||
static void unit_status_info_free(UnitStatusInfo *info) {
|
||||
ExecStatusInfo *p;
|
||||
UnitCondition *c;
|
||||
|
||||
strv_free(info->documentation);
|
||||
strv_free(info->dropin_paths);
|
||||
strv_free(info->triggered_by);
|
||||
strv_free(info->triggers);
|
||||
strv_free(info->listen);
|
||||
|
||||
while ((c = info->conditions)) {
|
||||
LIST_REMOVE(conditions, info->conditions, c);
|
||||
unit_condition_free(c);
|
||||
}
|
||||
|
||||
while ((p = info->exec_status_info_list)) {
|
||||
LIST_REMOVE(exec_status_info_list, info->exec_status_info_list, p);
|
||||
exec_status_info_free(p);
|
||||
}
|
||||
LIST_CLEAR(conditions, info->conditions, unit_condition_free);
|
||||
LIST_CLEAR(exec_status_info_list, info->exec_status_info_list, exec_status_info_free);
|
||||
}
|
||||
|
||||
static void format_active_state(const char *active_state, const char **active_on, const char **active_off) {
|
||||
|
||||
@@ -36,10 +36,7 @@ struct PatternElement {
|
||||
};
|
||||
|
||||
static PatternElement *pattern_element_free_all(PatternElement *e) {
|
||||
PatternElement *p;
|
||||
|
||||
while ((p = LIST_POP(elements, e)))
|
||||
free(p);
|
||||
LIST_CLEAR(elements, e, free);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -115,8 +115,6 @@ static UnitStatusInfo *unit_status_info_free(UnitStatusInfo *p) {
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(UnitStatusInfo*, unit_status_info_free);
|
||||
|
||||
static void context_clear(Context *c) {
|
||||
UnitStatusInfo *p;
|
||||
|
||||
assert(c);
|
||||
|
||||
free(c->zone);
|
||||
@@ -125,10 +123,7 @@ static void context_clear(Context *c) {
|
||||
|
||||
sd_bus_slot_unref(c->slot_job_removed);
|
||||
|
||||
while ((p = c->units)) {
|
||||
LIST_REMOVE(units, c->units, p);
|
||||
unit_status_info_free(p);
|
||||
}
|
||||
LIST_CLEAR(units, c->units, unit_status_info_free);
|
||||
}
|
||||
|
||||
static int context_add_ntp_service(Context *c, const char *s, const char *source) {
|
||||
|
||||
Reference in New Issue
Block a user