summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-09 20:55:45 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-09-09 21:16:37 +0900
commit88b5080ea9633fa0fb537f0f296fbf93b8107e1c (patch)
treea96fa109ac12b36d24f397301d66cc36e9b54587 /src
parent89ad604839f9185af2e78da0e411c2f9b6d92953 (diff)
downloadsystemd-88b5080ea9633fa0fb537f0f296fbf93b8107e1c.tar.gz
sd-device-enumerator: use _cleanup_free_ attribute for safety
No functional changes, just improve readability. Suggested by https://github.com/systemd/systemd/pull/24601#discussion_r966883459.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-device/device-enumerator.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c
index 5afe9f348f..a583a37dab 100644
--- a/src/libsystemd/sd-device/device-enumerator.c
+++ b/src/libsystemd/sd-device/device-enumerator.c
@@ -935,13 +935,17 @@ static int enumerator_scan_devices_children(sd_device_enumerator *enumerator) {
r = k;
}
- for (char *p; (p = set_steal_first(stack)); free(p)) {
+ for (;;) {
+ _cleanup_free_ char *p = NULL;
+
+ p = set_steal_first(stack);
+ if (!p)
+ return r;
+
k = parent_crawl_children(enumerator, p, &stack);
if (k < 0)
r = k;
}
-
- return r;
}
static int enumerator_scan_devices_all(sd_device_enumerator *enumerator) {