Mercurial > hg > index.cgi
changeset 264:346966cffeef
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.
author | William Astle <lost@l-w.ca> |
---|---|
date | Wed, 06 Feb 2013 21:43:10 -0700 |
parents | 8dd8c3bdca7c |
children | 6f4c4d59666f |
files | lwar/add.c lwar/extract.c lwar/list.c lwar/replace.c lwasm/pseudo.c lwlib/lw_expr.c lwlink/link.c lwlink/objdump.c lwlink/output.c |
diffstat | 9 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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...
--- 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);
--- 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);
--- 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...
--- 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);
--- 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) {
--- 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");
--- 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:
--- 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);