1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00

core/umount: use _cleanup_ in one more place

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-11-27 16:13:04 +00:00
parent 1a96c8e1cc
commit 595c66a3db

View File

@ -159,7 +159,7 @@ static int swap_list_get(MountPoint **head) {
for (i = 2;; i++) { for (i = 2;; i++) {
MountPoint *swap; MountPoint *swap;
char *dev = NULL, *d; _cleanup_free_ char *dev = NULL, *d = NULL;
int k; int k;
k = fscanf(proc_swaps, k = fscanf(proc_swaps,
@ -175,27 +175,21 @@ static int swap_list_get(MountPoint **head) {
break; break;
log_warning("Failed to parse /proc/swaps:%u.", i); log_warning("Failed to parse /proc/swaps:%u.", i);
free(dev);
continue; continue;
} }
if (endswith(dev, " (deleted)")) { if (endswith(dev, " (deleted)"))
free(dev);
continue; continue;
}
r = cunescape(dev, UNESCAPE_RELAX, &d); r = cunescape(dev, UNESCAPE_RELAX, &d);
free(dev);
if (r < 0) if (r < 0)
return r; return r;
swap = new0(MountPoint, 1); swap = new0(MountPoint, 1);
if (!swap) { if (!swap)
free(d);
return -ENOMEM; return -ENOMEM;
}
swap->path = d; free_and_replace(swap->path, d);
LIST_PREPEND(mount_point, *head, swap); LIST_PREPEND(mount_point, *head, swap);
} }