From 89f7d44912e50ab038167c8f7192803e681664e4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 31 Jul 2023 16:30:24 -0700 Subject: [PATCH] cksum,df,digest: prefer signed types * src/cksum.c (main): * src/df.c (decode_output_arg): * src/digest.c (valid_digits): Prefer idx_t to unsigned types when the value is an index into an array. --- src/cksum.c | 2 +- src/df.c | 2 +- src/digest.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cksum.c b/src/cksum.c index c7e93fa74a..41146d256d 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -109,7 +109,7 @@ main (void) uint32_t crc = 0; crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ (i & 0xFF)) & 0xFF]; - for (unsigned int offset = 1; offset < 8; offset++) + for (idx_t offset = 1; offset < 8; offset++) { crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ 0x00) & 0xFF]; crctab[offset][i] = crc; diff --git a/src/df.c b/src/df.c index 7511162cb9..1bd17c5e99 100644 --- a/src/df.c +++ b/src/df.c @@ -443,7 +443,7 @@ decode_output_arg (char const *arg) /* process S. */ display_field_t field = INVALID_FIELD; - for (unsigned int i = 0; i < ARRAY_CARDINALITY (field_data); i++) + for (idx_t i = 0; i < ARRAY_CARDINALITY (field_data); i++) { if (STREQ (field_data[i].arg, s)) { diff --git a/src/digest.c b/src/digest.c index 60ba82e5f9..c78ed66eea 100644 --- a/src/digest.c +++ b/src/digest.c @@ -658,7 +658,7 @@ valid_digits (unsigned char const *s, size_t len) #endif if (len == digest_hex_bytes) { - for (unsigned int i = 0; i < digest_hex_bytes; i++) + for (idx_t i = 0; i < digest_hex_bytes; i++) { if (!isxdigit (*s)) return false; -- 2.47.2