* [PATCH] make memcmp arguments const
@ 2008-11-03 14:34 Stefan Assmann
2008-11-03 22:19 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Assmann @ 2008-11-03 14:34 UTC (permalink / raw)
To: kexec
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)
Signed-off-by: Stefan Assmann <sassmann@suse.de>
---
purgatory/string.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/purgatory/string.c
+++ b/purgatory/string.c
@@ -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;
--
Stefan Assmann | SUSE LINUX Products GmbH
Software Engineer | Maxfeldstr. 5, D-90409 Nuernberg
Mail : sassmann@suse.de | GF: Markus Rex, HRB 16746 (AG Nuernberg)
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] make memcmp arguments const
2008-11-03 14:34 [PATCH] make memcmp arguments const Stefan Assmann
@ 2008-11-03 22:19 ` Simon Horman
2008-11-04 9:45 ` Stefan Assmann
0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2008-11-03 22:19 UTC (permalink / raw)
To: Stefan Assmann; +Cc: kexec
[-- Attachment #1: Type: text/plain, Size: 2447 bytes --]
On Mon, Nov 03, 2008 at 03:34:36PM +0100, Stefan Assmann wrote:
> 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)
>
> Signed-off-by: Stefan Assmann <sassmann@suse.de>
>
> ---
> purgatory/string.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/purgatory/string.c
> +++ b/purgatory/string.c
> @@ -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;
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
Index: kexec-tools/purgatory/include/string.h
===================================================================
--- kexec-tools.orig/purgatory/include/string.h 2008-11-04 09:07:48.000000000 +1100
+++ kexec-tools/purgatory/include/string.h 2008-11-04 09:08:02.000000000 +1100
@@ -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 */
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
[-- Attachment #2: Type: text/plain, Size: 143 bytes --]
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] make memcmp arguments const
2008-11-03 22:19 ` Simon Horman
@ 2008-11-04 9:45 ` Stefan Assmann
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Assmann @ 2008-11-04 9:45 UTC (permalink / raw)
To: Simon Horman; +Cc: kexec
Hi Simon,
Simon Horman wrote:
> On Mon, Nov 03, 2008 at 03:34:36PM +0100, Stefan Assmann wrote:
>> 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)
>>
>> Signed-off-by: Stefan Assmann <sassmann@suse.de>
>>
>> ---
>> purgatory/string.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> --- a/purgatory/string.c
>> +++ b/purgatory/string.c
>> @@ -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;
>
> 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 ?
You're right, I forgot to change that. New patch is appended.
>
> # 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
>
> Index: kexec-tools/purgatory/include/string.h
> ===================================================================
> --- kexec-tools.orig/purgatory/include/string.h 2008-11-04 09:07:48.000000000 +1100
> +++ kexec-tools/purgatory/include/string.h 2008-11-04 09:08:02.000000000 +1100
> @@ -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 */
>
Signed-off-by: Stefan Assmann <sassmann@suse.de>
---
purgatory/include/string.h | 2 +-
purgatory/string.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
--- a/purgatory/string.c
+++ b/purgatory/string.c
@@ -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;
--- a/purgatory/include/string.h
+++ b/purgatory/include/string.h
@@ -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 */
--
Stefan Assmann | SUSE LINUX Products GmbH
Software Engineer | Maxfeldstr. 5, D-90409 Nuernberg
Mail : sassmann@suse.de | GF: Markus Rex, HRB 16746 (AG Nuernberg)
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-04 9:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-03 14:34 [PATCH] make memcmp arguments const Stefan Assmann
2008-11-03 22:19 ` Simon Horman
2008-11-04 9:45 ` Stefan Assmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox