diff --git a/util/led/debug.h b/util/led/debug.h index 979e0cec8..da1e1e972 100644 --- a/util/led/debug.h +++ b/util/led/debug.h @@ -7,6 +7,7 @@ #ifndef __DEBUG_H_INCLUDED__ #define __DEBUG_H_INCLUDED__ +#include "error.h" #ifdef NDEBUG @@ -15,13 +16,11 @@ #else extern int DEB; -#define debug(s, a1, a2, a3, a4) (DEB && printf(s, a1, a2, a3, a4)) +#define debug(s, a1, a2, a3, a4) (DEB && do_debug(s, a1, a2, a3, a4)) #endif extern int Verbose; #define verbose(s, a1, a2, a3, a4) (Verbose && do_verbose(s, a1, a2, a3, a4)) -extern void fatal(char* format, ...); - #endif /* __DEBUG_H_INCLUDED__ */ diff --git a/util/led/error.c b/util/led/error.c index 1d2be80b0..73125136a 100644 --- a/util/led/error.c +++ b/util/led/error.c @@ -60,6 +60,17 @@ void error(char *format, ...) va_end(ap); } +/* VARARGS1 */ +int do_debug(char *format, ...) +{ + /* printf() and return 1 */ + va_list ap; + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + return 1; +} + /* VARARGS1 */ int do_verbose(char *format, ...) { diff --git a/util/led/error.h b/util/led/error.h index 8071a9f06..637b1c42c 100644 --- a/util/led/error.h +++ b/util/led/error.h @@ -13,6 +13,7 @@ void stop(void); void fatal(char *format, ...); void warning(char *format, ...); void error(char *format, ...); +int do_debug(char *format, ...); int do_verbose(char *format, ...); diff --git a/util/led/main.c b/util/led/main.c index 4fcb42900..1ba5d7fac 100644 --- a/util/led/main.c +++ b/util/led/main.c @@ -580,7 +580,7 @@ void addbase(struct outname *name) address((name->on_type & S_EXT) ? ALLOGCHR : ALLOLCHR, (ind_t)name->on_foff ), - name->on_type, name->on_valu, 0 + name->on_type, (unsigned long)name->on_valu, 0 ); } diff --git a/util/led/relocate.c b/util/led/relocate.c index 9f7df829d..a167645d0 100644 --- a/util/led/relocate.c +++ b/util/led/relocate.c @@ -416,7 +416,8 @@ static void put_mips_valu(char* addr, uint32_t value) /* The two bottom zero bits are implicit. */ if (value & 3) - fatal("invalid MIPS relocation value 0x%x", value); + fatal("invalid MIPS relocation value 0x%lx", + (unsigned long)value); value >>= 2; switch (opcode >> 26) @@ -560,7 +561,8 @@ void relocate(struct outhead *head, char* emit, struct outname names[], struct o * Pick up previous value at location to be relocated. */ valu = getvalu(emit + (relo->or_addr - off), relo->or_type); - debug("read relocation from 0x%08x type 0x%x value 0x%08x symbol %d\n", realaddress, relo->or_type, valu, relo->or_nami); + debug("read relocation from 0x%08lx type 0x%x value 0x%08lx symbol %u\n", + (unsigned long)realaddress, relo->or_type, valu, relo->or_nami); /* * Or_nami is an index in the name table of the considered module. @@ -595,7 +597,8 @@ void relocate(struct outhead *head, char* emit, struct outname names[], struct o /* * Now put the value back. */ - debug("written fixed up relocation to 0x%08x type 0x%x value 0x%08x\n", realaddress, relo->or_type, valu, 0); + debug("written fixed up relocation to 0x%08lx type 0x%x value 0x%08lx\n", + (unsigned long)realaddress, relo->or_type, valu, 0); putvalu(valu, emit + (relo->or_addr - off), relo->or_type); /* diff --git a/util/led/sym.c b/util/led/sym.c index e946a5a17..8320a5a4c 100644 --- a/util/led/sym.c +++ b/util/led/sym.c @@ -19,6 +19,7 @@ static char rcsid[] = "$Id$"; #include "error.h" #include "memory.h" #include "debug.h" +#include "save.h" #include "sym.h" /* @@ -66,7 +67,8 @@ struct outname *searchname(char *string, int hashval) register struct symbol *sym; symindex = hashtable[hashval]; - debug("looking for %s %d %ld:", string, hashval, hashtable[hashval], 0); + debug("looking for %s %d %z:", string, hashval, + (size_t)hashtable[hashval], 0); while (symindex != BADOFF) { sym = (struct symbol *)address(ALLOSYMB, symindex); name = (struct outname *)address(ALLOGLOB, sym->sy_name); @@ -76,7 +78,8 @@ struct outname *searchname(char *string, int hashval) while (*rcp == *namestring++) if (*rcp++ == '\0') { debug("found %x, %x, %lx\n", - name->on_type, name->on_desc, name->on_valu, 0); + name->on_type, name->on_desc, + (unsigned long)name->on_valu, 0); return name; } symindex = sym->sy_next; @@ -99,12 +102,11 @@ void entername(struct outname* name, int hashval) ind_t namindex; register struct symbol *sym; struct outname *newname; - extern ind_t savechar(); debug("entername %s %d %x %x", modulptr((ind_t)name->on_foff), hashval, name->on_type, name->on_desc); savindex = savechar(ALLOGCHR, (ind_t)name->on_foff); symindex = hard_alloc(ALLOSYMB, (long)sizeof(struct symbol)); - debug("; %ld\n", symindex, 0, 0, 0); + debug("; %z\n", (size_t)symindex, 0, 0, 0); namindex = hard_alloc(ALLOGLOB, (long)sizeof(struct outname)); if (savindex == BADOFF || symindex == BADOFF || namindex == BADOFF) fatal("symbol table overflow"); @@ -137,7 +139,7 @@ int hash(register char* p) register unsigned short h = 0; register int c; - while (c = *p++) { + while ((c = *p++) != '\0') { h <<= 2; h += c; }