aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2023-01-30 18:43:36 +0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2023-04-24 19:20:19 -0500
commit3f82d5b1a3e7456571488fd151ae84f9f30ef6cc (patch)
tree30655524ee739e48155ebc778fb891396ed9b626
parent0b4732520fbe50445cd05df58c7475659ee0a6f3 (diff)
rc: use LIST_FOREACH_SAFE in cleanup()
according to the linux manpage, the "safe" variant may not be available on all platform. however we bundle our own `queue.h` so this should not be an issue.
-rw-r--r--src/openrc/rc.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/openrc/rc.c b/src/openrc/rc.c
index b6bb811b..1b714297 100644
--- a/src/openrc/rc.c
+++ b/src/openrc/rc.c
@@ -117,8 +117,7 @@ clean_failed(void)
static void
cleanup(void)
{
- RC_PID *p1 = LIST_FIRST(&service_pids);
- RC_PID *p2;
+ RC_PID *p, *tmp;
if (!rc_in_logger && !rc_in_plugin &&
applet && (strcmp(applet, "rc") == 0 || strcmp(applet, "openrc") == 0))
@@ -140,16 +139,13 @@ cleanup(void)
rc_logger_close();
}
- while (p1) {
- p2 = LIST_NEXT(p1, entries);
- free(p1);
- p1 = p2;
+ LIST_FOREACH_SAFE(p, &service_pids, entries, tmp) {
+ LIST_REMOVE(p, entries);
+ free(p);
}
-
- for (p1 = LIST_FIRST(&free_these_pids); p1; /* no-op */) {
- p2 = LIST_NEXT(p1, entries);
- free(p1);
- p1 = p2;
+ LIST_FOREACH_SAFE(p, &free_these_pids, entries, tmp) {
+ LIST_REMOVE(p, entries);
+ free(p);
}
rc_stringlist_free(main_hotplugged_services);