All of lore.kernel.org
 help / color / mirror / Atom feed
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: Wed, 04 Mar 2015 14:11:14 -0800	[thread overview]
Message-ID: <xmqqd24o76rh.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAP30j1684A=QsA0o+zLMP70V09mFTS_MtiPZB2TrRywYK2NWWw@mail.gmail.com> (Ben Walton's message of "Wed, 04 Mar 2015 21:09:01 +0000")

Ben Walton <bdwalton@gmail.com> writes:

> On Mon, Mar 2, 2015 at 8:30 PM Junio C Hamano <gitster@pobox.com> wrote:
>
>> The conversion looked good from a cursory view; I didn't check it
>> very carefully though.
>>
> Yes, because of the Solaris ABI, the Studio compiler defaults char to
> signed char.

Doesn't our beloved GCC also uses signed char when you write char?
You keep saying that "defaults to signed char is the problem", but
that does not explain why those in the rest of the world outside the
Solaris land do not encounter this problem.

	$ cat >x.c <<\EOF
        #include <stdio.h>
        int main (void) {
                SIGNED char ch = 0xff;
                printf("%d\n", ch);
                return 0;
        }
	EOF
        $ gcc -Wall -DSIGNED= x.c && ./a.out
        -1
        $ gcc -Wall -DSIGNED=signed x.c && ./a.out
	-1

I think th problem is not Solaris uses signed char for char like
everybody else does ;-) but it gives a fairly useless warning to
annoy people.

In any case, here is what I queued, FYI, on bw/kwset-use-unsigned
topic.

Thanks.

commit 189c860c9ec5deb95845c056ca5c15b58970158e
Author: Ben Walton <bdwalton@gmail.com>
Date:   Mon Mar 2 19:22:31 2015 +0000

    kwset: use unsigned char to store values with high-bit set
    
    Sun Studio on Solaris issues warnings about improper initialization
    values being used when defining tolower_trans_tbl[] in ctype.c.  The
    array wants to store values with high-bit set and treat them as
    values between 128 to 255.  Unlike the rest of the Git codebase
    where we explicitly specify 'unsigned char' for such variables and
    arrays, however, kwset code we borrowed from elsewhere uses 'char'
    for this and other variables.
    
    Fix the declarations to explicitly use 'unsigned char' where
    necessary to bring it in line with the rest of the Git.
    
    Signed-off-by: Ben Walton <bdwalton@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>

  parent reply	other threads:[~2015-03-04 22:11 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
     [not found]   ` <CAP30j1684A=QsA0o+zLMP70V09mFTS_MtiPZB2TrRywYK2NWWw@mail.gmail.com>
2015-03-04 22:11     ` Junio C Hamano [this message]
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=xmqqd24o76rh.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=bdwalton@gmail.com \
    --cc=git@vger.kernel.org \
    /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.