[coreboot] r3474 - in trunk/payloads/libpayload: drivers i386 include

Ulf Jordan jordan at chalmers.se
Sat Aug 9 10:21:43 CEST 2008


On Sat, 9 Aug 2008, Peter Stuge wrote:

[snip]

> memcmp() expects char *
>
> What should change? I'm thinking memcmp() and friends.

memcmp is memcmp(const void *, const void *, size_t) in libc, so I guess 
we should stick to that, see attached patch against r3478. Compile tested. 
coreinfo still runs under qemu after this patch is applied.

> Later revisions breaks more stuff. :\

Yes.

r3479: pci_module output becomes erratic in coreinfo.
r3482: no output at all from coreinfo on neither vga nor serial in qemu.


/ulf
-------------- next part --------------
Fix signedness problem in memcmp.

Signed-off-by: Ulf Jordan <jordan at chalmers.se>

Index: libpayload/include/libpayload.h
===================================================================
--- libpayload/include/libpayload.h	(revision 3478)
+++ libpayload/include/libpayload.h	(arbetskopia)
@@ -179,7 +179,7 @@
 void *memset(void *s, int c, size_t n);
 void *memcpy(void *dst, const void *src, size_t n);
 void *memmove(void *dst, const void *src, size_t n);
-int memcmp(const char *s1, const char *s2, size_t len);
+int memcmp(const void *s1, const void *s2, size_t len);
 
 /* libc/printf.c */
 int snprintf(char *str, size_t size, const char *fmt, ...);
Index: libpayload/libc/memory.c
===================================================================
--- libpayload/libc/memory.c	(revision 3478)
+++ libpayload/libc/memory.c	(arbetskopia)
@@ -107,8 +107,8 @@
  * @return If len is 0, return zero. If the areas match, return zero.
  *         Otherwise return non-zero.
  */
-int memcmp(const char *s1, const char *s2, size_t len)
+int memcmp(const void *s1, const void *s2, size_t len)
 {
-	for (; len && *s1++ == *s2++; len--) ;
+	for (; len && *(char *)s1++ == *(char *)s2++; len--) ;
 	return len;
 }


More information about the coreboot mailing list