linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Gabriel Paubert <paubert@iram.es>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	paulus@samba.org, LKML <linux-kernel@vger.kernel.org>,
	linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] add strncmp to PowerPC
Date: Mon, 03 Mar 2008 11:10:27 +0100	[thread overview]
Message-ID: <je4pbow224.fsf@sykes.suse.de> (raw)
In-Reply-To: <20080303095443.GB27105@iram.es> (Gabriel Paubert's message of "Mon\, 3 Mar 2008 10\:54\:43 +0100")

Gabriel Paubert <paubert@iram.es> writes:

> Now that I think a bit more about it, I believe that the C version is
> incorrect: the clrldi/extsb dance takes a value between -255 and +255
> and collapses it into the -128 to 127 range, meaning that the return
> value may be wrong if we rely on the sign of the result. So unless I
> miss something, the problem is much more serious than just stupid code
> (I had just a look at the libc version in C and characters are cast to
> unsigned char before the comparison).

The latter is explicitly required by the C standard.  Ie. even if your
characters are signed they are always compared as unsigned by
strcmp/strncmp/memcmp.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

  reply	other threads:[~2008-03-03 10:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-29 16:04 [PATCH] add strncmp to PowerPC Steven Rostedt
2008-03-01  3:04 ` Benjamin Herrenschmidt
2008-03-01  3:56   ` Steven Rostedt
2008-03-03  9:54     ` Gabriel Paubert
2008-03-03 10:10       ` Andreas Schwab [this message]
2008-03-03 19:08       ` Segher Boessenkool
2008-03-05  4:03   ` Paul Mackerras
2008-03-05  5:26     ` Segher Boessenkool
2008-03-05  5:39       ` Paul Mackerras
2008-03-05  7:01         ` Segher Boessenkool

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=je4pbow224.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paubert@iram.es \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).