Mercurial > hg-old > index.cgi
changeset 48:6de358e7903f
Cleaned up warnings about the return value of fwrite() being ignored (it still is but now there's no warning)
author | lost |
---|---|
date | Sun, 04 Jan 2009 07:31:20 +0000 |
parents | 804d7465e0f9 |
children | 21ae0fab469b |
files | src/output.c |
diffstat | 1 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/output.c Sun Jan 04 07:25:03 2009 +0000 +++ b/src/output.c Sun Jan 04 07:31:20 2009 +0000 @@ -35,6 +35,9 @@ void write_code_decb(asmstate_t *as, FILE *of); void write_code_rawrel(asmstate_t *as, FILE *of); +// this prevents warnings about not using the return value of fwrite() +#define writebytes(s, l, c, f) do { int r; r = fwrite((s), (l), (c), (f)); } while (0) + void lwasm_output(asmstate_t *as) { FILE *of; @@ -96,7 +99,7 @@ continue; fseek(of, cl -> codeaddr, SEEK_SET); - fwrite(cl -> bytes, cl -> codelen, 1, of); + writebytes(cl -> bytes, cl -> codelen, 1, of); } } @@ -115,10 +118,10 @@ { int i; for (i = 0; i < cl -> nocodelen; i++) - fwrite("\0", 1, 1, of); + writebytes("\0", 1, 1, of); continue; } - fwrite(cl -> bytes, cl -> codelen, 1, of); + writebytes(cl -> bytes, cl -> codelen, 1, of); } } @@ -143,7 +146,7 @@ fseek(of, preambloc, SEEK_SET); outbuf[0] = (blocklen >> 8) & 0xFF; outbuf[1] = blocklen & 0xFF; - fwrite(outbuf, 2, 1, of); + writebytes(outbuf, 2, 1, of); fseek(of, 0, SEEK_END); } blocklen = 0; @@ -154,10 +157,10 @@ outbuf[3] = (nextcalc >> 8) & 0xFF; outbuf[4] = nextcalc & 0xFF; preambloc = ftell(of) + 1; - fwrite(outbuf, 5, 1, of); + writebytes(outbuf, 5, 1, of); } nextcalc += cl -> codelen; - fwrite(cl -> bytes, cl -> codelen, 1, of); + writebytes(cl -> bytes, cl -> codelen, 1, of); blocklen += cl -> codelen; } if (blocklen > 0) @@ -165,7 +168,7 @@ fseek(of, preambloc, SEEK_SET); outbuf[0] = (blocklen >> 8) & 0xFF; outbuf[1] = blocklen & 0xFF; - fwrite(outbuf, 2, 1, of); + writebytes(outbuf, 2, 1, of); fseek(of, 0, SEEK_END); } @@ -175,5 +178,5 @@ outbuf[2] = 0x00; outbuf[3] = (as -> execaddr >> 8) & 0xFF; outbuf[4] = (as -> execaddr) & 0xFF; - fwrite(outbuf, 5, 1, of); + writebytes(outbuf, 5, 1, of); }