tree-wide: drop assignments to r when we only need errno
If the whole call is simple and we don't need to look at the return value apart from the conditional, let's use a form without assignment of the return value. When the function call is more complicated, it still makes sense to use a temporary variable.
This commit is contained in:
@@ -118,12 +118,13 @@ static int device_new_from_dev_path(const char *devlink, sd_device **ret_device)
|
||||
|
||||
assert(devlink);
|
||||
|
||||
r = stat(devlink, &st);
|
||||
if (r < 0)
|
||||
return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno, "Failed to stat() %s: %m", devlink);
|
||||
if (stat(devlink, &st) < 0)
|
||||
return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno,
|
||||
"Failed to stat() %s: %m", devlink);
|
||||
|
||||
if (!S_ISBLK(st.st_mode))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOTBLK), "%s does not point to a block device: %m", devlink);
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOTBLK),
|
||||
"%s does not point to a block device: %m", devlink);
|
||||
|
||||
r = sd_device_new_from_devnum(ret_device, 'b', st.st_rdev);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user