diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2013-12-22 10:21:33 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-12-22 10:21:33 +0100 |
commit | fe9428e7a58de96b4f26bff3926c4e478d1b5c5b (patch) | |
tree | a2b4ee35665266e8d0379952440cfe442f117636 | |
parent | 569af3d77cd858150707c24e1bce75792285b9f3 (diff) | |
download | dev86-lr-checks.tar.gz |
as: Deal with compiler warningslr-checks
-rw-r--r-- | as/Makefile | 2 | ||||
-rw-r--r-- | as/as.c | 7 | ||||
-rw-r--r-- | as/genlist.c | 28 | ||||
-rw-r--r-- | as/genobj.c | 14 | ||||
-rw-r--r-- | as/gensym.c | 4 | ||||
-rw-r--r-- | as/proto.h | 1 | ||||
-rw-r--r-- | as/typeconv.c | 19 |
7 files changed, 59 insertions, 16 deletions
diff --git a/as/Makefile b/as/Makefile index 60aa952..b1d4363 100644 --- a/as/Makefile +++ b/as/Makefile @@ -1,5 +1,5 @@ -CFLAGS=-O +CFLAGS=-O -Wall LDFLAGS=-s LIBDIR=/usr/bin BINDIR=/usr/bin @@ -65,9 +65,10 @@ char **argv; PUBLIC void as_abort(message) char *message; { - write(STDOUT, "as: ", 4); - write(STDOUT, message, strlen(message)); - write(STDOUT, "\n", 1); + outfd = STDOUT; + writebuf("as: ", 4); + writebuf(message, strlen(message)); + writebuf("\n", 1); exit(1); } diff --git a/as/genlist.c b/as/genlist.c index edeefff..19ede58 100644 --- a/as/genlist.c +++ b/as/genlist.c @@ -194,7 +194,7 @@ fd_t fd; { outfd = fd; listcode(); - write(outfd, linebuf, (unsigned) (lineptr - linebuf)); + writebuf(linebuf, (unsigned) (lineptr - linebuf)); writenl(); if (errcount != 0) listerrors(); @@ -424,12 +424,30 @@ unsigned nspaces; writec(' '); /* spaces out to error position */ } +/* write buffer with length */ + +PUBLIC void writebuf(s, len) +char *s; +int len; +{ + while (len) { + int nw; + nw = write(outfd, s, len); + if (nw > 0) { + len -= nw; + s += nw; + } else { + as_abort("write error"); + } + } +} + /* write 1 character */ PUBLIC void writec(ch) char ch; { - write(outfd, &ch, 1); + writebuf(&ch, 1); } /* write newline */ @@ -451,7 +469,7 @@ offset_t offset; #else u2c2(buf, offset); #endif - write(outfd, buf, sizeof buf); + writebuf(buf, sizeof buf); } /* write string */ @@ -459,7 +477,7 @@ offset_t offset; PUBLIC void writes(s) char *s; { - write(outfd, s, strlen(s)); + writebuf(s, strlen(s)); } /* write string followed by newline */ @@ -479,5 +497,5 @@ unsigned word; char buf[2]; u2c2(buf, (u16_T) word); - write(outfd, buf, sizeof buf); + writebuf(buf, sizeof buf); } diff --git a/as/genobj.c b/as/genobj.c index 67eb88e..45612cb 100644 --- a/as/genobj.c +++ b/as/genobj.c @@ -72,16 +72,22 @@ PUBLIC void flushobj() { int ntowrite; - if ((ntowrite = objbufptr - objbuf) > 0) + ntowrite = objbufptr - objbuf; + while (ntowrite > 0) { - if (write(objfil, objbuf, (unsigned) ntowrite) != ntowrite) + int nwritten; + + nwritten = write(objfil, objbufptr - ntowrite, (unsigned) ntowrite); + if (nwritten < 1) { error(OBJOUT); listline(); finishup(); - } - objbufptr = objbuf; + } else { + ntowrite -= nwritten; + } } + objbufptr = objbuf; } /* flush RMB count if necessary */ diff --git a/as/gensym.c b/as/gensym.c index 646c5cd..6bf1bfa 100644 --- a/as/gensym.c +++ b/as/gensym.c @@ -92,7 +92,7 @@ PUBLIC void gensym() writec(symptr->type & COMMBIT ? 'C' : '-'); writec(' '); - write(outfd, symptr->name, (unsigned) (symptr->length)); + writebuf(symptr->name, (unsigned) (symptr->length)); /* printsym(*copyptr++, 0); */ writenl(); @@ -121,7 +121,7 @@ PUBLIC void gensym() symptr = *copyptr++; writew((unsigned) symptr->value_reg_or_op.value); writec(symptr->type); - write(outfd, symptr->name, (unsigned) (symptr->length - 1)); + writebuf(symptr->name, (unsigned) (symptr->length - 1)); writec(symptr->name[symptr->length - 1] | 0x80); } sort(symlptr, copyptr, FALSE); @@ -34,6 +34,7 @@ char *build_number P((unsigned num, unsigned width, char *where)); void warning P((char * errorstr)); void error P((char * errorstr)); void listline P((void)); +void writebuf P((char *s, int len)); void writec P((int ch)); void writenl P((void)); void writeoff P((offset_t offset)); diff --git a/as/typeconv.c b/as/typeconv.c index 580f759..f700681 100644 --- a/as/typeconv.c +++ b/as/typeconv.c @@ -11,7 +11,24 @@ #include "globvar.h" void xxerr P((char *)); -void xxerr(x) char * x; { write(2, x, strlen(x)); } +void xxerr(x) +char * x; +{ + int len; + + len = strlen(x); + while (len) { + int nw; + + nw = write(2, x, strlen(x)); + if (nw > 0) { + len -= nw; + x += nw; + } else { + exit(1); + } + } +} #ifdef __AS386_16__ static int no_swap = 1; |