Fix gcc warnings on MIPS 64 bit
Subsystems (2)
cover Fix gcc warnings on MIPS 64 bit
From: Daniel Schwierzeck <[email protected]>
This series fixes the first bunch of gcc warnings appearing when compiling for MIPS 64 bit.
For testing purposes all patches are also queued in branch testing atgit://git.denx.de/u-boot-mips.git. The support for MIPS64 and qemu_mips64 is already included.
Daniel Schwierzeck (4):
lib: vsprintf.c: fix checkpath.pl warnings
lib: vsprintf.c: replace NUM_TYPE with s64/u64 types
common: cmd_elf.c: fix checkpath.pl warnings
common: cmd_elf.c: use uintptr_t for casts from u32 to void*
common/cmd_elf.c | 137 ++++++++++++++++++++++++++++--------------------------- lib/vsprintf.c | 134 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 149 insertions(+), 122 deletions(-)
Signature · 1 line
1.7.11.3
PATCH 1/4 lib: vsprintf.c: fix checkpath.pl warnings
From: Daniel Schwierzeck <[email protected]>
--- lib/vsprintf.c | 127 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 77 insertions(+), 50 deletions(-)
lib/vsprintf.c +77 -50
@@ -18,7 +18,7 @@#include <errno.h> #include <common.h> -#if !defined (CONFIG_PANIC_HANG ) +#if !defined(CONFIG_PANIC_HANG )#include <command.h> #endif
@@ -40,9 +40,11 @@ static inline char *pack_hex_byte(char *buf, u8 byte)return buf; } -unsigned long simple_strtoul (const char *cp,char **endp,unsigned int base) +unsigned long simple_strtoul (const char *cp,char **endp, +unsigned int base) { -unsigned long result =0 ,value; +unsigned long result =0 ; +unsigned long value;if (*cp =='0' ) { cp++;
@@ -50,20 +52,23 @@ unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) base =16 ; cp++; } -if (!base) { + +if (!base) base =8 ; - } } -if (!base) { + +if (!base) base =10 ; - } +while (isxdigit (*cp) && (value =isdigit (*cp) ? *cp-'0' : (islower (*cp) ?toupper (*cp) : *cp)-'A' +10 ) < base) { result = result*base + value; cp++; } +if (endp) *endp = (char *)cp; +return result; }
@@ -91,18 +96,19 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)return -EINVAL ; } -long simple_strtol (const char *cp,char **endp,unsigned int base) +long simple_strtol (const char *cp,char **endp,unsigned int base) { -if (*cp=='-' ) -return -simple_strtoul (cp+1 ,endp,base); -return simple_strtoul (cp,endp,base); +if (*cp =='-' ) +return -simple_strtoul (cp +1 , endp, base); + +return simple_strtoul (cp, endp, base); }int ustrtoul (const char *cp,char **endp,unsigned int base) {unsigned long result =simple_strtoul (cp, endp, base);switch (**endp) { -case 'G' : +case 'G' : result *=1024 ;/* fall through */ case 'M' :
@@ -121,31 +127,34 @@ int ustrtoul(const char *cp, char **endp, unsigned int base)return result; } -unsigned long long simple_strtoull (const char *cp,char **endp,unsigned int base) +unsigned long long simple_strtoull (const char *cp,char **endp, +unsigned int base) {unsigned long long result =0 , value;if (*cp =='0' ) { cp++; -if ((*cp =='x' ) &&isxdigit (cp[1 ])) { +if ((*cp =='x' ) &&isxdigit (cp[1 ])) { base =16 ; cp++; } -if (!base) { + +if (!base) base =8 ; - } } -if (!base) { + +if (!base) base =10 ; - } -while (isxdigit (*cp) && (value =isdigit (*cp) - ? *cp -'0' - : (islower (*cp) ?toupper (*cp) : *cp) -'A' +10 ) < base) { + +while (isxdigit (*cp) && (value =isdigit (*cp) ? *cp -'0' + : (islower (*cp) ?toupper (*cp) : *cp) -'A' +10 ) < base) { result = result * base + value; cp++; } +if (endp) *endp = (char *) cp; +return result; }
@@ -154,10 +163,11 @@ unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int bastatic int skip_atoi (const char **s) { -int i=0 ; +int i =0 ;while (is_digit (**s)) - i = i*10 + *((*s)++) -'0' ; + i = i *10 + *((*s)++) -'0' ; +return i; }
@@ -171,7 +181,7 @@ static int skip_atoi(const char **s)/* Formats correctly any integer in [0,99999]. * Outputs from one to five digits depending on input. * On i386 gcc 4.1.2 -O2: ~250 bytes of code. */ -static char *put_dec_trunc (char *buf,unsigned q) +static char *put_dec_trunc (char *buf,unsigned q) {unsigned d3, d2, d1, d0; d1 = (q>>4 ) &0xf ;
@@ -200,14 +210,14 @@ static char* put_dec_trunc(char *buf, unsigned q) d3 = d3 -10 *q; *buf++ = d3 +'0' ;/* next digit */ if (q !=0 ) - *buf++ = q +'0' ;/* most sign. digit */ + *buf++ = q +'0' ;/* most sign. digit */ } } }return buf; }/* Same with if's removed. Always emits five digits */ -static char *put_dec_full (char *buf,unsigned q) +static char *put_dec_full (char *buf,unsigned q) {/* BTW, if q is in [0,9999], 8-bit ints will be enough, */ /* but anyway, gcc produces better code with full-sized ints */
@@ -249,7 +259,7 @@ static char* put_dec_full(char *buf, unsigned q)return buf; }/* No inlining helps gcc to use registers better */ -static noinline char* put_dec(char *buf, unsigned NUM_TYPE num) +static noinline char *put_dec(char *buf, unsigned NUM_TYPE num) {while (1 ) {unsigned rem;
@@ -286,7 +296,7 @@ static char *number(char *buf, char *end, unsigned NUM_TYPE num, int base, int size, int precision, int type) { /* we are called with base 8, 10 or 16, only, thus don't need "G..." */ - static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */ + static const char digits[16] = "0123456789ABCDEF";char tmp[66 ];char sign;
@@ -303,7 +313,7 @@ static char *number(char *buf, char *end, unsigned NUM_TYPE num,if (type &SIGN ) {if ((signed NUM_TYPE ) num <0 ) { sign ='-' ; - num = - (signed NUM_TYPE ) num; + num = -(signed NUM_TYPE ) num; size--; }else if (type &PLUS ) { sign ='+' ;
@@ -331,9 +341,13 @@ static char *number(char *buf, char *end, unsigned NUM_TYPE num,else if (base !=10 ) {/* 8 or 16 */ int mask = base -1 ;int shift =3 ; -if (base ==16 ) shift =4 ; + +if (base ==16 ) + shift =4 ; +do { - tmp[i++] = (digits[((unsigned char )num) & mask] | locase); + tmp[i++] = (digits[((unsigned char )num) & mask] + | locase); num >>= shift; }while (num); }else {/* base 10 */
@@ -401,7 +415,8 @@ static char *string(char *buf, char *end, char *s, int field_width,static char *mac_address_string (char *buf,char *end,u8 *addr,int field_width,int precision,int flags) { -char mac_addr[6 *3 ];/* (6 * 2 hex digits), 5 colons and trailing zero */ +/* (6 * 2 hex digits), 5 colons and trailing zero */ +char mac_addr[6 *3 ];char *p = mac_addr;int i;
@@ -419,7 +434,8 @@ static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,static char *ip6_addr_string (char *buf,char *end,u8 *addr,int field_width,int precision,int flags) { -char ip6_addr[8 *5 ];/* (8 * 4 hex digits), 7 colons and trailing zero */ +/* (8 * 4 hex digits), 7 colons and trailing zero */ +char ip6_addr[8 *5 ];char *p = ip6_addr;int i;
@@ -438,7 +454,8 @@ static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width,static char *ip4_addr_string (char *buf,char *end,u8 *addr,int field_width,int precision,int flags) { -char ip4_addr[4 *4 ];/* (4 * 3 decimal digits), 3 dots and trailing zero */ +/* (4 * 3 decimal digits), 3 dots and trailing zero */ +char ip4_addr[4 *4 ];char temp[3 ];/* hold each IP quad in reverse order */ char *p = ip4_addr;int i, digits;
@@ -549,14 +566,24 @@ static int vsnprintf_internal(char *buf, size_t size, const char *fmt,/* process flags */ flags =0 ; - repeat: +repeat: ++fmt;/* this also skips first '%' */ switch (*fmt) { -case '-' : flags |=LEFT ; goto repeat; -case '+' : flags |=PLUS ; goto repeat; -case ' ' : flags |=SPACE ; goto repeat; -case '#' : flags |=SPECIAL ; goto repeat; -case '0' : flags |=ZEROPAD ; goto repeat; +case '-' : + flags |=LEFT ; + goto repeat; +case '+' : + flags |=PLUS ; + goto repeat; +case ' ' : + flags |=SPACE ; + goto repeat; +case '#' : + flags |=SPECIAL ; + goto repeat; +case '0' : + flags |=ZEROPAD ; + goto repeat; }/* get field width */
@@ -620,7 +647,7 @@ static int vsnprintf_internal(char *buf, size_t size, const char *fmt,continue ;case 'p' : - str =pointer (fmt+1 , str, end, + str =pointer (fmt +1 , str, end, va_arg(args, void *), field_width, precision, flags);/* Skip all alphanumeric pointer suffixes */
@@ -630,10 +657,10 @@ static int vsnprintf_internal(char *buf, size_t size, const char *fmt,case 'n' :if (qualifier =='l' ) { - long * ip = va_arg(args, long *); + long *ip = va_arg(args, long *); *ip = (str - buf); }else { - int * ip = va_arg(args, int *); + int *ip = va_arg(args, int *); *ip = (str - buf); }continue ;
@@ -700,7 +727,7 @@ static int vsnprintf_internal(char *buf, size_t size, const char *fmt, *str ='\0' ;#endif /* the trailing null byte doesn't count towards the total */ -return str-buf; +return str - buf; }#ifdef CONFIG_SYS_VSNPRINTF
@@ -766,29 +793,29 @@ int vsprintf(char *buf, const char *fmt, va_list args)return vsnprintf_internal (buf,INT_MAX , fmt, args); } -int sprintf (char * buf,const char *fmt, ...) +int sprintf (char *buf,const char *fmt, ...) {va_list args;int i;va_start (args, fmt); - i=vsprintf (buf,fmt,args); + i =vsprintf (buf, fmt, args);va_end (args);return i; }void panic (const char *fmt, ...) { -va_list args; +va_list args;va_start (args, fmt);vprintf (fmt, args);putc ('\n' );va_end (args); -#if defined (CONFIG_PANIC_HANG ) +#if defined(CONFIG_PANIC_HANG )hang ();#else -udelay (100000 );/* allow messages to go out */ -do_reset (NULL ,0 ,0 ,NULL ); +udelay (100000 );/* allow messages to go out */ +do_reset (NULL ,0 ,0 ,NULL );#endif while (1 ) ;
Signature · 1 line
1.7.11.3
PATCH 1/4 lib: vsprintf.c: fix checkpath.pl warnings
Quoted 3 lines · Daniel Schwierzeck
From: Daniel Schwierzeck <[email protected]>
Signed-off-by Daniel Schwierzeck <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120927/dacba089/attachment.pgp>
PATCH 2/4 lib: vsprintf.c: replace NUM_TYPE with s64/u64 types
In reply to daniel.schwierzeck at gmail.comFrom: Daniel Schwierzeck <[email protected]>
This fixes warnings when compiling with ELDK-5.2.1 for MIPS64:
vsprintf.c: In function 'put_dec':
vsprintf.c:258:9: warning: comparison of distinct pointer types lacks a cast [enabled by default] vsprintf.c:258:3: warning: passing argument 1 of '__div64_32' from incompatible pointer type [enabled by default] include/div64.h:22:17: note: expected 'uint64_t *' but argument is of type 'long long unsigned int *'
--- lib/vsprintf.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
lib/vsprintf.c +5 -6
@@ -23,7 +23,6 @@#endif #include <div64.h> -# define NUM_TYPE long long#define noinline __attribute__((noinline))/* some reluctance to put this into a new limits.h, so it is here */
@@ -259,7 +258,7 @@ static char *put_dec_full(char *buf, unsigned q)return buf; }/* No inlining helps gcc to use registers better */ -static noinline char *put_dec(char *buf, unsigned NUM_TYPE num) +static noinline char *put_dec(char *buf, u64 num) {while (1 ) {unsigned rem;
@@ -292,7 +291,7 @@ static noinline char *put_dec(char *buf, unsigned NUM_TYPE num)#define ADDCH (str, ch) (*(str)++ = (ch))#endif -static char *number (char *buf,char *end,unsigned NUM_TYPE num, +static char *number (char *buf,char *end,u64 num,int base,int size,int precision,int type) {/* we are called with base 8, 10 or 16, only, thus don't need "G..." */
@@ -311,9 +310,9 @@ static char *number(char *buf, char *end, unsigned NUM_TYPE num, type &= ~ZEROPAD ; sign =0 ;if (type &SIGN ) { -if ((signed NUM_TYPE ) num <0 ) { +if ((s64 ) num <0 ) { sign ='-' ; - num = -(signed NUM_TYPE ) num; + num = -(s64 ) num; size--; }else if (type &PLUS ) { sign ='+' ;
@@ -534,7 +533,7 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,static int vsnprintf_internal (char *buf,size_t size,const char *fmt,va_list args) { -unsigned NUM_TYPE num; +u64 num;int base;char *str;
Signature · 1 line
1.7.11.3
PATCH 2/4 lib: vsprintf.c: replace NUM_TYPE with s64/u64 types
Quoted 10 lines · Daniel Schwierzeck
From: Daniel Schwierzeck <[email protected]>
This fixes warnings when compiling with ELDK-5.2.1 for MIPS64:
vsprintf.c: In function 'put_dec':
vsprintf.c:258:9: warning: comparison of distinct pointer types lacks a cast [enabled by default] vsprintf.c:258:3: warning: passing argument 1 of '__div64_32' from incompatible pointer type [enabled by default]include/div64.h:22:17: note: expected 'uint64_t*' but argument is of type 'long long unsigned int *'Signed-off-by Daniel Schwierzeck <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120927/b50a0086/attachment.pgp>
PATCH 3/4 common: cmd_elf.c: fix checkpath.pl warnings
In reply to daniel.schwierzeck at gmail.comFrom: Daniel Schwierzeck <[email protected]>
--- common/cmd_elf.c | 134 +++++++++++++++++++++++++++---------------------------- 1 file changed, 67 insertions(+), 67 deletions(-)
common/cmd_elf.c +67 -67
@@ -24,13 +24,13 @@DECLARE_GLOBAL_DATA_PTR ;#endif -int valid_elf_image (unsigned long addr); +static int valid_elf_image (unsigned long addr);static unsigned long load_elf_image_phdr (unsigned long addr);static unsigned long load_elf_image_shdr (unsigned long addr);/* Allow ports to override the default behavior */ __attribute__((weak)) -unsigned long do_bootelf_exec (ulong (*entry)(int ,char *const []), +unsigned long do_bootelf_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]) {unsigned long ret;
@@ -39,18 +39,18 @@ unsigned long do_bootelf_exec (ulong (*entry)(int, char * const[]),* QNX images require the data cache is disabled. * Data cache is already flushed, so just turn it off. */ -int dcache =dcache_status (); +int dcache =dcache_status ();if (dcache) -dcache_disable (); +dcache_disable ();/* * pass address parameter as argv[0] (aka command name), * and all remaining args */ - ret =entry (argc, argv); + ret =entry (argc, argv);if (dcache) -dcache_enable (); +dcache_enable ();return ret; }
@@ -58,7 +58,7 @@ unsigned long do_bootelf_exec (ulong (*entry)(int, char * const[]),/* ====================================================================== * Interpreter command to boot an arbitrary ELF image from memory. * ====================================================================== */ -int do_bootelf (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +int do_bootelf (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {unsigned long addr;/* Address of the ELF image */ unsigned long rc;/* Return value from user code */
@@ -83,7 +83,7 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])else addr = load_addr; -if (!valid_elf_image (addr)) +if (!valid_elf_image (addr))return 1 ;if (sload && sload[1 ] =='p' )
@@ -91,17 +91,17 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])else addr =load_elf_image_shdr (addr); -printf ("## Starting application at 0x%08lx ...\n" , addr); +printf ("## Starting application at 0x%08lx ...\n" , addr);/* * pass address parameter as argv[0] (aka command name), * and all remaining args */ - rc =do_bootelf_exec ((void *)addr, argc -1 , argv +1 ); + rc =do_bootelf_exec ((void *)addr, argc -1 , argv +1 );if (rc !=0 ) rcode =1 ; -printf ("## Application terminated, rc = 0x%lx\n" , rc); +printf ("## Application terminated, rc = 0x%lx\n" , rc);return rcode; }
@@ -110,10 +110,10 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])* be either an ELF image or a raw binary. Will attempt to setup the * bootline and other parameters correctly. * ====================================================================== */ -int do_bootvx (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +int do_bootvx (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {unsigned long addr;/* Address of image */ -unsigned long bootaddr;/* Address to put the bootline */ +unsigned long bootaddr;/* Address to put the bootline */ char *bootline;/* Text of the bootline */ char *tmp;/* Temporary char pointer */ char build_buf[128 ];/* Buffer for building the bootline */
@@ -127,16 +127,17 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <2 ) addr = load_addr;else - addr =simple_strtoul (argv[1 ],NULL ,16 ); + addr =simple_strtoul (argv[1 ],NULL ,16 );#if defined(CONFIG_CMD_NET ) -/* Check to see if we need to tftp the image ourselves before starting */ - -if ((argc ==2 ) && (strcmp (argv[1 ],"tftp" ) ==0 )) { +/* +* Check to see if we need to tftp the image ourselves before starting +*/ +if ((argc ==2 ) && (strcmp (argv[1 ],"tftp" ) ==0 )) {if (NetLoop (TFTPGET ) <=0 )return 1 ; -printf ("Automatic boot of VxWorks image at address 0x%08lx " -"...\n" , addr); +printf ("Automatic boot of VxWorks image at address 0x%08lx ...\n" , + addr); }#endif
@@ -155,7 +156,7 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])eth_getenv_enetaddr ("ethaddr" , (uchar *)build_buf);memcpy (tmp, build_buf,6 );#else -puts ("## Ethernet MAC address not copied to NV RAM\n" ); +puts ("## Ethernet MAC address not copied to NV RAM\n" );#endif /*
@@ -164,53 +165,52 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])* PowerPC is LOCAL_MEM_LOCAL_ADRS + BOOT_LINE_OFFSET which * defaults to 0x4200 */ - -if ((tmp =getenv ("bootaddr" )) ==NULL ) + tmp =getenv ("bootaddr" ); +if (tmp) bootaddr =CONFIG_SYS_VXWORKS_BOOT_ADDR ;else - bootaddr =simple_strtoul (tmp,NULL ,16 ); + bootaddr =simple_strtoul (tmp,NULL ,16 );/* * Check to see if the bootline is defined in the 'bootargs' * parameter. If it is not defined, we may be able to * construct the info */ - -if ((bootline =getenv ("bootargs" )) !=NULL ) { -memcpy ((void *) bootaddr, bootline, -max (strlen (bootline),255 )); -flush_cache (bootaddr,max (strlen (bootline),255 )); + bootline =getenv ("bootargs" ); +if (bootline) { +memcpy ((void *) bootaddr, bootline, +max (strlen (bootline),255 )); +flush_cache (bootaddr,max (strlen (bootline),255 )); }else { - - -sprintf (build_buf,CONFIG_SYS_VXWORKS_BOOT_DEVICE ); -if ((tmp =getenv ("bootfile" )) !=NULL ) { -sprintf (&build_buf[strlen (build_buf)], +sprintf (build_buf,CONFIG_SYS_VXWORKS_BOOT_DEVICE ); + tmp =getenv ("bootfile" ); +if (tmp) +sprintf (&build_buf[strlen (build_buf)],"%s:%s " ,CONFIG_SYS_VXWORKS_SERVERNAME , tmp); - }else { -sprintf (&build_buf[strlen (build_buf)], +else +sprintf (&build_buf[strlen (build_buf)],"%s:file " ,CONFIG_SYS_VXWORKS_SERVERNAME ); - } -if ((tmp =getenv ("ipaddr" )) !=NULL ) { -sprintf (&build_buf[strlen (build_buf)],"e=%s " , tmp); - } + tmp =getenv ("ipaddr" ); +if (tmp) +sprintf (&build_buf[strlen (build_buf)],"e=%s " , tmp); -if ((tmp =getenv ("serverip" )) !=NULL ) { -sprintf (&build_buf[strlen (build_buf)],"h=%s " , tmp); - } + tmp =getenv ("serverip" ); +if (tmp) +sprintf (&build_buf[strlen (build_buf)],"h=%s " , tmp); + + tmp =getenv ("hostname" ); +if (tmp) +sprintf (&build_buf[strlen (build_buf)],"tn=%s " , tmp); -if ((tmp =getenv ("hostname" )) !=NULL ) { -sprintf (&build_buf[strlen (build_buf)],"tn=%s " , tmp); - }#ifdef CONFIG_SYS_VXWORKS_ADD_PARAMS -sprintf (&build_buf[strlen (build_buf)], +sprintf (&build_buf[strlen (build_buf)],CONFIG_SYS_VXWORKS_ADD_PARAMS );#endif -memcpy ((void *) bootaddr, build_buf, -max (strlen (build_buf),255 )); -flush_cache (bootaddr,max (strlen (build_buf),255 )); +memcpy ((void *) bootaddr, build_buf, +max (strlen (build_buf),255 )); +flush_cache (bootaddr,max (strlen (build_buf),255 )); }/*
@@ -219,21 +219,21 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])* binary image */ -if (valid_elf_image (addr)) { - addr =load_elf_image_shdr (addr); +if (valid_elf_image (addr)) { + addr =load_elf_image_shdr (addr); }else { -puts ("## Not an ELF image, assuming binary\n" ); +puts ("## Not an ELF image, assuming binary\n" );/* leave addr as load_addr */ } -printf ("## Using bootline (@ 0x%lx): %s\n" , bootaddr, +printf ("## Using bootline (@ 0x%lx): %s\n" , bootaddr, (char *) bootaddr); -printf ("## Starting vxWorks at 0x%08lx ...\n" , addr); +printf ("## Starting vxWorks at 0x%08lx ...\n" , addr);dcache_disable (); ((void (*)(int )) addr) (0 ); -puts ("## vxWorks terminated\n" ); +puts ("## vxWorks terminated\n" );return 1 ; }
@@ -242,7 +242,7 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])* First looks at the ELF header magic field, the makes sure that it is * executable and makes sure that it is for a PowerPC. * ====================================================================== */ -int valid_elf_image (unsigned long addr) +int valid_elf_image (unsigned long addr) {Elf32_Ehdr *ehdr;/* Elf header structure pointer */
@@ -250,20 +250,19 @@ int valid_elf_image (unsigned long addr) ehdr = (Elf32_Ehdr *) addr; -if (!IS_ELF (*ehdr)) { -printf ("## No elf image at address 0x%08lx\n" , addr); +if (!IS_ELF (*ehdr)) { +printf ("## No elf image@address 0x%08lx\n" , addr);return 0 ; }if (ehdr->e_type !=ET_EXEC ) { -printf ("## Not a 32-bit elf image at address 0x%08lx\n" , addr); +printf ("## Not a 32-bit elf image at address 0x%08lx\n" , addr);return 0 ; }#if 0 if (ehdr->e_machine !=EM_PPC ) { -printf ("## Not a PowerPC elf image at address 0x%08lx\n" , - addr); +printf ("## Not a PowerPC elf image at address 0x%08lx\n" , addr);return 0 ; }#endif
@@ -293,7 +292,8 @@ static unsigned long load_elf_image_phdr(unsigned long addr)if (phdr->p_filesz)memcpy (dst, src, phdr->p_filesz);if (phdr->p_filesz != phdr->p_memsz) -memset (dst + phdr->p_filesz,0x00 , phdr->p_memsz - phdr->p_filesz); +memset (dst + phdr->p_filesz,0x00 , + phdr->p_memsz - phdr->p_filesz);flush_cache ((unsigned long )dst, phdr->p_filesz); ++phdr; }
@@ -315,7 +315,7 @@ static unsigned long load_elf_image_shdr(unsigned long addr)/* Find the section header string table for output info */ shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff + - (ehdr->e_shstrndx *sizeof (Elf32_Shdr))); + (ehdr->e_shstrndx *sizeof (Elf32_Shdr)));if (shdr->sh_type ==SHT_STRTAB ) strtab = (unsigned char *) (addr + shdr->sh_offset);
@@ -323,7 +323,7 @@ static unsigned long load_elf_image_shdr(unsigned long addr)/* Load each appropriate section */ for (i =0 ; i < ehdr->e_shnum; ++i) { shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff + - (i *sizeof (Elf32_Shdr))); + (i *sizeof (Elf32_Shdr)));if (!(shdr->sh_flags &SHF_ALLOC ) || shdr->sh_addr ==0 || shdr->sh_size ==0 ) {
@@ -340,14 +340,14 @@ static unsigned long load_elf_image_shdr(unsigned long addr) }if (shdr->sh_type ==SHT_NOBITS ) { -memset ((void *)shdr->sh_addr,0 , shdr->sh_size); +memset ((void *)shdr->sh_addr,0 , shdr->sh_size); }else { image = (unsigned char *) addr + shdr->sh_offset; -memcpy ((void *) shdr->sh_addr, +memcpy ((void *) shdr->sh_addr, (const void *) image, shdr->sh_size); } -flush_cache (shdr->sh_addr, shdr->sh_size); +flush_cache (shdr->sh_addr, shdr->sh_size); }return ehdr->e_entry;
Signature · 1 line
1.7.11.3
PATCH 3/4 common: cmd_elf.c: fix checkpath.pl warnings
Quoted 4 lines · Daniel Schwierzeck
From: Daniel Schwierzeck <[email protected]>
Signed-off-by Daniel Schwierzeck <[email protected]>
With a change to re-order the functions (board/w7o/ uses valid_elf_image as well) rather than mark valid_elf_image as static, applied to u-boot/next, thanks.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120927/d27d7a57/attachment.pgp>
PATCH 4/4 common: cmd_elf.c: use uintptr_t for casts from u32 to void*
In reply to daniel.schwierzeck at gmail.comFrom: Daniel Schwierzeck <[email protected]>
This fixes warnings when compiling with ELDK-5.2.1 for MIPS64:
cmd_elf.c: In function 'load_elf_image_phdr':
cmd_elf.c:289:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] cmd_elf.c: In function 'load_elf_image_shdr':
cmd_elf.c:343:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] cmd_elf.c:346:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
--- common/cmd_elf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
common/cmd_elf.c +4 -3
@@ -285,7 +285,7 @@ static unsigned long load_elf_image_phdr(unsigned long addr)/* Load each program header */ for (i =0 ; i < ehdr->e_phnum; ++i) { -void *dst = (void *) phdr->p_paddr; +void *dst = (void *)(uintptr_t ) phdr->p_paddr;void *src = (void *) addr + phdr->p_offset;debug ("Loading phdr %i to 0x%p (%i bytes)\n" , i, dst, phdr->p_filesz);
@@ -340,10 +340,11 @@ static unsigned long load_elf_image_shdr(unsigned long addr) }if (shdr->sh_type ==SHT_NOBITS ) { -memset ((void *)shdr->sh_addr,0 , shdr->sh_size); +memset ((void *)(uintptr_t ) shdr->sh_addr,0 , + shdr->sh_size); }else { image = (unsigned char *) addr + shdr->sh_offset; -memcpy ((void *) shdr->sh_addr, +memcpy ((void *)(uintptr_t ) shdr->sh_addr, (const void *) image, shdr->sh_size); }
Signature · 1 line
1.7.11.3
PATCH 4/4 common: cmd_elf.c: use uintptr_t for casts from u32 to void*
Quoted 11 lines · Daniel Schwierzeck
From: Daniel Schwierzeck <[email protected]>
This fixes warnings when compiling with ELDK-5.2.1 for MIPS64:
cmd_elf.c: In function 'load_elf_image_phdr':
cmd_elf.c:289:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]cmd_elf.c: In function 'load_elf_image_shdr':
cmd_elf.c:343:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] cmd_elf.c:346:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]Signed-off-by Daniel Schwierzeck <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120927/ffccfd0f/attachment.pgp>