diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-04-30 18:45:29 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-30 19:10:35 +0200 |
commit | 8b803ad6343a318b026da759c2ca48363af9074f (patch) | |
tree | 836e18e68b018f4caf3f8f959fe029bb34af3ca6 | |
parent | Merge pull request #12420 from mrc0mmand/coccinelle-tweaks (diff) | |
download | systemd-8b803ad6343a318b026da759c2ca48363af9074f.tar.xz systemd-8b803ad6343a318b026da759c2ca48363af9074f.zip |
udev: drop unnecessary brackets
Follow-up for ed0cb346821972ec2c505ee11ed3d383aba6256e.
-rw-r--r-- | src/udev/cdrom_id/cdrom_id.c | 16 | ||||
-rw-r--r-- | src/udev/scsi_id/scsi_id.c | 6 | ||||
-rw-r--r-- | src/udev/scsi_id/scsi_serial.c | 30 |
3 files changed, 20 insertions, 32 deletions
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 299c031176..e5c5d4403e 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -202,9 +202,8 @@ static int cd_capability_compat(int fd) { int capability; capability = ioctl(fd, CDROM_GET_CAPABILITY, NULL); - if (capability < 0) { + if (capability < 0) return log_debug_errno(errno, "CDROM_GET_CAPABILITY failed"); - } if (capability & CDC_CD_R) cd_cd_r = 1; @@ -224,9 +223,9 @@ static int cd_capability_compat(int fd) { } static int cd_media_compat(int fd) { - if (ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) != CDS_DISC_OK) { + if (ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) != CDS_DISC_OK) return log_debug_errno(errno, "CDROM_DRIVE_STATUS != CDS_DISC_OK"); - } + cd_media = 1; return 0; } @@ -246,9 +245,8 @@ static int cd_inquiry(int fd) { return -1; } - if ((inq[0] & 0x1F) != 5) { + if ((inq[0] & 0x1F) != 5) return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "not an MMC unit"); - } log_debug("INQUIRY: [%.8s][%.16s][%.4s]", inq + 8, inq + 16, inq + 32); return 0; @@ -470,10 +468,9 @@ static int cd_profiles_old_mmc(int fd) { cd_media_track_count = 1; cd_media_track_count_data = 1; return 0; - } else { + } else return log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM), "no current profile, assuming no media"); - } }; cd_media = 1; @@ -656,10 +653,9 @@ static int cd_media_info(int fd) { } len = format[3]; - if (len & 7 || len < 16) { + if (len & 7 || len < 16) return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "invalid format capacities length"); - } switch(format[8] & 3) { case 1: diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index bb9801e7cc..e1a8d7e3a9 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -346,20 +346,18 @@ static int set_options(int argc, char **argv, default_page_code = PAGE_83; else if (streq(optarg, "pre-spc3-83")) default_page_code = PAGE_83_PRE_SPC3; - else { + else return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown page code '%s'", optarg); - } break; case 's': sg_version = atoi(optarg); - if (sg_version < 3 || sg_version > 4) { + if (sg_version < 3 || sg_version > 4) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown SG version '%s'", optarg); - } break; case 'u': diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index fc62339a52..481c426618 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -168,11 +168,10 @@ static int scsi_dump_sense(struct scsi_id_device *dev_scsi, * we'll retry the command. */ - if (sb_len < 1) { + if (sb_len < 1) return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: sense buffer empty", dev_scsi->kernel); - } sense_class = (sense_buffer[0] >> 4) & 0x07; code = sense_buffer[0] & 0xf; @@ -182,42 +181,41 @@ static int scsi_dump_sense(struct scsi_id_device *dev_scsi, * extended sense data. */ s = sense_buffer[7] + 8; - if (sb_len < s) { + if (sb_len < s) return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: sense buffer too small %d bytes, %d bytes too short", dev_scsi->kernel, sb_len, s - sb_len); - } + if (IN_SET(code, 0x0, 0x1)) { sense_key = sense_buffer[2] & 0xf; - if (s < 14) { + if (s < 14) /* * Possible? */ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: sense result too small %d bytes", dev_scsi->kernel, s); - } + asc = sense_buffer[12]; ascq = sense_buffer[13]; } else if (IN_SET(code, 0x2, 0x3)) { sense_key = sense_buffer[1] & 0xf; asc = sense_buffer[2]; ascq = sense_buffer[3]; - } else { + } else return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: invalid sense code 0x%x", dev_scsi->kernel, code); - } + log_debug("%s: sense key 0x%x ASC 0x%x ASCQ 0x%x", dev_scsi->kernel, sense_key, asc, ascq); } else { - if (sb_len < 4) { + if (sb_len < 4) return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: sense buffer too small %d bytes, %d bytes too short", dev_scsi->kernel, sb_len, 4 - sb_len); - } if (sense_buffer[0] < 15) log_debug("%s: old sense key: 0x%x", dev_scsi->kernel, sense_buffer[0] & 0x0f); @@ -234,14 +232,13 @@ static int scsi_dump_sense(struct scsi_id_device *dev_scsi, static int scsi_dump(struct scsi_id_device *dev_scsi, struct sg_io_hdr *io) { if (!io->status && !io->host_status && !io->msg_status && - !io->driver_status) { + !io->driver_status) /* * Impossible, should not be called. */ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: called with no error", __FUNCTION__); - } log_debug("%s: sg_io failed status 0x%x 0x%x 0x%x 0x%x", dev_scsi->kernel, io->driver_status, io->host_status, io->msg_status, io->status); @@ -253,14 +250,13 @@ static int scsi_dump(struct scsi_id_device *dev_scsi, struct sg_io_hdr *io) { static int scsi_dump_v4(struct scsi_id_device *dev_scsi, struct sg_io_v4 *io) { if (!io->device_status && !io->transport_status && - !io->driver_status) { + !io->driver_status) /* * Impossible, should not be called. */ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: called with no error", __FUNCTION__); - } log_debug("%s: sg_io failed status 0x%x 0x%x 0x%x", dev_scsi->kernel, io->driver_status, io->transport_status, io->device_status); @@ -283,10 +279,9 @@ static int scsi_inquiry(struct scsi_id_device *dev_scsi, int fd, int retry = 3; /* rather random */ int retval; - if (buflen > SCSI_INQ_BUFF_LEN) { + if (buflen > SCSI_INQ_BUFF_LEN) return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "buflen %d too long", buflen); - } resend: if (dev_scsi->use_sg == 4) { @@ -416,12 +411,11 @@ static int prepend_vendor_model(struct scsi_id_device *dev_scsi, char *serial) { * This is not a complete check, since we are using strncat/cpy * above, ind will never be too large. */ - if (ind != (VENDOR_LENGTH + MODEL_LENGTH)) { + if (ind != (VENDOR_LENGTH + MODEL_LENGTH)) return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: expected length %d, got length %d", dev_scsi->kernel, (VENDOR_LENGTH + MODEL_LENGTH), ind); - } return ind; } |