]> git.ipfire.org Git - thirdparty/git.git/commitdiff
range-diff: avoid compiler warning when char is unsigned
authorRené Scharfe <l.s.r@web.de>
Tue, 28 Feb 2023 16:13:27 +0000 (17:13 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Feb 2023 22:43:05 +0000 (14:43 -0800)
Since 2b15969f61 (range-diff: let '--abbrev' option takes effect,
2023-02-20), GCC 11.3 on Ubuntu 22.04 on aarch64 warns (and errors
out if the make variable DEVELOPER is set):

range-diff.c: In function ‘output_pair_header’:
range-diff.c:388:20: error: comparison is always false due to limited range of data type [-Werror=type-limits]
  388 |         if (abbrev < 0)
      |                    ^
cc1: all warnings being treated as errors

That's because char is unsigned on that platform.  Use int instead, just
like in struct diff_options, to copy the value faithfully.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
range-diff.c

index 086365dffb7e42de0158cfb9cd64c218571c2ba2..4bd65ab7496ebf8c6f0ca9420ff16e8532cce71d 100644 (file)
@@ -383,7 +383,7 @@ static void output_pair_header(struct diff_options *diffopt,
        const char *color_new = diff_get_color_opt(diffopt, DIFF_FILE_NEW);
        const char *color_commit = diff_get_color_opt(diffopt, DIFF_COMMIT);
        const char *color;
-       char abbrev = diffopt->abbrev;
+       int abbrev = diffopt->abbrev;
 
        if (abbrev < 0)
                abbrev = DEFAULT_ABBREV;