gpt-auto-generator: do not assign '*ret' on error

This commit is contained in:
Yu Watanabe 2018-09-01 23:07:18 +09:00
parent 403660c508
commit 8090b41ed5
1 changed files with 6 additions and 11 deletions

View File

@ -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;