# HG changeset patch # User William Astle # Date 1360212190 25200 # Node ID 346966cffeef960b5412155a7dc16f91c18cf655 # Parent 8dd8c3bdca7c5dd186c8f08197062e5c28650c65 Clean up various warnings when building under -Wall Add some gimmicks to prevent fread() and fwrite() warnings about ignoring the return value. Yes, this is probably not a good thing to do, but doing something with a non-success return value is going to involve crashing out or something anyway. Also fix several warnings about variables used while possibly uninitialized. The code flow shows that this cannot be the case but initializing them to a plausible value at declaration time costs pretty much nothing and it makes gcc happy. Also caught a use of | instead of || which probably would have caused a certain check for duplicate declarations in __os9 sections to behave oddly. diff -r 8dd8c3bdca7c -r 346966cffeef lwar/add.c --- a/lwar/add.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwar/add.c Wed Feb 06 21:43:10 2013 -0700 @@ -53,7 +53,7 @@ perror("Cannot open archive file"); } - fread(buf, 1, 6, f); + (void)(fread(buf, 1, 6, f) && 1); if (memcmp("LWAR1V", buf, 6)) { fprintf(stderr, "%s is not a valid archive file.\n", archive_file); @@ -113,7 +113,7 @@ perror(""); exit(1); } - fread(buf, 1, 6, f2); + (void)(fread(buf, 1, 6, f2) && 1); if (mergeflag && !memcmp("LWAR1V", buf, 6)) { // add archive contents... diff -r 8dd8c3bdca7c -r 346966cffeef lwar/extract.c --- a/lwar/extract.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwar/extract.c Wed Feb 06 21:43:10 2013 -0700 @@ -43,7 +43,7 @@ exit(1); } - fread(buf, 1, 6, f); + (void)(fread(buf, 1, 6, f) && 1); if (memcmp("LWAR1V", buf, 6)) { fprintf(stderr, "%s is not a valid archive file.\n", archive_file); diff -r 8dd8c3bdca7c -r 346966cffeef lwar/list.c --- a/lwar/list.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwar/list.c Wed Feb 06 21:43:10 2013 -0700 @@ -43,7 +43,7 @@ exit(1); } - fread(buf, 1, 6, f); + (void)(fread(buf, 1, 6, f) && 1); if (memcmp("LWAR1V", buf, 6)) { fprintf(stderr, "%s is not a valid archive file.\n", archive_file); diff -r 8dd8c3bdca7c -r 346966cffeef lwar/replace.c --- a/lwar/replace.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwar/replace.c Wed Feb 06 21:43:10 2013 -0700 @@ -56,7 +56,7 @@ perror("Cannot open archive file"); } - fread(buf, 1, 6, f); + (void)(fread(buf, 1, 6, f) && 1); if (memcmp("LWAR1V", buf, 6)) { fprintf(stderr, "%s is not a valid archive file.\n", archive_file); @@ -153,7 +153,7 @@ perror(""); exit(1); } - fread(buf, 1, 6, f2); + (void)(fread(buf, 1, 6, f2) && 1); if (mergeflag && !memcmp("LWAR1V", buf, 6)) { // add archive contents... diff -r 8dd8c3bdca7c -r 346966cffeef lwasm/pseudo.c --- a/lwasm/pseudo.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwasm/pseudo.c Wed Feb 06 21:43:10 2013 -0700 @@ -1475,7 +1475,7 @@ RESOLVEFUNC(pseudo_resolve_align) { lw_expr_t e; - int align; + int align = 1; e = lwasm_fetch_expr(l, 0); @@ -1552,7 +1552,7 @@ RESOLVEFUNC(pseudo_resolve_fill) { lw_expr_t e; - int align; + int align = 1; e = lwasm_fetch_expr(l, 0); diff -r 8dd8c3bdca7c -r 346966cffeef lwlib/lw_expr.c --- a/lwlib/lw_expr.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwlib/lw_expr.c Wed Feb 06 21:43:10 2013 -0700 @@ -955,7 +955,7 @@ } if (c == 1) { - lw_expr_t r; + lw_expr_t r = NULL; // find the value and "move it up" while (E -> operands) { diff -r 8dd8c3bdca7c -r 346966cffeef lwlink/link.c --- a/lwlink/link.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwlink/link.c Wed Feb 06 21:43:10 2013 -0700 @@ -570,7 +570,7 @@ reloc_t *rl; lw_expr_stack_t *te; - int rval; +// int rval; if (fn -> forced == 0) @@ -582,7 +582,7 @@ { // do a "simplify" on the expression te = lw_expr_stack_dup(rl -> expr); - rval = lw_expr_reval(te, resolve_sym, &(fn -> sections[sn])); + lw_expr_reval(te, resolve_sym, &(fn -> sections[sn])); // is it constant? error out if not // incompletes will error out during resolve_references() @@ -808,7 +808,7 @@ if (st.attrseen > 1 || st.typeseen > 1 || st.langseen > 1 || st.revseen > 1 || - st.nameseen > 1 | st.edseen > 1 + st.nameseen > 1 || st.edseen > 1 ) { fprintf(stderr, "Warning: multiple instances of __os9 found with duplicate settings of type, lang, attr, rev, edition, or module name.\n"); diff -r 8dd8c3bdca7c -r 346966cffeef lwlink/objdump.c --- a/lwlink/objdump.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwlink/objdump.c Wed Feb 06 21:43:10 2013 -0700 @@ -154,7 +154,7 @@ long cc; int val; int bss; - int constant; +// int constant; static char *opernames[] = { "?", @@ -180,7 +180,7 @@ while (1) { bss = 0; - constant = 0; +// constant = 0; // bail out if no more sections if (!(CURBYTE())) @@ -201,7 +201,7 @@ break; case 0x02: printf(" FLAG: CONSTANT\n"); - constant = 1; +// constant = 1; break; default: diff -r 8dd8c3bdca7c -r 346966cffeef lwlink/output.c --- a/lwlink/output.c Tue Feb 05 22:39:34 2013 -0700 +++ b/lwlink/output.c Wed Feb 06 21:43:10 2013 -0700 @@ -30,7 +30,8 @@ // this prevents warnings about not using the return value of fwrite() // and, theoretically, can be replaced with a function that handles things // better in the future -#define writebytes(s, l, c, f) do { int r; r = fwrite((s), (l), (c), (f)); } while (0) +//#define writebytes(s, l, c, f) do { int r; r = fwrite((s), (l), (c), (f)); (void)r; } while (0) +#define writebytes(s, l, c, f) do { (void)(fwrite((s), (l), (c), (f)) && 1); } while (0) void do_output_os9(FILE *of); void do_output_decb(FILE *of);