diff options
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/ata_id/ata_id.c | 5 | ||||
-rw-r--r-- | src/udev/cdrom_id/cdrom_id.c | 2 | ||||
-rw-r--r-- | src/udev/scsi_id/scsi_serial.c | 13 | ||||
-rw-r--r-- | src/udev/udev-builtin-uaccess.c | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-usb_id.c | 2 | ||||
-rw-r--r-- | src/udev/udev-node.c | 6 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 20 |
7 files changed, 23 insertions, 27 deletions
diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index ad152b9d31..1dc62b69d5 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -617,7 +617,7 @@ int main(int argc, char *argv[]) */ word = identify.wyde[76]; - if (word != 0x0000 && word != 0xffff) { + if (!IN_SET(word, 0x0000, 0xffff)) { printf("ID_ATA_SATA=1\n"); /* * If bit 2 of word 76 is set to one, then the device supports the Gen2 @@ -661,8 +661,7 @@ int main(int argc, char *argv[]) } /* from Linux's include/linux/ata.h */ - if (identify.wyde[0] == 0x848a || - identify.wyde[0] == 0x844a || + if (IN_SET(identify.wyde[0], 0x848a, 0x844a) || (identify.wyde[83] & 0xc004) == 0x4004) printf("ID_ATA_CFA=1\n"); } else { diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 1f906a8525..b9cf3bdf68 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -544,7 +544,7 @@ static int cd_profiles(struct udev *udev, int fd) if ((err != 0)) { info_scsi_cmd_err(udev, "GET CONFIGURATION", err); /* handle pre-MMC2 drives which do not support GET CONFIGURATION */ - if (SK(err) == 0x5 && (ASC(err) == 0x20 || ASC(err) == 0x24)) { + if (SK(err) == 0x5 && IN_SET(ASC(err), 0x20, 0x24)) { log_debug("drive is pre-MMC2 and does not support 46h get configuration command"); log_debug("trying to work around the problem"); ret = cd_profiles_old_mmc(udev, fd); diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index f007cc6001..b56a541f78 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -115,9 +115,8 @@ static int sg_err_category_new(struct udev *udev, if (!scsi_status && !host_status && !driver_status) return SG_ERR_CAT_CLEAN; - if ((scsi_status == SCSI_CHECK_CONDITION) || - (scsi_status == SCSI_COMMAND_TERMINATED) || - ((driver_status & 0xf) == DRIVER_SENSE)) { + if (IN_SET(scsi_status, SCSI_CHECK_CONDITION, SCSI_COMMAND_TERMINATED) || + (driver_status & 0xf) == DRIVER_SENSE) { if (sense_buffer && (sb_len > 2)) { int sense_key; unsigned char asc; @@ -143,9 +142,7 @@ static int sg_err_category_new(struct udev *udev, return SG_ERR_CAT_SENSE; } if (host_status) { - if ((host_status == DID_NO_CONNECT) || - (host_status == DID_BUS_BUSY) || - (host_status == DID_TIME_OUT)) + if (IN_SET(host_status, DID_NO_CONNECT, DID_BUS_BUSY, DID_TIME_OUT)) return SG_ERR_CAT_TIMEOUT; } if (driver_status) { @@ -215,7 +212,7 @@ static int scsi_dump_sense(struct udev *udev, dev_scsi->kernel, sb_len, s - sb_len); return -1; } - if ((code == 0x0) || (code == 0x1)) { + if (IN_SET(code, 0x0, 0x1)) { sense_key = sense_buffer[2] & 0xf; if (s < 14) { /* @@ -227,7 +224,7 @@ static int scsi_dump_sense(struct udev *udev, } asc = sense_buffer[12]; ascq = sense_buffer[13]; - } else if ((code == 0x2) || (code == 0x3)) { + } else if (IN_SET(code, 0x2, 0x3)) { sense_key = sense_buffer[1] & 0xf; asc = sense_buffer[2]; ascq = sense_buffer[3]; diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c index 3ebe36f043..d92a10e1c5 100644 --- a/src/udev/udev-builtin-uaccess.c +++ b/src/udev/udev-builtin-uaccess.c @@ -47,7 +47,7 @@ static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool seat = "seat0"; r = sd_seat_get_active(seat, NULL, &uid); - if (r == -ENXIO || r == -ENODATA) { + if (IN_SET(r, -ENXIO, -ENODATA)) { /* No active session on this seat */ r = 0; goto finish; diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index 587649eff0..3ce075f079 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -307,7 +307,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool dev_if_packed_info(dev_usb, packed_if_str, sizeof(packed_if_str)); /* mass storage : SCSI or ATAPI */ - if (protocol == 6 || protocol == 2) { + if (IN_SET(protocol, 6, 2)) { struct udev_device *dev_scsi; const char *scsi_model, *scsi_vendor, *scsi_type, *scsi_rev; int host, bus, target, lun; diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 53cfd9c053..01e56cac36 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -87,7 +87,7 @@ static int node_symlink(struct udev_device *dev, const char *node, const char *s log_debug("creating symlink '%s' to '%s'", slink, target); do { err = mkdir_parents_label(slink, 0755); - if (err != 0 && err != -ENOENT) + if (!IN_SET(err, 0, -ENOENT)) break; mac_selinux_create_file_prepare(slink, S_IFLNK); err = symlink(target, slink); @@ -104,7 +104,7 @@ static int node_symlink(struct udev_device *dev, const char *node, const char *s unlink(slink_tmp); do { err = mkdir_parents_label(slink_tmp, 0755); - if (err != 0 && err != -ENOENT) + if (!IN_SET(err, 0, -ENOENT)) break; mac_selinux_create_file_prepare(slink_tmp, S_IFLNK); err = symlink(target, slink_tmp); @@ -209,7 +209,7 @@ static void link_update(struct udev_device *dev, const char *slink, bool add) { int fd; err = mkdir_parents(filename, 0755); - if (err != 0 && err != -ENOENT) + if (!IN_SET(err, 0, -ENOENT)) break; fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444); if (fd >= 0) diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 5ab697e399..9aaec72baf 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -579,7 +579,7 @@ static int import_property_from_string(struct udev_device *dev, char *line) { key++; /* comment or empty line */ - if (key[0] == '#' || key[0] == '\0') + if (IN_SET(key[0], '#', '\0')) return -1; /* split key/value */ @@ -613,7 +613,7 @@ static int import_property_from_string(struct udev_device *dev, char *line) { return -1; /* unquote */ - if (val[0] == '"' || val[0] == '\'') { + if (IN_SET(val[0], '"', '\'')) { if (len == 1 || val[len-1] != val[0]) { log_debug("inconsistent quoting: '%s', skip", line); return -1; @@ -741,7 +741,7 @@ static int get_key(struct udev *udev, char **line, char **key, enum operation_ty break; if (linepos[0] == '=') break; - if ((linepos[0] == '+') || (linepos[0] == '-') || (linepos[0] == '!') || (linepos[0] == ':')) + if (IN_SET(linepos[0], '+', '-', '!', ':')) if (linepos[1] == '=') break; } @@ -1968,7 +1968,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules, int count; util_remove_trailing_chars(result, '\n'); - if (esc == ESCAPE_UNSET || esc == ESCAPE_REPLACE) { + if (IN_SET(esc, ESCAPE_UNSET, ESCAPE_REPLACE)) { count = util_replace_chars(result, UDEV_ALLOWED_CHARS_INPUT); if (count > 0) log_debug("%i character(s) replaced" , count); @@ -2219,7 +2219,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules, else label = rules_str(rules, cur->key.value_off); - if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL) + if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL)) udev_list_cleanup(&event->seclabel_list); udev_list_entry_add(&event->seclabel_list, name, label); log_debug("SECLABEL{%s}='%s' %s:%u", @@ -2260,13 +2260,13 @@ void udev_rules_apply_to_event(struct udev_rules *rules, const char *p; udev_event_apply_format(event, rules_str(rules, cur->key.value_off), tag, sizeof(tag), false); - if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL) + if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL)) udev_device_cleanup_tags_list(event->dev); for (p = tag; *p != '\0'; p++) { if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || - *p == '-' || *p == '_') + IN_SET(*p, '-', '_')) continue; log_error("ignoring invalid tag name '%s'", tag); break; @@ -2288,7 +2288,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules, if (cur->key.op == OP_ASSIGN_FINAL) event->name_final = true; udev_event_apply_format(event, name, name_str, sizeof(name_str), false); - if (esc == ESCAPE_UNSET || esc == ESCAPE_REPLACE) { + if (IN_SET(esc, ESCAPE_UNSET, ESCAPE_REPLACE)) { count = util_replace_chars(name_str, "/"); if (count > 0) log_debug("%i character(s) replaced", count); @@ -2323,7 +2323,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules, break; if (cur->key.op == OP_ASSIGN_FINAL) event->devlink_final = true; - if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL) + if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL)) udev_device_cleanup_devlinks_list(event->dev); /* allow multiple symlinks separated by spaces */ @@ -2396,7 +2396,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules, case TK_A_RUN_PROGRAM: { struct udev_list_entry *entry; - if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL) + if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL)) udev_list_cleanup(&event->run_list); log_debug("RUN '%s' %s:%u", rules_str(rules, cur->key.value_off), |