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:
+1
-2
@@ -526,8 +526,7 @@ int socket_acquire_peer(Socket *s, int fd, SocketPeer **p) {
|
||||
assert(fd >= 0);
|
||||
assert(s);
|
||||
|
||||
r = getpeername(fd, &sa.peer.sa, &salen);
|
||||
if (r < 0)
|
||||
if (getpeername(fd, &sa.peer.sa, &salen) < 0)
|
||||
return log_unit_error_errno(UNIT(s), errno, "getpeername failed: %m");
|
||||
|
||||
if (!IN_SET(sa.peer.sa.sa_family, AF_INET, AF_INET6, AF_VSOCK)) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -110,10 +110,8 @@ static const char* parse_token(const char *current, int32_t *val_out) {
|
||||
static int override_abs(sd_device *dev, int fd, unsigned evcode, const char *value) {
|
||||
struct input_absinfo absinfo;
|
||||
const char *next;
|
||||
int r;
|
||||
|
||||
r = ioctl(fd, EVIOCGABS(evcode), &absinfo);
|
||||
if (r < 0)
|
||||
if (ioctl(fd, EVIOCGABS(evcode), &absinfo) < 0)
|
||||
return log_device_error_errno(dev, errno, "Failed to call EVIOCGABS");
|
||||
|
||||
next = parse_token(value, &absinfo.minimum);
|
||||
@@ -122,12 +120,12 @@ static int override_abs(sd_device *dev, int fd, unsigned evcode, const char *val
|
||||
next = parse_token(next, &absinfo.fuzz);
|
||||
next = parse_token(next, &absinfo.flat);
|
||||
if (!next)
|
||||
return log_device_error_errno(dev, SYNTHETIC_ERRNO(EINVAL), "Failed to parse EV_ABS override '%s'", value);
|
||||
return log_device_error_errno(dev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Failed to parse EV_ABS override '%s'", value);
|
||||
|
||||
log_device_debug(dev, "keyboard: %x overridden with %"PRIi32"/%"PRIi32"/%"PRIi32"/%"PRIi32"/%"PRIi32,
|
||||
evcode, absinfo.minimum, absinfo.maximum, absinfo.resolution, absinfo.fuzz, absinfo.flat);
|
||||
r = ioctl(fd, EVIOCSABS(evcode), &absinfo);
|
||||
if (r < 0)
|
||||
if (ioctl(fd, EVIOCSABS(evcode), &absinfo) < 0)
|
||||
return log_device_error_errno(dev, errno, "Failed to call EVIOCSABS");
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user