All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Teng Long <dyroneteng@gmail.com>,
	git@vger.kernel.org, avarab@gmail.com,
	tenglong.tl@alibaba-inc.com
Subject: Re: [PATCH] range-diff: avoid compiler warning when char is unsigned
Date: Tue, 28 Feb 2023 15:44:54 -0800	[thread overview]
Message-ID: <xmqqh6v5pd6x.fsf@gitster.g> (raw)
In-Reply-To: <1156586e-9dbe-335e-7e33-74eea7913e86@web.de> ("René Scharfe"'s message of "Tue, 28 Feb 2023 17:13:27 +0100")

René Scharfe <l.s.r@web.de> writes:

> 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>
> ---
>  range-diff.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Very clearly explained.  The patch does make sense.

Thanks.

> diff --git a/range-diff.c b/range-diff.c
> index 086365dffb..4bd65ab749 100644
> --- a/range-diff.c
> +++ b/range-diff.c
> @@ -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;
> --
> 2.34.1

      reply	other threads:[~2023-02-28 23:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20 14:24 [PATCH 0/1] range-diff: let '--abbrev' option takes effect Teng Long
2023-02-20 14:24 ` [PATCH 1/1] " Teng Long
2023-02-21 22:01   ` Junio C Hamano
2023-02-28 16:13   ` [PATCH] range-diff: avoid compiler warning when char is unsigned René Scharfe
2023-02-28 23:44     ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqh6v5pd6x.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=dyroneteng@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --cc=tenglong.tl@alibaba-inc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.