]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cksum,df,digest: prefer signed types
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 31 Jul 2023 23:30:24 +0000 (16:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 1 Aug 2023 00:51:28 +0000 (17:51 -0700)
* 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
src/df.c
src/digest.c

index c7e93fa74a563393a2cccdfd685e6a9e6cdaa834..41146d256dd90d122350e5d688fa89b3c2096c98 100644 (file)
@@ -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;
index 7511162cb99fe6ab002b37b2d0e80d9bb00f13dc..1bd17c5e9961c4659de2e7a7e616eb08f77ac92a 100644 (file)
--- 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))
             {
index 60ba82e5f9f31e0d342b18dce3cdafe56086f6c7..c78ed66eea28641895d5e8ad45a7f9b155b62840 100644 (file)
@@ -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;