]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use LIST_CLEAR()
authorDavid Tardon <dtardon@redhat.com>
Mon, 14 Aug 2023 14:07:46 +0000 (16:07 +0200)
committerDavid Tardon <dtardon@redhat.com>
Thu, 17 Aug 2023 07:48:17 +0000 (09:48 +0200)
src/core/cgroup.c
src/core/socket.c
src/libsystemd-network/sd-radv.c
src/network/netdev/wireguard.c
src/nspawn/nspawn-expose-ports.c
src/shared/bus-polkit.c
src/shared/open-file.c
src/shared/varlink.c
src/systemctl/systemctl-show.c
src/sysupdate/sysupdate-pattern.c
src/timedate/timedated.c

index 2ccfcbad72ed62ebcfcba81ca8ba00deeaebd54b..91ef33b12c922e4d426d4f30b3e0841563740cc2 100644 (file)
@@ -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) {
index 023c0ba3882a0e97fb5e918d5d735661a9a4109c..74d77692819591ee395d42d1dd74bd9250f4e37d 100644 (file)
@@ -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) {
index 890c146295070eea8994fdcd2495e8f58921a456..839c9a9ee6fc92df48eb503c79d3afcb4e2ec96a 100644 (file)
@@ -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);
index ffc6452bbfedc1d7a9dbe3d265978c491a6e9643..0e992f9ad1b183e6d3afb0ecd8f455ddc80e2963 100644 (file)
@@ -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) {
index b35f8b6a9ba2698a82cbcdb3f122bf8a0fe449b8..564406844675c430b410c0cc659de6842922134c 100644 (file)
@@ -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) {
index 2d9e521fc50f1fa02f1c88001ca163e270b34831..a68367d50b5006d2063902a08ad2aae15c701729 100644 (file)
@@ -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);
index 3402518555b3589a36c676086a2512cad3ed09bd..906a141d60d68a8e3075534785cbcab8d000acd7 100644 (file)
@@ -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] = {
index 41c2daf02bd8d21e12338ed405a0adf8fa509839..28068c686e31a8d4be096c3a84e379b0afd28b19 100644 (file)
@@ -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);
index 6422550af48afa54409f5068630385eaafe2e365..38cd4256e110373ea489d7e00602b2fbfae6d22c 100644 (file)
@@ -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) {
index c9e2067c58e7e34e7d68af051e802b104c2e22b2..6822d7eda227a4a8a2839dc1ff3a367ac4595fdc 100644 (file)
@@ -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;
 }
index ad1d492d6bb89e7bb5d14f664b5d023a8cc45e75..5ac7c9f8b248862de0517b4e679ddabbe7bed043 100644 (file)
@@ -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) {