commit 27c8f13fc9be521f7ce0b92f89dd308eb208b1f1
parent c6ddae70f7da3cd965f1a05f029040b40c61f536
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 13 Feb 2022 11:34:17 +0100
tweaks: change the type of a variable, to avoid a compiler warning
A newer compiler (gcc-10.3) said: browser.c:174:34: warning:
field width specifier '*' expects argument of type 'int'
It's fine for 'longest' to be an integer, as a filename in Unix is
at most 255 bytes long, which can occupy at most 510 columns (when
the name consists entirely of control codes), and that fits easily
within an 'int', which has at least fifteen bits, unsigned.
Well... in theory 'tabsize' could be set to an insanely high number,
and if a filename contains several tabs, this could cause 'longest'
to overflow. (Why doesn't the compiler warn about that?) If that
were to occur, and the filename with the tabs were the last in the
list, then 'longest' would get set to the minimum width: 15. That
would not be correct, but... nothing bad would happen.
This addresses https://savannah.gnu.org/bugs/?62014.
Reported-by: Mike Frysinger <vapier@gentoo.org>
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/browser.c b/src/browser.c
@@ -36,7 +36,7 @@ static size_t usable_rows = 0;
/* The number of screen rows we can use to display the list. */
static size_t piles = 0;
/* The number of files that we can display per screen row. */
-static size_t longest = 0;
+static int longest = 0;
/* The number of columns in the longest filename in the list. */
static size_t selected = 0;
/* The currently selected filename in the list; zero-based. */