]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Ignore return values harder
authorJeffrey Hutzelman <jhutz@cmu.edu>
Sun, 16 Jun 2013 20:28:22 +0000 (16:28 -0400)
committerStephan Wiesand <stephan.wiesand@desy.de>
Wed, 7 Oct 2015 10:11:49 +0000 (06:11 -0400)
In various places where we intentionally ignore the return values of system
calls and standard library routines, this changes the way in which we do so,
to avoid compiler warnings when building on Ubuntu 12.10, with gcc 4.7.2 and
eglibc 2.15-0ubuntu20.1.

Reviewed-on: http://gerrit.openafs.org/9980
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 73cad3be0a3489237ab7e66d3b12c52ffb0b67d0)

Change-Id: I934406d67d7409655a7084894fd231c410d72c58
Reviewed-on: http://gerrit.openafs.org/11715
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Daria Phoebe Brashear <shadow@your-file-system.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/aklog/aklog.c
src/butm/file_tm.c
src/rx/rx_trace.c
src/util/serverLog.c
src/viced/viced.c
src/vol/vol-salvage.c
src/volser/vsprocs.c

index b191249317ef775c8c14abefb41bfcd8ecf691d6..5aab5226e518fcc15db9185bc2d7f80c5428d7dc 100644 (file)
@@ -1104,8 +1104,11 @@ auth_to_cell(krb5_context context, char *cell, char *realm, char **linkedcell)
         * this routine, it will not add the token. It is not clear what
         * is going on here! So we will do the following operation.
         * On AIX 5, it causes the parent program to die, so we won't.
+        * We don't care about the return value, but need to collect it
+        * to avoid compiler warnings.
         */
-       write(2,"",0); /* dummy write */
+       if (write(2,"",0) < 0) /* dummy write */
+           ; /* don't care */
 #endif
        status = set_kernel_token(&cellconf, username, token, afssetpag);
        if (status) {
index d70751075084778b0b4ee1322ad8fafb13c9ee51..b637f99831cbccf7e12c08db0dc7468c6ac9e4be 100644 (file)
@@ -211,8 +211,13 @@ ForkIoctl(usd_handle_t fd, int op, int count)
        /* do the ioctl call */
        ioctl_rc = USD_IOCTL(fd, USD_IOCTL_TAPEOPERATION, (void *)&tapeop);
 
-       /* send the return code back to the parent */
-       write(pipefd[1], &ioctl_rc, sizeof(int));
+       /*
+        * Send the return code back to the parent.
+        * If this fails, there's nothing we can do, but we must test
+        * it in order to avoid complier warnings on some platforms.
+        */
+       if (write(pipefd[1], &ioctl_rc, sizeof(int)) < 0)
+           ; /* don't care */
 
        exit(0);
     } else {                   /* parent process */
@@ -334,8 +339,13 @@ ForkOpen(char *device)
            USD_CLOSE(fd);
        }
 
-       /* send the return code back to the parent */
-       write(pipefd[1], &open_rc, sizeof(open_rc));
+       /*
+        * Send the return code back to the parent.
+        * If this fails, there's nothing we can do, but we must test
+        * it in order to avoid complier warnings on some platforms.
+        */
+       if (write(pipefd[1], &open_rc, sizeof(open_rc)) < 0)
+           ; /* don't care */
 
        exit(0);
     } else {                   /* parent process */
@@ -459,15 +469,26 @@ ForkClose(usd_handle_t fd)
            }
        }
 
-       /* the parent writes the control pipe after it closes the device */
-       read(ctlpipe[0], &close_rc, sizeof(int));
+       /*
+        * The parent writes the control pipe after it closes the device.
+        * We don't actually care about the read; we're just using it to
+        * block until the parent is ready.  But we must do something
+        * with the result, to avoid complier warnings on some platforms.
+        */
+       if (read(ctlpipe[0], &close_rc, sizeof(int)) < 0)
+           ; /* don't care */
        close(ctlpipe[0]);
 
        /* do the close */
        close_rc = USD_CLOSE(fd);
 
