[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101129041359.GA6991@core.coreip.homeip.net>
Date: Sun, 28 Nov 2010 20:13:59 -0800
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Pavel Vasilyev <pavel@...linux.ru>
Cc: Ming Lei <tom.leiming@...il.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Repalce strncmp by memcmp
On Mon, Nov 29, 2010 at 06:11:21AM +0300, Pavel Vasilyev wrote:
> On 29.11.2010 05:29, Ming Lei wrote:
> > Hi,
> >
> > 2010/11/29 Pavel Vasilyev <pavel@...linux.ru>:
> >> This patch replace all strncmp(a, b, c) by memcmp(a, b, c).
> >>
> >> I test on x86_64 (AMD Opteron 285).
> > In fact, memcmp doesn't handle case of tail of string, so
> > it is not safe to replace strncmp with memcmp
> >
> #include <stdio.h>
> #include <errno.h>
>
> int main() {
>
> char *STR = "XXXX\0";
> char *XXX = "XXXX";
Try comparing:
"XXXX\0YYYY" and
"XXXX\0ZZZZ"
and observe the difference.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists