From: Paul Eggert Date: Mon, 31 Jul 2023 23:38:02 +0000 (-0700) Subject: kill: prefer signed types X-Git-Tag: v9.4~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0b8c4ad6104581f44775c9d0f4d6b297351ba06;p=thirdparty%2Fcoreutils.git kill: prefer signed types * src/kill.c (list_signals): Prefer signed types. This avoids undefined behavior on theoretical platforms where unsigned and signed int have different representations. --- diff --git a/src/kill.c b/src/kill.c index 81f6fba8b8..47aaa16132 100644 --- a/src/kill.c +++ b/src/kill.c @@ -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; }