make memcmp arguments const
Subsystems (2)
PATCH 1/1 make memcmp arguments const
In purgatory/string.c the definition of memcmp is
int memcmp(void *src1, void *src2, size_t len)
man memcmp reveals
int memcmp(const void *s1, const void *s2, size_t n)
--- purgatory/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
purgatory/string.c +2 -2
@@ -36,9 +36,9 @@ void* memcpy(void *dest, const void *src } -int memcmp (void *src1,void *src2,size_t len) +int memcmp (const void *src1,const void *src2,size_t len) { -unsigned char *s1, *s2; +const unsigned char *s1, *s2;size_t i; s1 = src1; s2 = src2;
Signature · 8 lines
Stefan Assmann | SUSE LINUX Products GmbH Software Engineer | Maxfeldstr. 5, D-90409 Nuernberg Mail : [email protected] | GF: Markus Rex, HRB 16746 (AG Nuernberg) _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 15 lines · Stefan Assmann
In
purgatory/string.cthe definition of memcmp is
intmemcmp(void *src1, void *src2, size_t len)
man memcmp reveals
intmemcmp(const void *s1, const void *s2, size_t n)Signed-off-by Stefan Assmann <[email protected]>--- purgatory/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)purgatory/string.c +0
-0@@ -36,9 +36,9 @@ void* memcpy(void *dest, const void *src }
purgatory/string.c void* memcpy(void *dest, const void *src · line 44
Quoted 10 lines
purgatory/string.c +2
-2-int memcmp (void *src1,void *src2,size_t len) +int memcmp (const void *src1,const void *src2,size_t len) { -unsigned char *s1, *s2; +const unsigned char *s1, *s2;size_t i; s1 = src1; s2 = src2;
Hi Stefan,
this change seems reasonable to me, but I think that the declaration also needs to be updated. If the change below is fine by you, could you please add it to your patch and repost ?
# gcc --version gcc (Debian 4.3.2-1) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# make ... gcc -Wall -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -Os -fno-builtin -ffreestanding -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I/usr/lib/gcc/i486-linux-gnu/4.3.2/include -c -MD -o purgatory/string.o purgatory/string.c purgatory/string.c:39: error: conflicting types for ‘memcmp’ ./purgatory/include/string.h:9: error: previous declaration of ‘memcmp’ was here make: *** [purgatory/string.o] Error 1
purgatory/include/string.h +1 -1
@@ -6,7 +6,7 @@size_t strnlen (const char *s,size_t max);void *memset (void * s,int c,size_t n);void *memcpy (void *dest,const void *src,size_t len); -int memcmp (void *src1,void *src2,size_t len); +int memcmp (const void *src1,const void *src2,size_t len);#endif /* STRING_H */
Signature · 3 lines
Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Simon,
Quoted 29 lines · Simon Horman
Quoted 15 lines · Stefan Assmann
In
purgatory/string.cthe definition of memcmp is
intmemcmp(void *src1, void *src2, size_t len)
man memcmp reveals
intmemcmp(const void *s1, const void *s2, size_t n)Signed-off-by Stefan Assmann <[email protected]>--- purgatory/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)purgatory/string.c +0
-0@@ -36,9 +36,9 @@ void* memcpy(void *dest, const void *src }purgatory/string.c void* memcpy(void *dest, const void *src · line 44
Quoted 10 lines
purgatory/string.c +2
-2-int memcmp (void *src1,void *src2,size_t len) +int memcmp (const void *src1,const void *src2,size_t len) { -unsigned char *s1, *s2; +const unsigned char *s1, *s2;size_t i; s1 = src1; s2 = src2;Hi Stefan,
Quoted 4 lines
this change seems reasonable to me, but I think that the declaration also needs to be updated. If the change below is fine by you, could you please add it to your patch and repost ?
You're right, I forgot to change that. New patch is appended.
Quoted 21 lines
# gcc --version gcc (Debian 4.3.2-1) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.# make ... gcc -Wall -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -Os -fno-builtin -ffreestanding -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I/usr/lib/gcc/i486-linux-gnu/4.3.2/include -c -MD -o purgatory/string.o purgatory/string.c purgatory/string.c:39: error: conflicting types for ‘memcmp’ ./purgatory/include/string.h:9: error: previous declaration of ‘memcmp’ was here make: *** [purgatory/string.o] Error 1Index:
kexec-tools/purgatory/include/string.h
===================================================================
purgatory/include/string.h line 12
Quoted 8 lines
purgatory/include/string.h +1
-1@@ -6,7 +6,7 @@size_t strnlen (const char *s,size_t max);void *memset (void * s,int c,size_t n);void *memcpy (void *dest,const void *src,size_t len); -int memcmp (void *src1,void *src2,size_t len); +int memcmp (const void *src1,const void *src2,size_t len);#endif /* STRING_H */
--- purgatory/include/string.h | 2 +- purgatory/string.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
purgatory/string.c +2 -2
@@ -36,9 +36,9 @@ void* memcpy(void *dest, const void *src } -int memcmp (void *src1,void *src2,size_t len) +int memcmp (const void *src1,const void *src2,size_t len) { -unsigned char *s1, *s2; +const unsigned char *s1, *s2;size_t i; s1 = src1; s2 = src2;
purgatory/include/string.h +1 -1
@@ -6,7 +6,7 @@size_t strnlen (const char *s,size_t max);void *memset (void * s,int c,size_t n);void *memcpy (void *dest,const void *src,size_t len); -int memcmp (void *src1,void *src2,size_t len); +int memcmp (const void *src1,const void *src2,size_t len);#endif /* STRING_H */
Signature · 8 lines
Stefan Assmann | SUSE LINUX Products GmbH Software Engineer | Maxfeldstr. 5, D-90409 Nuernberg Mail : [email protected] | GF: Markus Rex, HRB 16746 (AG Nuernberg) _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec