Skip to content

Commit 52e3671

Browse files
committed
tree-wide: use LIST_POP()
1 parent 9aad490 commit 52e3671

File tree

9 files changed

+19
-39
lines changed

9 files changed

+19
-39
lines changed

src/core/execute.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6326,8 +6326,7 @@ void exec_command_done_array(ExecCommand *c, size_t n) {
63266326
ExecCommand* exec_command_free_list(ExecCommand *c) {
63276327
ExecCommand *i;
63286328

6329-
while ((i = c)) {
6330-
LIST_REMOVE(command, c, i);
6329+
while ((i = LIST_POP(command, c))) {
63316330
exec_command_done(i);
63326331
free(i);
63336332
}

src/core/manager.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,10 +1257,8 @@ static unsigned manager_dispatch_release_resources_queue(Manager *m) {
12571257

12581258
assert(m);
12591259

1260-
while ((u = m->release_resources_queue)) {
1260+
while ((u = LIST_POP(release_resources_queue, m->release_resources_queue))) {
12611261
assert(u->in_release_resources_queue);
1262-
1263-
LIST_REMOVE(release_resources_queue, m->release_resources_queue, u);
12641262
u->in_release_resources_queue = false;
12651263

12661264
n++;
@@ -1364,12 +1362,11 @@ static unsigned manager_dispatch_gc_unit_queue(Manager *m) {
13641362

13651363
gc_marker = m->gc_marker;
13661364

1367-
while ((u = m->gc_unit_queue)) {
1365+
while ((u = LIST_POP(gc_queue, m->gc_unit_queue))) {
13681366
assert(u->in_gc_queue);
13691367

13701368
unit_gc_sweep(u, gc_marker);
13711369

1372-
LIST_REMOVE(gc_queue, m->gc_unit_queue, u);
13731370
u->in_gc_queue = false;
13741371

13751372
n++;
@@ -1392,10 +1389,8 @@ static unsigned manager_dispatch_gc_job_queue(Manager *m) {
13921389

13931390
assert(m);
13941391

1395-
while ((j = m->gc_job_queue)) {
1392+
while ((j = LIST_POP(gc_queue, m->gc_job_queue))) {
13961393
assert(j->in_gc_queue);
1397-
1398-
LIST_REMOVE(gc_queue, m->gc_job_queue, j);
13991394
j->in_gc_queue = false;
14001395

14011396
n++;
@@ -1459,11 +1454,10 @@ static unsigned manager_dispatch_stop_when_unneeded_queue(Manager *m) {
14591454

14601455
assert(m);
14611456

1462-
while ((u = m->stop_when_unneeded_queue)) {
1457+
while ((u = LIST_POP(stop_when_unneeded_queue, m->stop_when_unneeded_queue))) {
14631458
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
14641459

14651460
assert(u->in_stop_when_unneeded_queue);
1466-
LIST_REMOVE(stop_when_unneeded_queue, m->stop_when_unneeded_queue, u);
14671461
u->in_stop_when_unneeded_queue = false;
14681462

14691463
n++;
@@ -1500,12 +1494,11 @@ static unsigned manager_dispatch_start_when_upheld_queue(Manager *m) {
15001494

15011495
assert(m);
15021496

1503-
while ((u = m->start_when_upheld_queue)) {
1497+
while ((u = LIST_POP(start_when_upheld_queue, m->start_when_upheld_queue))) {
15041498
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
15051499
Unit *culprit = NULL;
15061500

15071501
assert(u->in_start_when_upheld_queue);
1508-
LIST_REMOVE(start_when_upheld_queue, m->start_when_upheld_queue, u);
15091502
u->in_start_when_upheld_queue = false;
15101503

15111504
n++;
@@ -1542,12 +1535,11 @@ static unsigned manager_dispatch_stop_when_bound_queue(Manager *m) {
15421535

15431536
assert(m);
15441537

1545-
while ((u = m->stop_when_bound_queue)) {
1538+
while ((u = LIST_POP(stop_when_bound_queue, m->stop_when_bound_queue))) {
15461539
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
15471540
Unit *culprit = NULL;
15481541

15491542
assert(u->in_stop_when_bound_queue);
1550-
LIST_REMOVE(stop_when_bound_queue, m->stop_when_bound_queue, u);
15511543
u->in_stop_when_bound_queue = false;
15521544

15531545
n++;
@@ -2177,13 +2169,12 @@ static int manager_dispatch_target_deps_queue(Manager *m) {
21772169

21782170
assert(m);
21792171

2180-
while ((u = m->target_deps_queue)) {
2172+
while ((u = LIST_POP(target_deps_queue, m->target_deps_queue))) {
21812173
_cleanup_free_ Unit **targets = NULL;
21822174
int n_targets;
21832175

21842176
assert(u->in_target_deps_queue);
21852177

2186-
LIST_REMOVE(target_deps_queue, u->manager->target_deps_queue, u);
21872178
u->in_target_deps_queue = false;
21882179

21892180
/* Take an "atomic" snapshot of dependencies here, as the call below will likely modify the

src/core/path.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,8 @@ void path_free_specs(Path *p) {
288288

289289
assert(p);
290290

291-
while ((s = p->specs)) {
291+
while ((s = LIST_POP(spec, p->specs))) {
292292
path_spec_unwatch(s);
293-
LIST_REMOVE(spec, p->specs, s);
294293
path_spec_done(s);
295294
free(s);
296295
}

src/core/timer.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ void timer_free_values(Timer *t) {
5151

5252
assert(t);
5353

54-
while ((v = t->values)) {
55-
LIST_REMOVE(value, t->values, v);
54+
while ((v = LIST_POP(value, t->values))) {
5655
calendar_spec_free(v->calendar_spec);
5756
free(v);
5857
}

src/libsystemd-network/sd-dhcp-lease.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,11 @@ int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, const void **data, s
345345
}
346346

347347
static sd_dhcp_lease *dhcp_lease_free(sd_dhcp_lease *lease) {
348-
assert(lease);
349-
350-
while (lease->private_options) {
351-
struct sd_dhcp_raw_option *option = lease->private_options;
348+
struct sd_dhcp_raw_option *option;
352349

353-
LIST_REMOVE(options, lease->private_options, option);
350+
assert(lease);
354351

352+
while ((option = LIST_POP(options, lease->private_options))) {
355353
free(option->data);
356354
free(option);
357355
}

src/login/logind.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,7 @@ static void manager_gc(Manager *m, bool drop_not_started) {
907907

908908
assert(m);
909909

910-
while ((seat = m->seat_gc_queue)) {
911-
LIST_REMOVE(gc_queue, m->seat_gc_queue, seat);
910+
while ((seat = LIST_POP(gc_queue, m->seat_gc_queue))) {
912911
seat->in_gc_queue = false;
913912

914913
if (seat_may_gc(seat, drop_not_started)) {
@@ -917,8 +916,7 @@ static void manager_gc(Manager *m, bool drop_not_started) {
917916
}
918917
}
919918

920-
while ((session = m->session_gc_queue)) {
921-
LIST_REMOVE(gc_queue, m->session_gc_queue, session);
919+
while ((session = LIST_POP(gc_queue, m->session_gc_queue))) {
922920
session->in_gc_queue = false;
923921

924922
/* First, if we are not closing yet, initiate stopping. */
@@ -934,8 +932,7 @@ static void manager_gc(Manager *m, bool drop_not_started) {
934932
}
935933
}
936934

937-
while ((user = m->user_gc_queue)) {
938-
LIST_REMOVE(gc_queue, m->user_gc_queue, user);
935+
while ((user = LIST_POP(gc_queue, m->user_gc_queue))) {
939936
user->in_gc_queue = false;
940937

941938
/* First step: queue stop jobs */

src/machine/machined.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ static void manager_gc(Manager *m, bool drop_not_started) {
254254

255255
assert(m);
256256

257-
while ((machine = m->machine_gc_queue)) {
258-
LIST_REMOVE(gc_queue, m->machine_gc_queue, machine);
257+
while ((machine = LIST_POP(gc_queue, m->machine_gc_queue))) {
259258
machine->in_gc_queue = false;
260259

261260
/* First, if we are not closing yet, initiate stopping */

src/rfkill/rfkill.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ static void context_save_and_clear(Context *c) {
257257

258258
assert(c);
259259

260-
while ((i = c->write_queue)) {
261-
LIST_REMOVE(queue, c->write_queue, i);
260+
while ((i = LIST_POP(queue, c->write_queue))) {
262261
(void) save_state_write_one(i);
263262
write_queue_item_free(i);
264263
}

src/shared/dissect-image.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3689,8 +3689,7 @@ bool dissected_image_verity_sig_ready(const DissectedImage *image, PartitionDesi
36893689
MountOptions* mount_options_free_all(MountOptions *options) {
36903690
MountOptions *m;
36913691

3692-
while ((m = options)) {
3693-
LIST_REMOVE(mount_options, options, m);
3692+
while ((m = LIST_POP(mount_options, options))) {
36943693
free(m->options);
36953694
free(m);
36963695
}

0 commit comments

Comments
 (0)