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>
This commit is contained in:
Benno Schulenberg 2022-02-13 11:34:17 +01:00
parent c6ddae70f7
commit 27c8f13fc9

View File

@ -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. */