changeset 2:7317fbe024af

Clean up insane number of compiler warnings under -Wall
author lost@l-w.ca
date Thu, 20 Jan 2011 22:39:46 -0700
parents 96c4dc89016e
children d4eb3c328a47
files Makefile lwar/add.c lwar/replace.c lwar/util.c lwasm/debug.c lwasm/input.c lwasm/insn_bitbit.c lwasm/insn_gen.c lwasm/insn_indexed.c lwasm/insn_logicmem.c lwasm/insn_rel.c lwasm/insn_rlist.c lwasm/lwasm.c lwasm/lwasm.h lwasm/macro.c lwasm/main.c lwasm/output.c lwasm/pass1.c lwasm/pass5.c lwasm/pragma.c lwasm/pseudo.c lwasm/section.c lwasm/struct.c lwlib/lw_expr.c lwlib/lw_stack.c lwlink/expr.c lwlink/link.c lwlink/main.c lwlink/map.c lwlink/objdump.c lwlink/readfiles.c lwlink/rules.make lwlink/script.c lwlink/util.c
diffstat 34 files changed, 117 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Wed Jan 19 22:31:00 2011 -0700
+++ b/Makefile	Thu Jan 20 22:39:46 2011 -0700
@@ -1,8 +1,8 @@
-CPPFLAGS += -I lwlib -DPACKAGE_STRING='"lwtools 4.0-pre"' -DPACKAGE_BUGREPORT='"lost@l-w.ca"'
+CPPFLAGS += -I lwlib -D_GNU_SOURCE -DPACKAGE_STRING='"lwtools 4.0-pre"' -DPACKAGE_BUGREPORT='"lost@l-w.ca"'
 
 LDFLAGS += -L$(PWD)/lwlib -llw
 
-MAIN_TARGETS := lwasm/lwasm lwlink/lwlink lwar/lwar
+MAIN_TARGETS := lwasm/lwasm lwlink/lwlink lwar/lwar lwlink/lwobjdump
 
 .PHONY: all
 all: $(MAIN_TARGETS)
@@ -15,6 +15,7 @@
 lwlink_objs := $(lwlink_srcs:.c=.o)
 lwar_objs := $(lwar_srcs:.c=.o)
 lwlib_objs := $(lwlib_srcs:.c=.o)
+lwobjdump_objs := $(lwobjdump_srcs:.c=.o)
 
 lwasm_deps := $(lwasm_srcs:.c=.d)
 lwlink_deps := $(lwlink_srcs:.c=.d)
@@ -65,4 +66,7 @@
 	rm -f lwlib/liblw.a lwasm/lwasm lwlink/lwlink lwlink/lwobjdump lwar/lwar
 	rm -f $(lwasm_objs) $(lwlink_objs) $(lwar_objs) $(lwlib_objs) $(lwobjdump_objs)
 	rm -f $(extra_clean)
+
+print-%:
+	@echo $* = $($*)
 	
\ No newline at end of file
--- a/lwar/add.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwar/add.c	Thu Jan 20 22:39:46 2011 -0700
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "lwar.h"
 
--- a/lwar/replace.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwar/replace.c	Thu Jan 20 22:39:46 2011 -0700
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "lwar.h"
 
--- a/lwar/util.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwar/util.c	Thu Jan 20 22:39:46 2011 -0700
@@ -52,7 +52,7 @@
 	if (size == 0)
 	{
 		lw_free(optr);
-		return;
+		return NULL;
 	}
 	
 	ptr = realloc(optr, size);
@@ -61,6 +61,7 @@
 		fprintf(stderr, "lw_realloc(): memory allocation error\n");
 		exit(1);
 	}
+	return ptr;
 }
 
 void lw_free(void *ptr)
