LKML Archive on
help / color / mirror / Atom feed
From: Andreas Schwab <>
To: Gabriel Paubert <>
Cc: Steven Rostedt <>,, LKML <>,
Subject: Re: [PATCH] add strncmp to PowerPC
Date: Mon, 03 Mar 2008 11:10:27 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> (Gabriel Paubert's message of "Mon\, 3 Mar 2008 10\:54\:43 +0100")

Gabriel Paubert <> 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


Andreas Schwab, SuSE Labs,
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 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:

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

  git send-email \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] add strncmp to PowerPC' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).