blockdev-util: don't use mixed style of retval in block_device_get_originating
We have two typical styles of 'ret' param assignment + retval: 1) < 0 on actual error, 0 on nothing (ret == NULL), > 0 on something 2) recognizable errno on nothing, < 0 on other errors, >= 0 on something but never use both at the same time.
This commit is contained in:
@@ -138,7 +138,7 @@ int block_device_get_originating(sd_device *dev, sd_device **ret) {
|
||||
return -ENOENT;
|
||||
|
||||
*ret = TAKE_PTR(first_found);
|
||||
return 1; /* found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int block_device_new_from_fd(int fd, BlockDeviceLookupFlag flags, sd_device **ret) {
|
||||
@@ -166,10 +166,10 @@ int block_device_new_from_fd(int fd, BlockDeviceLookupFlag flags, sd_device **re
|
||||
return r;
|
||||
|
||||
r = block_device_get_originating(dev_whole_disk, &dev_origin);
|
||||
if (r < 0 && r != -ENOENT)
|
||||
return r;
|
||||
if (r > 0)
|
||||
if (r >= 0)
|
||||
device_unref_and_replace(dev, dev_origin);
|
||||
else if (r != -ENOENT)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (FLAGS_SET(flags, BLOCK_DEVICE_LOOKUP_WHOLE_DISK)) {
|
||||
|
||||
@@ -842,7 +842,7 @@ static void device_track_back(sd_device *d, sd_device **ret) {
|
||||
|
||||
_cleanup_(sd_device_unrefp) sd_device *d_originating = NULL;
|
||||
r = block_device_get_originating(d, &d_originating);
|
||||
if (r < 0)
|
||||
if (r < 0 && r != -ENOENT)
|
||||
log_device_debug_errno(d, r, "Failed to get originating device for '%s', ignoring: %m", strna(devname));
|
||||
|
||||
sd_device *d_whole = NULL;
|
||||
|
||||
Reference in New Issue
Block a user