diff options
author | Randy Dunlap <randy.dunlap@oracle.com> | 2007-10-15 17:38:40 -0700 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2007-11-05 14:15:26 +0100 |
commit | 36c1d79b570699f99b7d778db421a303772438ba (patch) | |
tree | 56738d7e094e9d36883808a5e06a221c63e065f1 /misc-utils | |
parent | 0fa7180bcd256667ff5b45c681c2694400999111 (diff) | |
download | util-linux-old-36c1d79b570699f99b7d778db421a303772438ba.tar.gz |
script: cleanup gcc warnings
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@oracle.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/script.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/misc-utils/script.c b/misc-utils/script.c index 3b957d8d..6a0fc810 100644 --- a/misc-utils/script.c +++ b/misc-utils/script.c @@ -141,7 +141,7 @@ main(int argc, char **argv) { setlocale(LC_NUMERIC, "C"); /* see comment above */ bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - + if (argc == 2) { if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) { printf(_("%s (%s)\n"), @@ -237,8 +237,15 @@ doinput() { die = 1; while (die == 0) { - if ((cc = read(0, ibuf, BUFSIZ)) > 0) - (void) write(master, ibuf, cc); + if ((cc = read(0, ibuf, BUFSIZ)) > 0) { + ssize_t wrt = write(master, ibuf, cc); + if (wrt == -1) { + int err = errno; + fprintf (stderr, _("%s: write error %d: %s\n"), + progname, err, strerror(err)); + fail(); + } + } else if (cc == -1 && errno == EINTR && resized) resized = 0; else @@ -285,6 +292,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 @@ -333,8 +342,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: %s\n"), + progname, strerror(err)); + fail(); + } + fwrt = fwrite(obuf, 1, cc, fscript); + if (fwrt < cc) { + int err = errno; + fprintf (stderr, _("%s: cannot write script file, error: %s\n"), + progname, strerror(err)); + fail(); + } if (fflg) (void) fflush(fscript); } while(1); |