From: Junio C Hamano <gitster@pobox•com>
To: Ben Walton <bdwalton@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] Use unsigned char to squash compiler warnings
Date: Mon, 02 Mar 2015 12:29:49 -0800 [thread overview]
Message-ID: <xmqqoaob9m82.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1425324151-5480-1-git-send-email-bdwalton@gmail.com> (Ben Walton's message of "Mon, 2 Mar 2015 19:22:31 +0000")
Ben Walton <bdwalton@gmail•com> writes:
> Sun Studio on Solaris issues warnings about improper initialization
> values being used when defining tolower_trans_tbl in
> ctype.c. tolower_trans_tbl is defined as char[], which studio's
> compiler defaults to signed char[] due to the Solaris ABI. To resolve
> this, instead of supplying -xchar or another option at build time,
> declare tolower_trans_tbl as unsigned char. Update all appropriate
> references to the new type.
>
> Signed-off-by: Ben Walton <bdwalton@gmail•com>
> ---
> ctype.c | 2 +-
> git-compat-util.h | 2 +-
> kwset.c | 8 ++++----
> kwset.h | 2 +-
> 4 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/ctype.c b/ctype.c
> index 0bfebb4..fc0225c 100644
> --- a/ctype.c
> +++ b/ctype.c
> @@ -30,7 +30,7 @@ const unsigned char sane_ctype[256] = {
> };
>
> /* For case-insensitive kwset */
> -const char tolower_trans_tbl[256] = {
> +const unsigned char tolower_trans_tbl[256] = {
> 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
> 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
> 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
It is not obvious from the context but later elements in this array
have values above 0x7f. So you are saying your compiler complains
when you write:
signed char ch = 0xff;
which sort of makes sense (because you actually are storing -1 not
255 to the variable). Throughout our codebase (and kwset is a
borrowed code that does not count as "our" codebase ;-) we do use
unsigned when we mean we want 255 and not -1, and this patch fixes
that borrowed code to be in line with the rest.
The conversion looked good from a cursory view; I didn't check it
very carefully though.
Thanks.
next prev parent reply other threads:[~2015-03-02 20:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 19:22 [PATCH] Use unsigned char to squash compiler warnings Ben Walton
2015-03-02 20:29 ` Junio C Hamano [this message]
[not found] ` <CAP30j1684A=QsA0o+zLMP70V09mFTS_MtiPZB2TrRywYK2NWWw@mail.gmail.com>
2015-03-04 22:11 ` Junio C Hamano
2015-03-04 22:34 ` Randall S. Becker
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=xmqqoaob9m82.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=bdwalton@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox