Re: [PATCH] Repalce strncmp by memcmp

From: Bernd Petrovitsch
Date: Tue Nov 30 2010 - 05:34:33 EST


On Mon, 2010-11-29 at 05:09 +0300, Pavel Vasilyev wrote:
> This patch replace all strncmp(a, b, c) by memcmp(a, b, c).
>
> I test on x86_64 (AMD Opteron 285).
>
> #include <string.h>
> char *A = "0000";
> void test_memcmp(void) {
> memcmp(A, "TEST", 4);
> }
> void test_strn(void) {
> strncmp(A, "TEST", 4);
> }
[...]

You use constant parameters with user-space functions defined by the
C-standard on one architecture (and CPU?) - and even worse the width is
4 so - for the memcmp() case - it boilsdown to a comparison of unsigned
ints.
So that example is (also) completely worthless.

Bernd
--
Bernd Petrovitsch Email : bernd@xxxxxxxxxxxxxxxxxxx
LUGA : http://www.luga.at

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/