diff --git a/src/dj.c b/src/dj.c index 8dc066a..1d12844 100644 --- a/src/dj.c +++ b/src/dj.c @@ -99,7 +99,7 @@ Io_write(struct Io *io) { io->error = errno; t = 0; } else if (t > 0) { - memmove(io->buf, &(io->buf)[t], (io->bufuse -= t)); + (void)memmove(io->buf, &(io->buf)[t], (io->bufuse -= t)); } io->bytes += t; @@ -111,7 +111,8 @@ Io_write(struct Io *io) { static int oserr(char *e, int n) { - fprintf(stderr, "%s: %s: %s\n", program_name, e, strerror(n)); + (void)fprintf(stderr, "%s: %s: %s\n", program_name, e, strerror(n)); + return EX_OSERR; } @@ -119,7 +120,7 @@ oserr(char *e, int n) { * completely read and written records. */ static void fprintio(FILE *stream, char *fmt, struct Io io[2]) { - fprintf( + return fprintf( stream, fmt, io[0].rec, @@ -129,8 +130,6 @@ fprintio(FILE *stream, char *fmt, struct Io io[2]) { io[0].bytes, io[1].bytes ); - - return; } /* Parses the string s to an integer, returning either the integer or in the @@ -248,7 +247,7 @@ int main(int argc, char *argv[]) { for (i = 0; i < (sizeof io) / (sizeof *io); ++i) { /* buffer allocation */ if ((io[i].buf = malloc(io[i].bs * (sizeof *(io[i].buf)))) == NULL) { - fprintf( + (void)fprintf( stderr, "%s: Failed to allocate %zd bytes\n", program_name, io[i].bs ); @@ -265,13 +264,13 @@ int main(int argc, char *argv[]) { /* hard seeking; t is io[1].bufuse, before Io_write subtracts from it */ for(size_t t; io[1].seek > 0; io[1].seek -= (t - io[1].bufuse)) { - memset( + (void)memset( io[1].buf, '\0', /* set buf to all nulls */ (t = io[1].bufuse = MIN(io[1].bs, io[1].seek)) /* saturate block */ ); if (Io_write(&io[1])->bufuse == t && !noerror && io[1].error == 0) { - Io_write(&io[1]); /* second chance */ + (void)Io_write(&io[1]); /* second chance */ } if (io[1].error != 0) { return oserr(io[1].fn, io[1].error); } @@ -282,7 +281,7 @@ int main(int argc, char *argv[]) { io[1].bufuse = 0; if (io[1].seek > 0) { /* hard seeking failed */ - fprintio(stderr, fmt, io); + (void)fprintio(stderr, fmt, io); return oserr(io[1].fn, errno); } @@ -303,7 +302,7 @@ int main(int argc, char *argv[]) { t = io[0].bufuse; if (Io_read(&io[0])->bufuse == t && !noerror && io[0].error == 0) { - Io_read(&io[0]); /* second chance */ + (void)Io_read(&io[0]); /* second chance */ } assert(io[0].bufuse >= t); @@ -311,14 +310,14 @@ int main(int argc, char *argv[]) { if (io[0].bufuse == t) { break; } /* that's all she wrote */ if (/* t < io[0].bufuse && */ io[0].bufuse < io[0].bs) { - fprintf(stderr, "%s: Partial read:\n\t", program_name); - fprintio(stderr, fmt, io); + (void)fprintf(stderr, "%s: Partial read:\n\t", program_name); + (void)fprintio(stderr, fmt, io); if (!noerror) { count = 1; } if (align >= 0) { /* fill the rest of the ibuf with padding */ - memset( + (void)memset( &(io[0].buf)[io[0].bufuse], align, io[0].bs - io[0].bufuse @@ -342,25 +341,25 @@ int main(int argc, char *argv[]) { if (io[0].bs <= io[1].bs) { int n; - memcpy( /* saturate obuf */ + (void)memcpy( /* saturate obuf */ io[1].buf, io[0].buf, (io[1].bufuse = (n = MIN(io[0].bufuse, io[1].bs))) ); /* permute the copied units out of ibuf */ - memmove(io[0].buf, &(io[0].buf)[n], (io[0].bufuse -= n)); + (void)memmove(io[0].buf, &(io[0].buf)[n], (io[0].bufuse -= n)); } else /* if(io[0].bs > io[1].bs) */ { int n; /* drain what we can from ibuf */ - memcpy( + (void)memcpy( &(io[1].buf)[io[1].bufuse], io[0].buf, (n = MIN(io[0].bufuse, io[1].bs - io[1].bufuse)) ); io[1].bufuse += n; /* permute out the copied units */ - memmove(io[0].buf, &(io[0].buf)[n], io[0].bs - n); + (void)memmove(io[0].buf, &(io[0].buf)[n], io[0].bs - n); io[0].bufuse -= n; if(io[0].bs + io[1].bufuse <= io[1].bs && count != 1) { @@ -375,7 +374,7 @@ int main(int argc, char *argv[]) { if (Io_write(&io[1])->bufuse == t && !noerror && io[1].error == 0) { - Io_write(&io[1]); /* second chance */ + (void)Io_write(&io[1]); /* second chance */ } assert(io[1].error == 0 || io[1].bufuse == t); @@ -392,15 +391,15 @@ int main(int argc, char *argv[]) { } if (0 < io[1].bufuse /* && io[1].bufuse < t */) { - fprintf(stderr, "%s: Partial write:\n\t", program_name); - fprintio(stderr, fmt, io); + (void)fprintf(stderr, "%s: Partial write:\n\t", program_name); + (void)fprintio(stderr, fmt, io); if(!noerror) { count = 1; } } } } - fprintio(stderr, fmt, io); + (void)fprintio(stderr, fmt, io); for (i = 0; i < (sizeof io) / (sizeof *io); ++i) { if (io[i].error) { return oserr(io[i].fn, io[i].error); }