summaryrefslogtreecommitdiffstats
path: root/misc-utils/script.c
diff options
context:
space:
mode:
authorRandy Dunlap2007-10-16 02:38:40 +0200
committerKarel Zak2007-11-05 14:15:26 +0100
commit36c1d79b570699f99b7d778db421a303772438ba (patch)
tree56738d7e094e9d36883808a5e06a221c63e065f1 /misc-utils/script.c
parentmore: cleanup gcc warnings (diff)
downloadkernel-qcow2-util-linux-36c1d79b570699f99b7d778db421a303772438ba.tar.gz
kernel-qcow2-util-linux-36c1d79b570699f99b7d778db421a303772438ba.tar.xz
kernel-qcow2-util-linux-36c1d79b570699f99b7d778db421a303772438ba.zip
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/script.c')
-rw-r--r--misc-utils/script.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/misc-utils/script.c b/misc-utils/script.c
index 3b957d8d7..6a0fc8103 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);