From 595c66a3db50b23d25aee24f253c2a9009344956 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 27 Nov 2017 16:13:04 +0000 Subject: [PATCH] core/umount: use _cleanup_ in one more place --- src/core/umount.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/core/umount.c b/src/core/umount.c index cd195e12af6..cd58a9cf6d7 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -159,7 +159,7 @@ static int swap_list_get(MountPoint **head) { for (i = 2;; i++) { MountPoint *swap; - char *dev = NULL, *d; + _cleanup_free_ char *dev = NULL, *d = NULL; int k; k = fscanf(proc_swaps, @@ -175,27 +175,21 @@ static int swap_list_get(MountPoint **head) { break; log_warning("Failed to parse /proc/swaps:%u.", i); - free(dev); continue; } - if (endswith(dev, " (deleted)")) { - free(dev); + if (endswith(dev, " (deleted)")) continue; - } r = cunescape(dev, UNESCAPE_RELAX, &d); - free(dev); if (r < 0) return r; swap = new0(MountPoint, 1); - if (!swap) { - free(d); + if (!swap) return -ENOMEM; - } - swap->path = d; + free_and_replace(swap->path, d); LIST_PREPEND(mount_point, *head, swap); } -- 2.47.3