summaryrefslogtreecommitdiffstats
path: root/src/udev
diff options
context:
space:
mode:
authorIntegral <integral@member.fsf.org>2024-10-23 10:32:02 +0200
committerGitHub <noreply@github.com>2024-10-23 10:32:02 +0200
commitb6b8527cd184085008585c1a1f9725eb97c342ef (patch)
treed615d9db0cfbbd14417e8e5feb32461dfec83e10 /src/udev
parentupdate TODO (diff)
downloadsystemd-b6b8527cd184085008585c1a1f9725eb97c342ef.tar.xz
systemd-b6b8527cd184085008585c1a1f9725eb97c342ef.zip
refactor: replace sizeof in loop with ELEMENTSOF & FOREACH_ELEMENT (#34863)
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/scsi_id/scsi_serial.c9
-rw-r--r--src/udev/udev-builtin-input_id.c2
2 files changed, 4 insertions, 7 deletions
diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c
index aed6082620..d8655c08c3 100644
--- a/src/udev/scsi_id/scsi_serial.c
+++ b/src/udev/scsi_id/scsi_serial.c
@@ -557,7 +557,6 @@ static int do_scsi_page83_inquiry(struct scsi_id_device *dev_scsi, int fd,
char *unit_serial_number, char *wwn,
char *wwn_vendor_extension, char *tgpt_group) {
int retval;
- unsigned id_ind, j;
unsigned char page_83[SCSI_INQ_BUFF_LEN];
/* also pick up the page 80 serial number */
@@ -611,16 +610,14 @@ static int do_scsi_page83_inquiry(struct scsi_id_device *dev_scsi, int fd,
* Search for a match in the prioritized id_search_list - since WWN ids
* come first we can pick up the WWN in check_fill_0x83_id().
*/
- for (id_ind = 0;
- id_ind < sizeof(id_search_list)/sizeof(id_search_list[0]);
- id_ind++) {
+ FOREACH_ELEMENT(search_value, id_search_list) {
/*
* Examine each descriptor returned. There is normally only
* one or a small number of descriptors.
*/
- for (j = 4; j <= ((unsigned)page_83[2] << 8) + (unsigned)page_83[3] + 3; j += page_83[j + 3] + 4) {
+ for (unsigned j = 4; j <= ((unsigned)page_83[2] << 8) + (unsigned)page_83[3] + 3; j += page_83[j + 3] + 4) {
retval = check_fill_0x83_id(dev_scsi, page_83 + j,
- id_search_list + id_ind,
+ search_value,
serial, serial_short, len,
wwn, wwn_vendor_extension,
tgpt_group);
diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index 6f75d9df22..1dec5f868e 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -356,7 +356,7 @@ static bool test_key(
i * BITS_PER_LONG, yes_no(found));
}
/* If there are no keys in the lower block, check the higher blocks */
- for (size_t block = 0; block < sizeof(high_key_blocks) / sizeof(struct range) && !found; block++)
+ for (size_t block = 0; block < ELEMENTSOF(high_key_blocks) && !found; block++)
for (unsigned i = high_key_blocks[block].start; i < high_key_blocks[block].end && !found; i++)
if (test_bit(i, bitmask_key)) {
log_device_debug(dev, "test_key: Found key %x in high block", i);