]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use LIST_POP()
authorDavid Tardon <dtardon@redhat.com>
Mon, 14 Aug 2023 14:32:55 +0000 (16:32 +0200)
committerDavid Tardon <dtardon@redhat.com>
Thu, 17 Aug 2023 07:48:17 +0000 (09:48 +0200)
src/core/execute.c
src/core/manager.c
src/core/path.c
src/core/timer.c
src/libsystemd-network/sd-dhcp-lease.c
src/login/logind.c
src/machine/machined.c
src/rfkill/rfkill.c
src/shared/dissect-image.c

index 95349a4fb65f37618418c84fc7eb08a8ed9c0126..f9761b7239e5814208cecac9737437aa8e7821ee 100644 (file)
@@ -6326,8 +6326,7 @@ void exec_command_done_array(ExecCommand *c, size_t n) {
 ExecCommand* exec_command_free_list(ExecCommand *c) {
         ExecCommand *i;
 
-        while ((i = c)) {
-                LIST_REMOVE(command, c, i);
+        while ((i = LIST_POP(command, c))) {
                 exec_command_done(i);
                 free(i);
         }
index 53a1b41b0edb027d34f3e3b726fc2443bde30fa8..304abf4697a0981c3b78df8ba82860b289f2c542 100644 (file)
@@ -1257,10 +1257,8 @@ static unsigned manager_dispatch_release_resources_queue(Manager *m) {
 
         assert(m);
 
-        while ((u = m->release_resources_queue)) {
+        while ((u = LIST_POP(release_resources_queue, m->release_resources_queue))) {
                 assert(u->in_release_resources_queue);
-
-                LIST_REMOVE(release_resources_queue, m->release_resources_queue, u);
                 u->in_release_resources_queue = false;
 
                 n++;
@@ -1364,12 +1362,11 @@ static unsigned manager_dispatch_gc_unit_queue(Manager *m) {
 
         gc_marker = m->gc_marker;
 
-        while ((u = m->gc_unit_queue)) {
+        while ((u = LIST_POP(gc_queue, m->gc_unit_queue))) {
                 assert(u->in_gc_queue);
 
                 unit_gc_sweep(u, gc_marker);
 
-                LIST_REMOVE(gc_queue, m->gc_unit_queue, u);
                 u->in_gc_queue = false;
 
                 n++;
@@ -1392,10 +1389,8 @@ static unsigned manager_dispatch_gc_job_queue(Manager *m) {
 
         assert(m);
 
-        while ((j = m->gc_job_queue)) {
+        while ((j = LIST_POP(gc_queue, m->gc_job_queue))) {
                 assert(j->in_gc_queue);
-
-                LIST_REMOVE(gc_queue, m->gc_job_queue, j);
                 j->in_gc_queue = false;
 
                 n++;
@@ -1459,11 +1454,10 @@ static unsigned manager_dispatch_stop_when_unneeded_queue(Manager *m) {
 
         assert(m);
 
-        while ((u = m->stop_when_unneeded_queue)) {
+        while ((u = LIST_POP(stop_when_unneeded_queue, m->stop_when_unneeded_queue))) {
                 _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
 
                 assert(u->in_stop_when_unneeded_queue);
-                LIST_REMOVE(stop_when_unneeded_queue, m->stop_when_unneeded_queue, u);
                 u->in_stop_when_unneeded_queue = false;
 
                 n++;
@@ -1500,12 +1494,11 @@ static unsigned manager_dispatch_start_when_upheld_queue(Manager *m) {
 
         assert(m);
 
-        while ((u = m->start_when_upheld_queue)) {
+        while ((u = LIST_POP(start_when_upheld_queue, m->start_when_upheld_queue))) {
                 _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
                 Unit *culprit = NULL;
 
                 assert(u->in_start_when_upheld_queue);
-                LIST_REMOVE(start_when_upheld_queue, m->start_when_upheld_queue, u);
                 u->in_start_when_upheld_queue = false;
 
                 n++;
@@ -1542,12 +1535,11 @@ static unsigned manager_dispatch_stop_when_bound_queue(Manager *m) {
 
         assert(m);
 
-        while ((u = m->stop_when_bound_queue)) {
+        while ((u = LIST_POP(stop_when_bound_queue, m->stop_when_bound_queue))) {
                 _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
                 Unit *culprit = NULL;
 
                 assert(u->in_stop_when_bound_queue);
-                LIST_REMOVE(stop_when_bound_queue, m->stop_when_bound_queue, u);
                 u->in_stop_when_bound_queue = false;
 
                 n++;
@@ -2177,13 +2169,12 @@ static int manager_dispatch_target_deps_queue(Manager *m) {
 
         assert(m);
 
-        while ((u = m->target_deps_queue)) {
+        while ((u = LIST_POP(target_deps_queue, m->target_deps_queue))) {
                 _cleanup_free_ Unit **targets = NULL;
                 int n_targets;
 
                 assert(u->in_target_deps_queue);
 
-                LIST_REMOVE(target_deps_queue, u->manager->target_deps_queue, u);
                 u->in_target_deps_queue = false;
 
                 /* Take an "atomic" snapshot of dependencies here, as the call below will likely modify the
index b06b97d7124de7eb0a8af3b29c058b05a0cf783d..d5651cd9d8323806efdd6729459d9f674847496a 100644 (file)
@@ -288,9 +288,8 @@ void path_free_specs(Path *p) {
 
         assert(p);
 
-        while ((s = p->specs)) {
+        while ((s = LIST_POP(spec, p->specs))) {
                 path_spec_unwatch(s);
-                LIST_REMOVE(spec, p->specs, s);
                 path_spec_done(s);
                 free(s);
         }
index 17faa5cbfbb4bc0a03e0474d5e62c101db24505e..5a68f07e9dae5124daacdba3b786a3850d257225 100644 (file)
@@ -51,8 +51,7 @@ void timer_free_values(Timer *t) {
 
         assert(t);
 
-        while ((v = t->values)) {
-                LIST_REMOVE(value, t->values, v);
+        while ((v = LIST_POP(value, t->values))) {
                 calendar_spec_free(v->calendar_spec);
                 free(v);
         }
index 5e8869a3b7168ebc3af128c2bb7c0e6a68e8f761..791314e9cc7fbb4eff9525703b62d1da11fb45e2 100644 (file)
@@ -345,13 +345,11 @@ int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, const void **data, s
 }
 
 static sd_dhcp_lease *dhcp_lease_free(sd_dhcp_lease *lease) {
-        assert(lease);
-
-        while (lease->private_options) {
-                struct sd_dhcp_raw_option *option = lease->private_options;
+        struct sd_dhcp_raw_option *option;
 
-                LIST_REMOVE(options, lease->private_options, option);
+        assert(lease);
 
+        while ((option = LIST_POP(options, lease->private_options))) {
                 free(option->data);
                 free(option);
         }
index f30f7f9370485c42f92aaa02641a380d2366b34e..ba3a31b0a405cd0deecfac9e25861fcbcb72b626 100644 (file)
@@ -907,8 +907,7 @@ static void manager_gc(Manager *m, bool drop_not_started) {
 
         assert(m);
 
-        while ((seat = m->seat_gc_queue)) {
-                LIST_REMOVE(gc_queue, m->seat_gc_queue, seat);
+        while ((seat = LIST_POP(gc_queue, m->seat_gc_queue))) {
                 seat->in_gc_queue = false;
 
                 if (seat_may_gc(seat, drop_not_started)) {
@@ -917,8 +916,7 @@ static void manager_gc(Manager *m, bool drop_not_started) {
                 }
         }
 
-        while ((session = m->session_gc_queue)) {
-                LIST_REMOVE(gc_queue, m->session_gc_queue, session);
+        while ((session = LIST_POP(gc_queue, m->session_gc_queue))) {
                 session->in_gc_queue = false;
 
                 /* First, if we are not closing yet, initiate stopping. */
@@ -934,8 +932,7 @@ static void manager_gc(Manager *m, bool drop_not_started) {
                 }
         }
 
-        while ((user = m->user_gc_queue)) {
-                LIST_REMOVE(gc_queue, m->user_gc_queue, user);
+        while ((user = LIST_POP(gc_queue, m->user_gc_queue))) {
                 user->in_gc_queue = false;
 
                 /* First step: queue stop jobs */
index 8152bda50d19a58fb3b9f386ad2a3f8e935edb9e..926a8a7f2b69f94ad28a84879caa672deb853163 100644 (file)
@@ -254,8 +254,7 @@ static void manager_gc(Manager *m, bool drop_not_started) {
 
         assert(m);
 
-        while ((machine = m->machine_gc_queue)) {
-                LIST_REMOVE(gc_queue, m->machine_gc_queue, machine);
+        while ((machine = LIST_POP(gc_queue, m->machine_gc_queue))) {
                 machine->in_gc_queue = false;
 
                 /* First, if we are not closing yet, initiate stopping */
index c4e93737f54f307bd9e4387912529080f7e73a66..be2a7f8d29a7fcc4ac1fc43aee76bea208863e95 100644 (file)
@@ -257,8 +257,7 @@ static void context_save_and_clear(Context *c) {
 
         assert(c);
 
-        while ((i = c->write_queue)) {
-                LIST_REMOVE(queue, c->write_queue, i);
+        while ((i = LIST_POP(queue, c->write_queue))) {
                 (void) save_state_write_one(i);
                 write_queue_item_free(i);
         }
index 3b77706f8fb2b6993199ae781bc97ecb7a8c35b4..c361a7a4614ee25510dac6da225250b6f89bb7b1 100644 (file)
@@ -3689,8 +3689,7 @@ bool dissected_image_verity_sig_ready(const DissectedImage *image, PartitionDesi
 MountOptions* mount_options_free_all(MountOptions *options) {
         MountOptions *m;
 
-        while ((m = options)) {
-                LIST_REMOVE(mount_options, options, m);
+        while ((m = LIST_POP(mount_options, options))) {
                 free(m->options);
                 free(m);
         }