Skip to content
Snippets Groups Projects
Commit dc4b0b38 authored by Andrew Klossner's avatar Andrew Klossner Committed by Wolfgang Denk
Browse files

Fix printf errors.


The compiler will help find mismatches between printf formats and
arguments if you let it.  This patch adds the necessary attributes to
declarations in include/common.h, then begins to correct the resulting
compiler warnings.  Some of these were bugs, e.g., "$d" instead of
"%d" and incorrect arguments.  Others were just annoying, like
int-long mismatches on a system where both are 32 bits.  It's worth
fixing the annoying errors to catch the real ones.

Signed-off-by: default avatarAndrew Klossner <andrew@cesa.opbu.xerox.com>
parent a292d226
Branches
Tags reform2-rc1
No related merge requests found
......@@ -451,14 +451,14 @@ static int fdt_valid(void)
if (err == -FDT_ERR_BADVERSION) {
if (fdt_version(working_fdt) <
FDT_FIRST_SUPPORTED_VERSION) {
printf (" - too old, fdt $d < %d",
printf (" - too old, fdt %d < %d",
fdt_version(working_fdt),
FDT_FIRST_SUPPORTED_VERSION);
working_fdt = NULL;
}
if (fdt_last_comp_version(working_fdt) >
FDT_LAST_SUPPORTED_VERSION) {
printf (" - too new, fdt $d > %d",
printf (" - too new, fdt %d > %d",
fdt_version(working_fdt),
FDT_LAST_SUPPORTED_VERSION);
working_fdt = NULL;
......@@ -546,7 +546,7 @@ static int fdt_parse_prop(char **newval, int count, char *data, int *len)
newp = newval[++stridx];
}
if (*newp != ']') {
printf("Unexpected character '%c'\n", *newval);
printf("Unexpected character '%c'\n", *newp);
return 1;
}
} else {
......@@ -763,7 +763,7 @@ static int fdt_print(const char *pathp, char *prop, int depth)
}
break;
case FDT_NOP:
printf("/* NOP */\n", &tabs[MAX_LEVEL - level]);
printf("%s/* NOP */\n", &tabs[MAX_LEVEL - level]);
break;
case FDT_END:
return 1;
......
......@@ -509,7 +509,7 @@ void reset_cmd_timeout(void)
*/
#define putnstr(str,n) do { \
printf ("%.*s", n, str); \
printf ("%.*s", (int)n, str); \
} while (0)
#define CTL_CH(c) ((c) - 'a' + 1)
......
......@@ -216,10 +216,10 @@ MachineCheckException(struct pt_regs *regs)
if (machinecheck_count > 1) {
regs->nip += 4; /* skip offending instruction */
printf("Skipping current instr, Returning to 0x%08x\n",
printf("Skipping current instr, Returning to 0x%08lx\n",
regs->nip);
} else {
printf("Returning back to 0x%08x\n",regs->nip);
printf("Returning back to 0x%08lx\n",regs->nip);
}
}
......@@ -302,7 +302,7 @@ ExtIntException(struct pt_regs *regs)
printf("External Interrupt Exception at PC: %lx, SR: %lx, vector=%lx",
regs->nip, regs->msr, regs->trap);
vect = pic->iack0;
printf(" irq IACK0@%05x=%d\n",&pic->iack0,vect);
printf(" irq IACK0@%05x=%d\n",(int)&pic->iack0,vect);
show_regs(regs);
print_backtrace((unsigned long *)regs->gpr[1]);
machinecheck_count++;
......@@ -310,7 +310,7 @@ ExtIntException(struct pt_regs *regs)
printf("Returning back to 0x%08x\n",regs->nip);
#else
regs->nip += 4; /* skip offending instruction */
printf("Skipping current instr, Returning to 0x%08x\n",regs->nip);
printf("Skipping current instr, Returning to 0x%08lx\n",regs->nip);
#endif
}
......
......@@ -607,8 +607,10 @@ ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base);
#endif
long simple_strtol(const char *cp,char **endp,unsigned int base);
void panic(const char *fmt, ...);
int sprintf(char * buf, const char *fmt, ...);
void panic(const char *fmt, ...)
__attribute__ ((format (__printf__, 1, 2)));
int sprintf(char * buf, const char *fmt, ...)
__attribute__ ((format (__printf__, 2, 3)));
int vsprintf(char *buf, const char *fmt, va_list args);
/* lib_generic/crc32.c */
......@@ -630,7 +632,8 @@ int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */
*/
/* serial stuff */
void serial_printf (const char *fmt, ...);
void serial_printf (const char *fmt, ...)
__attribute__ ((format (__printf__, 1, 2)));
/* stdin */
int getc(void);
......@@ -639,7 +642,8 @@ int tstc(void);
/* stdout */
void putc(const char c);
void puts(const char *s);
void printf(const char *fmt, ...);
void printf(const char *fmt, ...)
__attribute__ ((format (__printf__, 1, 2)));
void vprintf(const char *fmt, va_list args);
/* stderr */
......@@ -656,7 +660,8 @@ void vprintf(const char *fmt, va_list args);
#define stderr 2
#define MAX_FILES 3
void fprintf(int file, const char *fmt, ...);
void fprintf(int file, const char *fmt, ...)
__attribute__ ((format (__printf__, 2, 3)));
void fputs(int file, const char *s);
void fputc(int file, const char c);
int ftstc(int file);
......
......@@ -105,7 +105,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if (size < bootm_size) {
ulong base = bootmap_base + size;
printf("WARNING: adjusting available memory to %x\n", size);
printf("WARNING: adjusting available memory to %lx\n", size);
lmb_reserve(lmb, base, bootm_size - size);
}
......@@ -672,7 +672,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
*/
fdt_blob = (char *)fdt_addr;
debug ("* fdt: raw FDT blob\n");
printf ("## Flattened Device Tree blob at %08lx\n", fdt_blob);
printf ("## Flattened Device Tree blob at %08lx\n", (long)fdt_blob);
}
break;
default:
......@@ -680,7 +680,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
goto error;
}
printf (" Booting using the fdt blob at 0x%x\n", fdt_blob);
printf (" Booting using the fdt blob at 0x%x\n", (int)fdt_blob);
} else if (images->legacy_hdr_valid &&
image_check_type (&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
......@@ -699,7 +699,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if (fdt_len) {
fdt_blob = (char *)fdt_data;
printf (" Booting using the fdt at 0x%x\n", fdt_blob);
printf (" Booting using the fdt at 0x%x\n", (int)fdt_blob);
if (fdt_check_header (fdt_blob) != 0) {
fdt_error ("image is not a fdt");
......
......@@ -178,7 +178,7 @@ TftpSend (void)
pkt += 5 /*strlen("octet")*/ + 1;
strcpy ((char *)pkt, "timeout");
pkt += 7 /*strlen("timeout")*/ + 1;
sprintf((char *)pkt, "%d", TIMEOUT);
sprintf((char *)pkt, "%lu", TIMEOUT);
#ifdef ET_DEBUG
printf("send option \"timeout %s\"\n", (char *)pkt);
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment