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;
                                newp = newval[++stridx];
                }
                if (*newp != ']') {
-                       printf("Unexpected character '%c'\n", *newval);
+                       printf("Unexpected character '%c'\n", *newp);
                        return 1;
                }
        } else {
                        }
                        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;
 
  */
 
 #define putnstr(str,n) do {                    \
-               printf ("%.*s", n, str);        \
+               printf ("%.*s", (int)n, str);   \
        } while (0)
 
 #define CTL_CH(c)              ((c) - 'a' + 1)
 
 
        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);
        }
 }
 
        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++;
        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
 
 }
 
 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 */
  */
 
 /* serial stuff */
-void   serial_printf (const char *fmt, ...);
+void   serial_printf (const char *fmt, ...)
+               __attribute__ ((format (__printf__, 1, 2)));
 
 /* stdin */
 int    getc(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 */
 #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);
 
 
        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);
        }
 
                                 */
                                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:
                        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)) {
                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");
 
                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