--- a/lwasm/debug.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/debug.c	Thu Jan 20 22:39:46 2011 -0700
@@ -34,9 +34,9 @@
 void dump_state(asmstate_t *as)
 {
 	line_t *cl;
-	exportlist_t *ex;
-	struct symtabe *s;
-	importlist_t *im;
+//	exportlist_t *ex;
+//	struct symtabe *s;
+//	importlist_t *im;
 	struct line_expr_s *le;
 	lwasm_error_t *e;
 	
--- a/lwasm/input.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/input.c	Thu Jan 20 22:39:46 2011 -0700
@@ -32,6 +32,8 @@
 #include <lw_alloc.h>
 #include <lw_stringlist.h>
 #include <lw_string.h>
+#include <lw_error.h>
+
 #include "lwasm.h"
 
 /*
@@ -82,7 +84,7 @@
 	
 	/* also add it to the list of files included */
 	char *dn, *dp;
-	int o;
+//	int o;
 
 	dn = lw_strdup(fn);
 	lw_stack_push(as -> includelist, dn);
@@ -177,7 +179,7 @@
 		
 		/* relative path, check relative to "current file" directory */
 		p = lw_stack_top(as -> file_dir);
-		0 == asprintf(&p2, "%s/%s", p, s);
+		(void)(0 == asprintf(&p2, "%s/%s", p, s));
 		debug_message(as, 1, "Open: (cd) %s\n", p2);
 		IS -> data = fopen(p2, "rb");
 		if (IS -> data)
@@ -191,9 +193,9 @@
 
 		/* now check relative to entries in the search path */
 		lw_stringlist_reset(as -> include_list);
-		while (p = lw_stringlist_current(as -> include_list))
+		while ((p = lw_stringlist_current(as -> include_list)))
 		{
-			0 == asprintf(&p2, "%s/%s", p, s);
+			(void)(0 == asprintf(&p2, "%s/%s", p, s));
 		debug_message(as, 1, "Open (sp): %s\n", p2);
 			IS -> data = fopen(p2, "rb");
 			if (IS -> data)
@@ -226,7 +228,7 @@
 
 FILE *input_open_standalone(asmstate_t *as, char *s)
 {
-	char *s2;
+//	char *s2;
 	FILE *fp;
 	char *p, *p2;
 
@@ -245,7 +247,7 @@
 
 	/* relative path, check relative to "current file" directory */
 	p = lw_stack_top(as -> file_dir);
-	0 == asprintf(&p2, "%s/%s", p, s);
+	(void)(0 == asprintf(&p2, "%s/%s", p, s));
 	debug_message(as, 2, "Open file (st cd) %s", p2);
 	fp = fopen(p2, "rb");
 	if (fp)
@@ -257,9 +259,9 @@
 
 	/* now check relative to entries in the search path */
 	lw_stringlist_reset(as -> include_list);
-	while (p = lw_stringlist_current(as -> include_list))
+	while ((p = lw_stringlist_current(as -> include_list)))
 	{
-		0 == asprintf(&p2, "%s/%s", p, s);
+		(void)(0 == asprintf(&p2, "%s/%s", p, s));
 		debug_message(as, 2, "Open file (st ip) %s", p2);
 		fp = fopen(p2, "rb");
 		if (fp)
@@ -402,6 +404,7 @@
 	
 	default:
 		lw_error("Problem reading from unknown input type");
+		return NULL;
 	}
 }
 
--- a/lwasm/insn_bitbit.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/insn_bitbit.c	Thu Jan 20 22:39:46 2011 -0700
@@ -19,6 +19,7 @@
 */
 
 #include <stdlib.h>
+#include <ctype.h>
 
 #include <lw_expr.h>
 
@@ -30,8 +31,8 @@
 {
 	int r;
 	lw_expr_t e;
-	int v1;
-	int tv;
+//	int v1;
+//	int tv;
 
 	r = toupper(*(*p)++);
 	if (r == 'A')
--- a/lwasm/insn_gen.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/insn_gen.c	Thu Jan 20 22:39:46 2011 -0700
@@ -31,11 +31,14 @@
 extern void insn_indexed_resolve_aux(asmstate_t *as, line_t *l, int force, int elen);
 extern void insn_indexed_emit_aux(asmstate_t *as, line_t *l);
 
+extern void insn_parse_indexed_aux(asmstate_t *as, line_t *l, char **p);
+extern void insn_resolve_indexed_aux(asmstate_t *as, line_t *l, int force, int elen);
+
 // "extra" is required due to the way OIM, EIM, TIM, and AIM work
 void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p)
 {
 	const char *optr2;
-	int v1, tv, rval;
+	int v1, tv;
 	lw_expr_t s;
 
 	optr2 = *p;
--- a/lwasm/insn_indexed.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/insn_indexed.c	Thu Jan 20 22:39:46 2011 -0700
@@ -314,7 +314,7 @@
 {
 	// here, we have an expression which needs to be
 	// resolved; the post byte is determined here as well
-	lw_expr_t e, e2, e3;
+	lw_expr_t e, e2;
 	int pb = -1;
 	int v;
 	
@@ -414,7 +414,7 @@
 				}	
 				else
 				{
-					pb = (l -> pb & 0x03) << 5 | v & 0x1F;
+					pb = (l -> pb & 0x03) << 5 | (v & 0x1F);
 				}
 				l -> pb = pb;
 				return;
@@ -499,7 +499,7 @@
 			}
 			else
 			{
-				pb = (l -> pb & 0x03) << 5 | v & 0x1F;
+				pb = (l -> pb & 0x03) << 5 | (v & 0x1F);
 			}
 			l -> pb = pb;
 			return;
--- a/lwasm/insn_logicmem.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/insn_logicmem.c	Thu Jan 20 22:39:46 2011 -0700
@@ -36,7 +36,7 @@
 // for aim, oim, eim, tim
 PARSEFUNC(insn_parse_logicmem)
 {
-	const char *p2;
+//	const char *p2;
 	lw_expr_t s;
 	
 	if (**p == '#')
--- a/lwasm/insn_rel.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/insn_rel.c	Thu Jan 20 22:39:46 2011 -0700
@@ -31,9 +31,9 @@
 
 PARSEFUNC(insn_parse_rel8)
 {
-	int v;
+//	int v;
 	lw_expr_t t, e1, e2;
-	int r;
+//	int r;
 
 	// sometimes there is a "#", ignore if there
 	if (**p == '#')
@@ -80,9 +80,9 @@
 
 PARSEFUNC(insn_parse_rel16)
 {
-	int v;
+//	int v;
 	lw_expr_t t, e1, e2;
-	int r;
+//	int r;
 
 	// sometimes there is a "#", ignore if there
 	if (**p == '#')
@@ -107,7 +107,7 @@
 EMITFUNC(insn_emit_rel16)
 {
 	lw_expr_t e;
-	int offs;
+//	int offs;
 	
 	e = lwasm_fetch_expr(l, 0);
 	
--- a/lwasm/insn_rlist.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/insn_rlist.c	Thu Jan 20 22:39:46 2011 -0700
@@ -22,6 +22,8 @@
 for handling inherent mode instructions
 */
 
+#include <ctype.h>
+
 #include "lwasm.h"
 #include "instab.h"
 
--- a/lwasm/lwasm.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/lwasm.c	Thu Jan 20 22:39:46 2011 -0700
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
+#include <ctype.h>
 
 #include <lw_expr.h>
 #include <lw_alloc.h>
@@ -597,6 +598,7 @@
 int lwasm_reduce_expr(asmstate_t *as, lw_expr_t expr)
 {
 	lw_expr_simplify(expr, as);
+	return 0;
 }
 
 void lwasm_save_expr(line_t *cl, int id, lw_expr_t expr)
--- a/lwasm/lwasm.h	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/lwasm.h	Thu Jan 20 22:39:46 2011 -0700
@@ -304,12 +304,13 @@
 
 extern int lwasm_reduce_expr(asmstate_t *as, lw_expr_t expr);
 
+extern lw_expr_t lwasm_parse_cond(asmstate_t *as, char **p);
+
+#endif
+
 extern void debug_message(asmstate_t *as, int level, const char *fmt, ...);
 extern void dump_state(asmstate_t *as);
 
-extern lw_expr_t lwasm_parse_cond(asmstate_t *as, char **p);
-
-#endif
 
 #define OPLEN(op) (((op)>0xFF)?2:1)
 #define CURPRAGMA(l,p)	(((l)->pragmas & (p)) ? 1 : 0)
--- a/lwasm/macro.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/macro.c	Thu Jan 20 22:39:46 2011 -0700
@@ -135,7 +135,7 @@
 int expand_macro(asmstate_t *as, line_t *l, char **p, char *opc)
 {
 	int lc;
-	line_t *cl, *nl;
+	line_t *cl; //, *nl;
 	int oldcontext;
 	macrotab_t *m;
 
--- a/lwasm/main.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/main.c	Thu Jan 20 22:39:46 2011 -0700
@@ -22,6 +22,7 @@
 #include <argp.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <lw_alloc.h>
 #include <lw_string.h>
@@ -248,7 +249,7 @@
 		// output dependencies
 		char *n;
 		
-		while (n = lw_stack_pop(asmstate.includelist))
+		while ((n = lw_stack_pop(asmstate.includelist)))
 		{
 			fprintf(stdout, "%s\n", n);
 			lw_free(n);
--- a/lwasm/output.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/output.c	Thu Jan 20 22:39:46 2011 -0700
@@ -342,8 +342,8 @@
 				writebytes(se -> symbol, strlen(se -> symbol), 1, of);
 				if (se -> context != -1)
 				{
-					sprintf(buf, "\x01%d", se -> context);
-					writebytes(buf, strlen(buf), 1, of);
+					sprintf((char *)buf, "\x01%d", se -> context);
+					writebytes(buf, strlen((char *)buf), 1, of);
 				}
 				writebytes("", 1, 1, of);
 				return 0;
@@ -470,8 +470,8 @@
 			if (se -> context >= 0)
 			{
 				writebytes("\x01", 1, 1, of);
-				sprintf(buf, "%d", se -> context);
-				writebytes(buf, strlen(buf), 1, of);
+				sprintf((char *)buf, "%d", se -> context);
+				writebytes(buf, strlen((char *)buf), 1, of);
 			}
 			// the "" is NOT an error
 			writebytes("", 1, 1, of);
--- a/lwasm/pass1.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/pass1.c	Thu Jan 20 22:39:46 2011 -0700
@@ -21,6 +21,8 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
 
 #include <lw_alloc.h>
 #include <lw_string.h>
@@ -31,6 +33,7 @@
 
 extern int expand_macro(asmstate_t *as, line_t *l, char **p, char *opc);
 extern int expand_struct(asmstate_t *as, line_t *l, char **p, char *opc);
+extern int add_macro_line(asmstate_t *as, char *optr);
 
 /*
 pass 1: parse the lines
--- a/lwasm/pass5.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/pass5.c	Thu Jan 20 22:39:46 2011 -0700
@@ -63,11 +63,11 @@
 
 void do_pass5(asmstate_t *as)
 {
-	int rc;
+//	int rc;
 	int cnt;
 	int ocnt;
 	line_t *cl, *sl;
-	struct line_expr_s *le;
+//	struct line_expr_s *le;
 
 	// first, count the number of non-constant addresses; do
 	// a reduction first on each one
--- a/lwasm/pragma.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/pragma.c	Thu Jan 20 22:39:46 2011 -0700
@@ -19,7 +19,11 @@
 this program. If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include <string.h>
+#include <ctype.h>
+
 #include <lw_string.h>
+#include <lw_alloc.h>
 
 #include "lwasm.h"
 #include "instab.h"
--- a/lwasm/pseudo.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/pseudo.c	Thu Jan 20 22:39:46 2011 -0700
@@ -20,6 +20,9 @@
 */
 
 #include <stdio.h>
+#include <ctype.h>
+
+#include <lw_alloc.h>
 
 #include "lwasm.h"
 #include "instab.h"
@@ -101,7 +104,7 @@
 {
 	int i;
 	lw_expr_t e;
-	int v;
+//	int v;
 	
 	for (i = 0; i < l -> len; i++)
 	{
@@ -136,7 +139,7 @@
 {
 	int i;
 	lw_expr_t e;
-	int v;
+//	int v;
 	
 	for (i = 0; i < (l -> len)/2; i++)
 	{
@@ -171,7 +174,7 @@
 {
 	int i;
 	lw_expr_t e;
-	int v;
+//	int v;
 	
 	for (i = 0; i < (l -> len)/4; i++)
 	{
@@ -1056,7 +1059,7 @@
 	if (delim && **p)
 		(*p)++;
 	
-	0 == asprintf(&p3, "include:%s", fn);
+	(void)(0 == asprintf(&p3, "include:%s", fn));
 	input_open(as, p3);
 	lw_free(p3);
 
--- a/lwasm/section.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/section.c	Thu Jan 20 22:39:46 2011 -0700
@@ -20,6 +20,7 @@
 */
 
 #include <string.h>
+#include <ctype.h>
 
 #include <lw_string.h>
 #include <lw_alloc.h>
@@ -292,7 +293,7 @@
 {
 	int after = 0;
 	char *sym = NULL;
-	importlist_t *e;
+//	importlist_t *e;
 	
 	if (as -> output_format != OUTPUT_OBJ)
 	{
--- a/lwasm/struct.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwasm/struct.c	Thu Jan 20 22:39:46 2011 -0700
@@ -80,9 +80,9 @@
 	while (e)
 	{
 		if (e -> name)
-			0 == asprintf(&symname, "%s.%s", prefix, e -> name);
+			(void)(0 == asprintf(&symname, "%s.%s", prefix, e -> name));
 		else
-			0 == asprintf(&symname, "%s.____%d", prefix, *coff);
+			(void)(0 == asprintf(&symname, "%s.____%d", prefix, *coff));
 		
 		// register the symbol
 		te1 = lw_expr_build(lw_expr_type_int, *coff);
@@ -94,7 +94,7 @@
 		if (e -> substruct)
 		{
 			char *t;
-			0 == asprintf(&t, "sizeof{%s}", symname);
+			(void)(0 == asprintf(&t, "sizeof{%s}", symname));
 			te1 = lw_expr_build(lw_expr_type_int, e -> substruct -> size);
 			register_symbol(as, l, t, te1, symbol_flag_nocheck);
 			lw_expr_destroy(te1);
@@ -123,7 +123,7 @@
 		return;
 	}
 	
-	0 == asprintf(&t, "sizeof{%s}", as -> cstruct -> name);
+	(void)(0 == asprintf(&t, "sizeof{%s}", as -> cstruct -> name));
 	te = lw_expr_build(lw_expr_type_int, as -> cstruct -> size);
 	register_symbol(as, l, t, te, symbol_flag_nocheck);
 	lw_expr_destroy(te);
@@ -188,22 +188,22 @@
 	if (!(l -> sym))
 	{
 		lwasm_register_error(as, l, "Cannot declare a structure without a symbol name.");
-		return;
+		return -1;
 	}
 	
 	l -> len = s -> size;
 
 	if (as -> instruct)
-		0 == asprintf(&t, "sizeof(%s.%s}", as -> cstruct -> name, l -> sym);
+		(void)(0 == asprintf(&t, "sizeof(%s.%s}", as -> cstruct -> name, l -> sym));
 	else
-		0 == asprintf(&t, "sizeof{%s}", l -> sym);
+		(void)(0 == asprintf(&t, "sizeof{%s}", l -> sym));
 	te = lw_expr_build(lw_expr_type_int, s -> size);
 	register_symbol(as, l, t, te, symbol_flag_nocheck);
 	lw_expr_destroy(te);
 	lw_free(t);
 	
 	if (as -> instruct)
-		0 == asprintf(&t, "%s.%s", as -> cstruct -> name, l -> sym);
+		(void)(0 == asprintf(&t, "%s.%s", as -> cstruct -> name, l -> sym));
 	else
 		t = lw_strdup(l -> sym);
 	pseudo_endstruct_aux(as, l, s -> fields, t, &addr);
--- a/lwlib/lw_expr.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlib/lw_expr.c	Thu Jan 20 22:39:46 2011 -0700
@@ -22,6 +22,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 
 #define ___lw_expr_c_seen___
 #include "lw_alloc.h"
@@ -111,7 +112,7 @@
 void lw_expr_add_operand(lw_expr_t E, lw_expr_t O);
 lw_expr_t lw_expr_copy(lw_expr_t E)
 {
-	lw_expr_t r, t;
+	lw_expr_t r;
 	struct lw_expr_opers *o;
 	
 	r = lw_alloc(sizeof(struct lw_expr_priv));
@@ -610,14 +611,12 @@
 	// merge plus operations
 	if (E -> value == lw_expr_oper_plus)
 	{
-		lw_expr_t e2;
-
 	tryagainplus:
 		for (o = E -> operands; o; o = o -> next)
 		{
 			if (o -> p -> type == lw_expr_type_oper && o -> p -> value == lw_expr_oper_plus)
 			{
-				struct lw_expr_opers *o2, *o3;
+				struct lw_expr_opers *o2;
 				// we have a + operation - bring operands up
 				
 				for (o2 = E -> operands; o2 && o2 -> next != o; o2 = o2 -> next)
@@ -640,14 +639,12 @@
 	// merge times operations
 	if (E -> value == lw_expr_oper_times)
 	{
-		lw_expr_t e2;
-
 	tryagaintimes:
 		for (o = E -> operands; o; o = o -> next)
 		{
 			if (o -> p -> type == lw_expr_type_oper && o -> p -> value == lw_expr_oper_times)
 			{
-				struct lw_expr_opers *o2, *o3;
+				struct lw_expr_opers *o2;
 				// we have a + operation - bring operands up
 				
 				for (o2 = E -> operands; o2 && o2 -> next != o; o2 = o2 -> next)
--- a/lwlib/lw_stack.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlib/lw_stack.c	Thu Jan 20 22:39:46 2011 -0700
@@ -55,7 +55,7 @@
 {
 	void *d;
 	
-	while (d = lw_stack_pop(S))
+	while ((d = lw_stack_pop(S)))
 		(S->freefn)(d);
 	lw_free(S);
 }
--- a/lwlink/expr.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/expr.c	Thu Jan 20 22:39:46 2011 -0700
@@ -194,7 +194,7 @@
 */
 int lw_expr_reval(lw_expr_stack_t *s, lw_expr_stack_t *(*sfunc)(char *sym, int stype, void *state), void *state)
 {
-	lw_expr_stack_node_t *n, *n2;
+	lw_expr_stack_node_t *n;
 	lw_expr_stack_t *ss;
 	int c;
 	
--- a/lwlink/link.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/link.c	Thu Jan 20 22:39:46 2011 -0700
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "expr.h"
 #include "lwlink.h"
@@ -41,7 +42,7 @@
 
 	for (sn = 0; sn < fn -> nsections; sn++)
 	{
-		if (!strcmp(name, fn -> sections[sn].name))
+		if (!strcmp(name, (char *)(fn -> sections[sn].name)))
 		{
 			// we have a match
 			sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1));
@@ -73,14 +74,14 @@
 		if (noflags && (fn -> sections[sn].flags & noflags))
 			continue;
 		// ignore unless the yesflags tell us not to
-		if (yesflags && (fn -> sections[sn].flags & yesflags == 0))
+		if (yesflags && ((fn -> sections[sn].flags & yesflags) == 0))
 			continue;
 		// ignore it if already processed
 		if (fn -> sections[sn].processed)
 			continue;
 
 		// we have a match - now collect *all* sections of the same name!
-		add_matching_sections(fn -> sections[sn].name, 0, 0, base);
+		add_matching_sections((char *)(fn -> sections[sn].name), 0, 0, base);
 		
 		// and then continue looking for sections
 	}
@@ -154,16 +155,16 @@
 					if (linkscript.lines[ln].noflags && (inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].noflags))
 						continue;
 					// ignore unless the yes flags tell us not to
-					if (linkscript.lines[ln].yesflags && (inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].yesflags == 0))
+					if (linkscript.lines[ln].yesflags && ((inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].yesflags) == 0))
 						continue;
 					if (inputfiles[fn0] -> sections[sn0].processed == 0)
 					{
-						sname = inputfiles[fn0] -> sections[sn0].name;
+						sname = (char *)(inputfiles[fn0] -> sections[sn0].name);
 						for (fn = 0; fn < ninputfiles; fn++)
 						{
 							for (sn = 0; sn < inputfiles[fn] -> nsections; sn++)
 							{
-								if (!strcmp(sname, inputfiles[fn] -> sections[sn].name))
+								if (!strcmp(sname, (char *)(inputfiles[fn] -> sections[sn].name)))
 								{
 									// we have a match
 									sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1));
@@ -207,7 +208,7 @@
 	{
 		for (se = fn -> sections[sn].exportedsyms; se; se = se -> next)
 		{
-			if (!strcmp(sym, se -> sym))
+			if (!strcmp(sym, (char *)(se -> sym)))
 			{
 				if (!(fn -> forced))
 				{
@@ -264,7 +265,7 @@
 		// start with this section
 		for (se = sect -> localsyms; se; se = se -> next)
 		{
-			if (!strcmp(se -> sym, sym))
+			if (!strcmp((char *)(se -> sym), sym))
 			{
 				val = se -> offset + sect -> loadaddress;
 				goto out;
@@ -275,7 +276,7 @@
 		{
 			for (se = sect -> file -> sections[i].localsyms; se; se = se -> next)
 			{
-				if (!strcmp(se -> sym, sym))
+				if (!strcmp((char *)(se -> sym), sym))
 				{
 					val = se -> offset + sect -> file -> sections[i].loadaddress;
 					goto out;
--- a/lwlink/main.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/main.c	Thu Jan 20 22:39:46 2011 -0700
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
 
 #include "lwlink.h"
 
--- a/lwlink/map.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/map.c	Thu Jan 20 22:39:46 2011 -0700
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "lwlink.h"
 #include "util.h"
@@ -67,7 +68,7 @@
 	for (sn = 0; sn < nsects; sn++)
 	{
 		fprintf(of, "Section: %s (%s) load at %04X, length %04X\n",
-				sanitize_symbol(sectlist[sn].ptr -> name),
+				sanitize_symbol((char*)(sectlist[sn].ptr -> name)),
 				sectlist[sn].ptr -> file -> filename,
 				sectlist[sn].ptr -> loadaddress,
 				sectlist[sn].ptr -> codesize
@@ -81,7 +82,7 @@
 		{
 			for (pe = NULL, ce = slist; ce; ce = ce -> next)
 			{
-				i = strcmp(ce -> name, sym -> sym);
+				i = strcmp(ce -> name, (char *)(sym -> sym));
 				if (i == 0)
 				{
 					i = strcmp(ce -> fn, sectlist[sn].ptr -> file -> filename);
@@ -94,7 +95,7 @@
 			ne -> ext = 0;
 			ne -> addr = sym -> offset + sectlist[sn].ptr -> loadaddress;
 			ne -> next = ce;
-			ne -> name = sym -> sym;
+			ne -> name = (char *)(sym -> sym);
 			ne -> fn = sectlist[sn].ptr -> file -> filename;
 			if (pe)
 				pe -> next = ne;
--- a/lwlink/objdump.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/objdump.c	Thu Jan 20 22:39:46 2011 -0700
@@ -23,6 +23,7 @@
 */
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "util.h"
 
@@ -76,7 +77,6 @@
 */
 int main(int argc, char **argv)
 {
-	int i;
 	long size;
 	FILE *f;
 	long bread;
@@ -220,7 +220,7 @@
 			NEXTBYTE();
 			// val is now the symbol value
 			
-			printf("        %s=%04X\n", string_cleanup(fp), val);
+			printf("        %s=%04X\n", string_cleanup((char *)fp), val);
 			
 		}
 		// skip terminating NUL
@@ -240,7 +240,7 @@
 			NEXTBYTE();
 			// val is now the symbol value
 			
-			printf("        %s=%04X\n", string_cleanup(fp), val);
+			printf("        %s=%04X\n", string_cleanup((char *)fp), val);
 		}
 		// skip terminating NUL
 		NEXTBYTE();
@@ -272,12 +272,12 @@
 				
 				case 0x02:
 					// external symbol reference
-					printf(" ES=%s", string_cleanup(CURSTR()));
+					printf(" ES=%s", string_cleanup((char *)CURSTR()));
 					break;
 					
 				case 0x03:
 					// internal symbol reference
-					printf(" IS=%s", string_cleanup(CURSTR()));
+					printf(" IS=%s", string_cleanup((char *)CURSTR()));
 					break;
 				
 				case 0x04:
--- a/lwlink/readfiles.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/readfiles.c	Thu Jan 20 22:39:46 2011 -0700
@@ -294,12 +294,12 @@
 				
 				case 0x02:
 					// external symbol reference
-					term = lw_expr_term_create_sym(CURSTR(), 0);
+					term = lw_expr_term_create_sym((char *)CURSTR(), 0);
 					break;
 					
 				case 0x03:
 					// internal symbol reference
-					term = lw_expr_term_create_sym(CURSTR(), 1);
+					term = lw_expr_term_create_sym((char *)CURSTR(), 1);
 					break;
 				
 				case 0x04:
@@ -413,7 +413,7 @@
 		memset(fn -> subs[fn -> nsubs], 0, sizeof(fileinfo_t));
 		fn -> subs[fn -> nsubs] -> filedata = fn -> filedata + cc;
 		fn -> subs[fn -> nsubs] -> filesize = flen;
-		fn -> subs[fn -> nsubs] -> filename = lw_strdup(fn -> filedata + l);
+		fn -> subs[fn -> nsubs] -> filename = lw_strdup((char *)(fn -> filedata + l));
 		fn -> subs[fn -> nsubs] -> parent = fn;
 		fn -> subs[fn -> nsubs] -> forced = fn -> forced;		
 		read_file(fn -> subs[fn -> nsubs]);
--- a/lwlink/rules.make	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/rules.make	Thu Jan 20 22:39:46 2011 -0700
@@ -1,8 +1,10 @@
 dirname := $(dir $(lastword $(MAKEFILE_LIST)))
 
 lwlink_srcs_local := main.c lwlink.c util.c readfiles.c expr.c script.c link.c output.c map.c
-lwobjdump_srcs_local := objdump.c util.c
+
+lwobjdump_srcs_l := objdump.c util.c
 
 
 lwlink_srcs := $(lwlink_srcs) $(addprefix $(dirname),$(lwlink_srcs_local))
-lwobjdump_srcs := $(lwobjdump_srcs) $(addprefix $(dirname),$(lwobjdump_srcs_local))
+
+lwobjdump_srcs := $(lwobjdump_srcs) $(addprefix $(dirname),$(lwobjdump_srcs_l))
--- a/lwlink/script.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/script.c	Thu Jan 20 22:39:46 2011 -0700
@@ -21,6 +21,7 @@
 Read and parse linker scripts
 */
 
+#include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
--- a/lwlink/util.c	Wed Jan 19 22:31:00 2011 -0700
+++ b/lwlink/util.c	Thu Jan 20 22:39:46 2011 -0700
@@ -51,7 +51,7 @@
 	if (size == 0)
 	{
 		lw_free(optr);
-		return;
+		return NULL;
 	}
 	
 	ptr = realloc(optr, size);
@@ -60,6 +60,7 @@
 		fprintf(stderr, "lw_realloc(): memory allocation error\n");
 		exit(1);
 	}
+	return ptr;
 }
 
 void lw_free(void *ptr)