Re: [PATCH] Repalce strncmp by memcmp

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: YOSHIFUJI Hideaki
Date: Sunday, November 28, 2010 - 10:26 pm

2010-11-28 (Sun) 20:13 -0800, Dmitry Torokhov wrote:

Yes, if both of the strings are NOT known to have enough length.

It is safe to replace strncmp(a,b,n) with memcmp(a,b,n)
if a or b is/are known to have enough length; strlen(a) >= n ||
strlen(b) >= n.

I think some of the replacements in the original patch are valid,
but for even those valid replacement, I think it is worth doing
that in hot code paths only.

--yoshfuji

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Repalce strncmp by memcmp, Pavel Vasilyev, (Sun Nov 28, 7:09 pm)
Re: [PATCH] Repalce strncmp by memcmp, microcai, (Sun Nov 28, 7:21 pm)
Re: [PATCH] Repalce strncmp by memcmp, Ming Lei, (Sun Nov 28, 7:29 pm)
Re: [PATCH] Repalce strncmp by memcmp, Américo Wang, (Sun Nov 28, 8:10 pm)
Re: [PATCH] Repalce strncmp by memcmp, Pavel Vasilyev, (Sun Nov 28, 8:11 pm)
Re: [PATCH] Repalce strncmp by memcmp, Dmitry Torokhov, (Sun Nov 28, 9:13 pm)
Re: [PATCH] Repalce strncmp by memcmp, YOSHIFUJI Hideaki, (Sun Nov 28, 10:26 pm)
Re: [PATCH] Repalce strncmp by memcmp, Andi Kleen, (Mon Nov 29, 3:18 am)
Re: [PATCH] Repalce strncmp by memcmp, Pavel Vasilyev, (Mon Nov 29, 5:41 am)
Re: [PATCH] Repalce strncmp by memcmp, Steven Rostedt, (Mon Nov 29, 7:58 am)
Re: [PATCH] Repalce strncmp by memcmp, Pavel Vasilyev, (Mon Nov 29, 12:41 pm)
Re: [PATCH] Repalce strncmp by memcmp, Steven Rostedt, (Mon Nov 29, 3:18 pm)
Re: [PATCH] Repalce strncmp by memcmp, Steven Rostedt, (Mon Nov 29, 3:26 pm)
Re: [PATCH] Repalce strncmp by memcmp, Pavel Vasilyev, (Mon Nov 29, 3:49 pm)
Re: [PATCH] Repalce strncmp by memcmp, Ryan Mallon, (Mon Nov 29, 3:51 pm)
Re: [PATCH] Repalce strncmp by memcmp, Arnaud Lacombe, (Mon Nov 29, 4:32 pm)
Re: [PATCH] Repalce strncmp by memcmp, Américo Wang, (Tue Nov 30, 2:24 am)
Re: [PATCH] Repalce strncmp by memcmp, Bernd Petrovitsch, (Tue Nov 30, 3:27 am)
Re: [PATCH] Repalce strncmp by memcmp, Bernd Petrovitsch, (Tue Nov 30, 3:34 am)