-       /* send the return code back to the parent */
-       write(pipefd[1], &close_rc, sizeof(int));
+       /*
+        * Send the return code back to the parent.
+        * If this fails, there's nothing we can do, but we must test
+        * it in order to avoid complier warnings on some platforms.
+        */
+       if (write(pipefd[1], &close_rc, sizeof(int)) < 0)
+           ; /* don't care */
 
        exit(0);
     } else {                   /* parent process */
index 973f795a1ef999854aa51a69f0e1a5e4d724529f..8c47377b3bcd9e28ef03fa0fd07a1644e26a2512 100644 (file)
@@ -56,9 +56,13 @@ struct rx_trace {
 void
 rxi_flushtrace(void)
 {
-    if (rxi_logfd >= 0)
-       write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
+    afs_uint32 len = rxi_tracepos;
+
     rxi_tracepos = 0;
+    if (rxi_logfd < 0)
+       return;
+    if (write(rxi_logfd, rxi_tracebuf, len) < 0)
+       ; /* don't care */
 }
 
 void
index aaa499203200529708223263e1f24ae8578114c0..380cb792e43ac07268f19dba36b9627d72d3bd44 100644 (file)
@@ -101,8 +101,10 @@ void
 WriteLogBuffer(char *buf, afs_uint32 len)
 {
     LOCK_SERVERLOG();
-    if (serverLogFD > 0)
-       (void)write(serverLogFD, buf, len);
+    if (serverLogFD > 0) {
+       if (write(serverLogFD, buf, len) < 0)
+           ; /* don't care */
+    }
     UNLOCK_SERVERLOG();
 }
 
@@ -146,8 +148,10 @@ vFSLog(const char *format, va_list args)
        syslog(LOG_INFO, "%s", info);
     } else
 #endif
-    if (serverLogFD > 0)
-       (void)write(serverLogFD, tbuffer, len);
+    if (serverLogFD > 0) {
+       if (write(serverLogFD, tbuffer, len) < 0)
+           ; /* don't care */
+    }
     UNLOCK_SERVERLOG();
 
 #if !defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
@@ -359,13 +363,15 @@ OpenLog(const char *fileName)
        return -1;
     }
     /* redirect stdout and stderr so random printf's don't write to data */
-    (void)freopen(fileName, "a", stdout);
-    (void)freopen(fileName, "a", stderr);
+    if (freopen(fileName, "a", stdout) == NULL)
+       ; /* don't care */
+    if (freopen(fileName, "a", stderr) != NULL) {
 #ifdef HAVE_SETVBUF
-    setvbuf(stderr, NULL, _IONBF, 0);
+       setvbuf(stderr, NULL, _IONBF, 0);
 #else
-    setbuf(stderr, NULL);
+       setbuf(stderr, NULL);
 #endif
+    }
 
 #if defined(AFS_PTHREAD_ENV)
     MUTEX_INIT(&serverLogMutex, "serverlog", MUTEX_DEFAULT, 0);
@@ -403,17 +409,19 @@ ReOpenLog(const char *fileName)
        close(serverLogFD);
     serverLogFD = open(fileName, O_WRONLY | O_APPEND | O_CREAT | (isfifo?O_NONBLOCK:0), 0666);
     if (serverLogFD > 0) {
-       (void)freopen(fileName, "a", stdout);
-       (void)freopen(fileName, "a", stderr);
+       if (freopen(fileName, "a", stdout) == NULL)
+           ; /* don't care */
+       if (freopen(fileName, "a", stderr) != NULL) {
 #ifdef HAVE_SETVBUF
 #ifdef SETVBUF_REVERSED
-       setvbuf(stderr, _IONBF, NULL, 0);
+           setvbuf(stderr, _IONBF, NULL, 0);
 #else
-       setvbuf(stderr, NULL, _IONBF, 0);
+           setvbuf(stderr, NULL, _IONBF, 0);
 #endif
 #else
-       setbuf(stderr, NULL);
+           setbuf(stderr, NULL);
 #endif
+       }
 
     }
     UNLOCK_SERVERLOG();
