From: Randy Dunlap <randy.dunlap@xxxxxxxxxx> Fix strict gcc warnings that come from using: ("-Wall -Wp,-D_FORTIFY_SOURCE=2") script.c:239: warning: ignoring return value of 'write', declared with attribute warn_unused_result script.c:330: warning: ignoring return value of 'write', declared with attribute warn_unused_result script.c:331: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result Signed-off-by: Randy Dunlap <randy.dunlap@xxxxxxxxxx> --- misc-utils/script.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) --- util-linux-ng-2.13.orig/misc-utils/script.c +++ util-linux-ng-2.13/misc-utils/script.c @@ -229,14 +229,22 @@ void doinput() { register int cc; char ibuf[BUFSIZ]; + int wcount; (void) fclose(fscript); if (die == 0 && child && kill(child, 0) == -1 && errno == ESRCH) die = 1; - while (die == 0 && (cc = read(0, ibuf, BUFSIZ)) > 0) - (void) write(master, ibuf, cc); + while (die == 0 && (cc = read(0, ibuf, BUFSIZ)) > 0) { + wcount = write(master, ibuf, cc); + if (wcount == -1) { // no check for short write + int err = errno; + fprintf (stderr, _("%s: write error %d: %s\n"), + progname, err, strerror(err)); + fail(); + } + } done(); } @@ -279,6 +287,8 @@ dooutput() { struct timeval tv; double oldtime=time(NULL), newtime; int flgs = 0; + ssize_t wrt; + size_t fwrt; (void) close(0); #ifdef HAVE_LIBUTIL @@ -327,8 +337,20 @@ dooutput() { fprintf(stderr, "%f %i\n", newtime - oldtime, cc); oldtime = newtime; } - (void) write(1, obuf, cc); - (void) fwrite(obuf, 1, cc, fscript); + wrt = write(1, obuf, cc); + if (wrt < 0) { + int err = errno; + fprintf (stderr, _("%s: write error %d: %s\n"), + progname, err, strerror(err)); + fail(); + } + fwrt = fwrite(obuf, 1, cc, fscript); + if (fwrt < cc) { + int err = errno; + fprintf (stderr, _("%s: cannot write script file, error %d: %s\n"), + progname, err, strerror(err)); + fail(); + } if (fflg) (void) fflush(fscript); } while(1); - To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html