[U-Boot-Users] [PATCH 01/17] example/82559_eeprom: Fix multiple warnings and errors

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sun May 18 19:09:43 CEST 2008


include/image.h: In function 'image_set_name':
include/image.h:374: warning: implicit declaration of function 'strncpy'
82559_eeprom.c: In function 'memcpy':
82559_eeprom.c:57: error: lvalue required as increment operand
82559_eeprom.c:57: error: lvalue required as increment operand
82559_eeprom.c: In function 'main':
82559_eeprom.c:318: warning: pointer targets in passing argument 2 of 'gethwaddr' differ in signedness

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 examples/82559_eeprom.c   |   22 +++++++++++++---------
 include/asm-i386/string.h |    2 ++
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/examples/82559_eeprom.c b/examples/82559_eeprom.c
index 1a121d4..587b6a4 100644
--- a/examples/82559_eeprom.c
+++ b/examples/82559_eeprom.c
@@ -18,14 +18,13 @@
  * and release the resulting code under the GPL.
  */
 
-#define _PPC_STRING_H_		/* avoid unnecessary str/mem functions */
-#define _LINUX_STRING_H_	/* avoid unnecessary str/mem functions */
+#define __HAVE_ARCH_MEMCPY	1	/* avoid unnecessary memcpy function */
+#define _PPC_STRING_H_		1	/* avoid unnecessary str/mem functions */
 
 #include <common.h>
 #include <exports.h>
 #include <asm/io.h>
 
-
 /* Default EEPROM for i82559 */
 static unsigned short default_eeprom[64] = {
 	0x0100, 0x0302, 0x0504, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
@@ -50,12 +49,16 @@ static inline unsigned short swap16(unsigned short x)
 	return (((x & 0xff) << 8) | ((x & 0xff00) >> 8));
 }
 
-
-static inline void *memcpy(void *dst, const void *src, unsigned int len)
+inline void *memcpy(void *dst, const void *src, unsigned int len)
 {
-	void * ret = dst;
-	while (len-- > 0) *((char *)dst)++ = *((char *)src)++;
-	return ret;
+	char *ret = dst;
+
+	while (len-- > 0) {
+		*ret++ = *((char *)src);
+		src++;
+	}
+
+	return (void *)dst;
 }
 
 /* The EEPROM commands include the alway-set leading bit. */
@@ -80,6 +83,7 @@ static inline void *memcpy(void *dst, const void *src, unsigned int len)
 static int eeprom_busy_poll(long ee_ioaddr)
 {
 	int i;
+
 	outw(EE_ENB, ee_ioaddr);
 	for (i = 0; i < 10000; i++)			/* Typical 2000 ticks */
 		if (inw(ee_ioaddr) & EE_DATA_READ)
@@ -305,7 +309,7 @@ write_config_word(int bus, int dev, int func, int reg, u16 data)
 int main (int argc, char *argv[])
 {
 	unsigned char *eth_addr;
-	char buf[6];
+	unsigned char buf[6];
 	int instance;
 
 	app_startup(argv);
diff --git a/include/asm-i386/string.h b/include/asm-i386/string.h
index 91a23f9..3b838b4 100644
--- a/include/asm-i386/string.h
+++ b/include/asm-i386/string.h
@@ -5,6 +5,8 @@
  * We don't do inline string functions, since the
  * optimised inline asm versions are not small.
  */
+#undef __HAVE_ARCH_STRNCPY
+extern char *strncpy(char *dest, const char *src, size_t count);
 
 #undef __HAVE_ARCH_STRRCHR
 extern char * strrchr(const char * s, int c);
-- 
1.5.5.1





More information about the U-Boot mailing list