index a7e022101593f41d1520a0e954c7326af2bcf35d..966571ddb0f00dc1f1f3729bd53d1b8aff84e341 100644 (file)
@@ -2102,7 +2102,8 @@ main(int argc, char *argv[])
        plock(PROCLOCK);
 #else
 #ifndef AFS_NT40_ENV
-    nice(-5);                  /* TODO: */
+    if (nice(-5) < 0)
+       ; /* don't care */
 #endif
 #endif
     osi_Assert(DInit(buffs) == 0);
index e72832fa48d993bcf05fc69e9de4831f177e492f..53519dcc2a7727b38e77ac34ce06d8fb8a5917de 100644 (file)
@@ -4904,7 +4904,8 @@ TimeStampLogFile(char * log_path)
 
     /* try to link the logfile to a timestamped filename */
     /* if it fails, oh well, nothing we can do */
-    link(log_path, stampSlvgLog);
+    if (link(log_path, stampSlvgLog))
+       ; /* oh well */
 }
 #endif
 
index 6cbf9c3750b5965ddc66629cf5e3440b893726d4..d3ab6094c3198d47144b2a9cbf19b39be2b74500 100644 (file)
@@ -1435,8 +1435,10 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
        fprintf(STDOUT, "First test point - operation not started.\n");
        fprintf(STDOUT, "...test here (y, n)? ");
        fflush(STDOUT);
-       fscanf(stdin, "%c", &in);
-       fscanf(stdin, "%c", &lf);       /* toss away */
+       if (fscanf(stdin, "%c", &in) < 1)
+           in = 0;
+       if (fscanf(stdin, "%c", &lf) < 0)       /* toss away */
+           ; /* don't care */
        if (in == 'y') {
            fprintf(STDOUT, "type control-c\n");
            while (1) {
@@ -1791,8 +1793,10 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
                "Second test point - operation in progress but not complete.\n");
        fprintf(STDOUT, "...test here (y, n)? ");
        fflush(STDOUT);
-       fscanf(stdin, "%c", &in);
-       fscanf(stdin, "%c", &lf);       /* toss away */
+       if (fscanf(stdin, "%c", &in) < 1)
+           in = 0;
+       if (fscanf(stdin, "%c", &lf) < 0)       /* toss away */
+           ; /* don't care */
        if (in == 'y') {
            fprintf(STDOUT, "type control-c\n");
            while (1) {
@@ -1824,8 +1828,10 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
                "Third test point - operation complete but no cleanup.\n");
        fprintf(STDOUT, "...test here (y, n)? ");
        fflush(STDOUT);
-       fscanf(stdin, "%c", &in);
-       fscanf(stdin, "%c", &lf);       /* toss away */
+       if (fscanf(stdin, "%c", &in) < 1)
+           in = 0;
+       if (fscanf(stdin, "%c", &lf) < 0)       /* toss away */
+           ; /* don't care */
        if (in == 'y') {
            fprintf(STDOUT, "type control-c\n");
            while (1) {
@@ -1907,8 +1913,10 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
        fprintf(STDOUT, "Fourth test point - operation complete.\n");
        fprintf(STDOUT, "...test here (y, n)? ");
        fflush(STDOUT);
-       fscanf(stdin, "%c", &in);
-       fscanf(stdin, "%c", &lf);       /* toss away */
+       if (fscanf(stdin, "%c", &in) < 1)
+           in = 0;
+       if (fscanf(stdin, "%c", &lf) < 0)       /* toss away */
+           ; /* don't care */
        if (in == 'y') {
            fprintf(STDOUT, "type control-c\n");
            while (1) {