[lkml]   [2010]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] Repalce strncmp by memcmp
On 11/30/2010 11:26 AM, Steven Rostedt wrote:
> On Mon, 2010-11-29 at 17:18 -0500, Steven Rostedt wrote:
>> Um, do you realize that the kernel does not always use the same memcmp
>> as gcc.
> Note, I'm not against the change, because in 99% of the cases, memcmp()
> can and will be faster, and we don't need to worry about these strange
> cases.

It can still break things in subtle ways. Lots of the replacements are
of the form:

if (strncmp(string, "foo", 3) == 0)

Which can only be replaced with memcmp if the minimum length of string
is _always_ 3. This may be true for some callsites (with careful audit),
but in general I doubt it is and it will lead to subtle bugs.

I hardly think it is worth auditing a bunch of strncmp calls to ensure
that the minimum length of the checked string is always n in order to
remove a single instruction. Making such a change will also introduce
subtle bugs if the rules for the string ever change, eg. a change is
made to allow string = "".


Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon 5 Amuri Park, 404 Barbadoes St PO Box 13 889, Christchurch 8013 New Zealand
Phone: +64 3 3779127 Freecall: Australia 1800 148 751
Fax: +64 3 3779135 USA 1800 261 2934

 \ /
  Last update: 2010-11-29 23:51    [W:0.055 / U:4.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site