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.
This commit is contained in:
Yu Watanabe
2022-09-09 20:55:45 +09:00
parent 89ad604839
commit 88b5080ea9

View File

@@ -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) {