From 8090b41ed534ad00433ef56445f2a61e121baddd Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 1 Sep 2018 23:07:18 +0900 Subject: [PATCH] gpt-auto-generator: do not assign '*ret' on error --- src/gpt-auto-generator/gpt-auto-generator.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index a088df8..6b75221 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -462,34 +462,34 @@ static int open_parent(dev_t devnum, int *ret) { r = sd_device_get_syspath(d, &name); if (r < 0) { log_debug_errno(r, "Device %u:%u does not have a name, ignoring: %m", major(devnum), minor(devnum)); - goto not_found; + return 0; } } r = sd_device_get_parent(d, &parent); if (r < 0) { log_debug_errno(r, "%s: not a partitioned device, ignoring: %m", name); - goto not_found; + return 0; } /* Does it have a devtype? */ r = sd_device_get_devtype(parent, &devtype); if (r < 0) { log_debug_errno(r, "%s: parent doesn't have a device type, ignoring: %m", name); - goto not_found; + return 0; } /* Is this a disk or a partition? We only care for disks... */ if (!streq(devtype, "disk")) { log_debug("%s: parent isn't a raw disk, ignoring.", name); - goto not_found; + return 0; } /* Does it have a device node? */ r = sd_device_get_devname(parent, &node); if (r < 0) { log_debug_errno(r, "%s: parent device does not have device node, ignoring: %m", name); - goto not_found; + return 0; } log_debug("%s: root device %s.", name, node); @@ -497,7 +497,7 @@ static int open_parent(dev_t devnum, int *ret) { r = sd_device_get_devnum(parent, &pn); if (r < 0) { log_debug_errno(r, "%s: parent device is not a proper block device, ignoring: %m", name); - goto not_found; + return 0; } fd = open(node, O_RDONLY|O_CLOEXEC|O_NOCTTY); @@ -506,14 +506,9 @@ static int open_parent(dev_t devnum, int *ret) { *ret = fd; return 1; - -not_found: - *ret = -1; - return 0; } static int enumerate_partitions(dev_t devnum) { - _cleanup_close_ int fd = -1; _cleanup_(dissected_image_unrefp) DissectedImage *m = NULL; int r, k; -- 2.7.4