]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
kill: prefer signed types
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 31 Jul 2023 23:38:02 +0000 (16:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 1 Aug 2023 00:51:28 +0000 (17:51 -0700)
* src/kill.c (list_signals):
Prefer signed types.  This avoids undefined behavior on
theoretical platforms where unsigned and signed int have
different representations.

src/kill.c

index 81f6fba8b880c480a02fae3002c176110d0ff2d9..47aaa161329db1d1450014a1dabcdb0412288e11 100644 (file)
@@ -131,10 +131,10 @@ list_signals (bool table, char *const *argv)
 
   if (table)
     {
-      unsigned int name_width = 0;
+      int name_width = 0;
 
       /* Compute the maximum width of a signal number.  */
-      unsigned int num_width = 1;
+      int num_width = 1;
       for (signum = 1; signum <= SIGNUM_BOUND / 10; signum *= 10)
         num_width++;
 
@@ -142,7 +142,7 @@ list_signals (bool table, char *const *argv)
       for (signum = 1; signum <= SIGNUM_BOUND; signum++)
         if (sig2str (signum, signame) == 0)
           {
-            size_t len = strlen (signame);
+            idx_t len = strlen (signame);
             if (name_width < len)
               name_width = len;
           }