Add braces to empty conditional blocks 81/13081/5
authorPat Riehecky <riehecky@fnal.gov>
Wed, 23 May 2018 20:50:45 +0000 (15:50 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 25 May 2018 15:52:59 +0000 (11:52 -0400)
GCC 7+ is able to quickly optimize away empty if/else blocks if the braces are
provided.  While this adds some additional syntax, it should also result
in faster optimization, so change our empty blocks after conditionals to use
braces.

FIXES 134377

Change-Id: I2b5e39fd8a3819e07077c2a4f28a9aa5ac432e1e
Reviewed-on: https://gerrit.openafs.org/13081
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/aklog/aklog.c
src/auth/ktc.c
src/butm/file_tm.c
src/rx/rx_rdwr.c
src/rx/rx_trace.c
src/util/serverLog.c
src/viced/viced.c
src/volser/vsprocs.c

index 1eaa95e..63b5a7f 100644 (file)
@@ -1097,8 +1097,9 @@ auth_to_cell(krb5_context context, const char *config,
         * We don't care about the return value, but need to collect it
         * to avoid compiler warnings.
         */
-       if (write(2,"",0) < 0) /* dummy write */
-           ; /* don't care */
+       if (write(2,"",0) < 0) {
+           /* dummy write, don't care */
+       }
 #endif
        token_setPag(token, afssetpag);
        status = ktc_SetTokenEx(token);
index b53479a..ecb9708 100644 (file)
@@ -180,8 +180,9 @@ SetToken(struct ktc_principal *aserver, struct ktc_token *atoken,
                        0)) {
                    found = i;  /* replace existing entry */
                    break;
-               } else          /* valid, but no match */
-                   ;
+               } else {
+                   /* valid, but no match */
+               }
            } else
                found = i;      /* remember this empty slot */
        if (found == -1)
index d25da70..fd4c8d7 100644 (file)
@@ -209,8 +209,9 @@ ForkIoctl(usd_handle_t fd, int op, int count)
         * 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 */
+       if (write(pipefd[1], &ioctl_rc, sizeof(int)) < 0) {
+           /* don't care */
+       }
 
        exit(0);
     } else {                   /* parent process */
@@ -337,8 +338,9 @@ ForkOpen(char *device)
         * 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 */
+       if (write(pipefd[1], &open_rc, sizeof(open_rc)) < 0) {
+           /* don't care */
+       }
 
        exit(0);
     } else {                   /* parent process */
@@ -468,8 +470,9 @@ ForkClose(usd_handle_t fd)
         * 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 */
+       if (read(ctlpipe[0], &close_rc, sizeof(int)) < 0) {
+           /* don't care */
+       }
        close(ctlpipe[0]);
 
        /* do the close */
@@ -480,8 +483,9 @@ ForkClose(usd_handle_t fd)
         * 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 */
+       if (write(pipefd[1], &close_rc, sizeof(int)) < 0) {
+           /* don't care */
+       }
 
        exit(0);
     } else {                   /* parent process */
index 4124658..1d1257c 100644 (file)
@@ -772,7 +772,9 @@ rxi_WriteProc(struct rx_call *call, char *buf,
        /* might be out of space now */
        if (!nbytes) {
            return requestCount;
-       } else;                 /* more data to send, so get another packet and keep going */
+       } else {
+           /* more data to send, so get another packet and keep going */
+       }
     } while (nbytes);
 
     return requestCount - nbytes;
index 94dc117..59cc646 100644 (file)
@@ -60,8 +60,9 @@ rxi_flushtrace(void)
     rxi_tracepos = 0;
     if (rxi_logfd < 0)
        return;
-    if (write(rxi_logfd, rxi_tracebuf, len) < 0)
-       ; /* don't care */
+    if (write(rxi_logfd, rxi_tracebuf, len) < 0) {
+       /* don't care */
+    }
 }
 
 void
index 41a07f5..a250d65 100644 (file)
@@ -149,8 +149,9 @@ WriteLogBuffer(char *buf, afs_uint32 len)
 {
     LOCK_SERVERLOG();
     if (serverLogFD >= 0) {
-       if (write(serverLogFD, buf, len) < 0)
-           ; /* don't care */
+       if (write(serverLogFD, buf, len) < 0) {
+           /* don't care */
+        }
     }
     UNLOCK_SERVERLOG();
 }
@@ -204,8 +205,9 @@ vFSLog(const char *format, va_list args)
     } else
 #endif
     if (serverLogFD >= 0) {
-       if (write(serverLogFD, tbuffer, len) < 0)
-           ; /* don't care */
+       if (write(serverLogFD, tbuffer, len) < 0) {
+           /* don't care */
+        }
     }
     UNLOCK_SERVERLOG();
 
@@ -523,8 +525,9 @@ InitServerLogMutex(void)
 static void
 RedirectStdStreams(const char *fileName)
 {
-    if (freopen(fileName, "a", stdout) == NULL)
-       ; /* don't care */
+    if (freopen(fileName, "a", stdout) == NULL) {
+       /* don't care */
+    }
     if (freopen(fileName, "a", stderr) != NULL) {
 #ifdef HAVE_SETVBUF
        setvbuf(stderr, NULL, _IONBF, 0);
index 1ca05a6..4065f72 100644 (file)
@@ -1913,8 +1913,9 @@ main(int argc, char *argv[])
     if (SawLock)
        plock(PROCLOCK);
 #elif !defined(AFS_NT40_ENV)
-    if (nice(-5) < 0)
-       ; /* don't care */
+    if (nice(-5) < 0) {
+       /* don't care */
+    }
 #endif
     DInit(buffs);
 #ifdef AFS_DEMAND_ATTACH_FS
index cd0e6b3..b879ebc 100644 (file)
@@ -1570,8 +1570,9 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
        fflush(STDOUT);
        if (fscanf(stdin, "%c", &in) < 1)
            in = 0;
-       if (fscanf(stdin, "%c", &lf) < 0)       /* toss away */
-           ; /* don't care */
+       if (fscanf(stdin, "%c", &lf) < 0) {
+           /* toss away; don't care */
+       }
        if (in == 'y') {
            fprintf(STDOUT, "type control-c\n");
            while (1) {
@@ -1928,8 +1929,9 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
        fflush(STDOUT);
        if (fscanf(stdin, "%c", &in) < 1)
            in = 0;
-       if (fscanf(stdin, "%c", &lf) < 0)       /* toss away */
-           ; /* don't care */
+       if (fscanf(stdin, "%c", &lf) < 0) {
+           /* toss away, don't care */
+       }
        if (in == 'y') {
            fprintf(STDOUT, "type control-c\n");
            while (1) {
@@ -1963,8 +1965,9 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
        fflush(STDOUT);
        if (fscanf(stdin, "%c", &in) < 1)
            in = 0;
-       if (fscanf(stdin, "%c", &lf) < 0)       /* toss away */
-           ; /* don't care */
+       if (fscanf(stdin, "%c", &lf) < 0) {
+           /* toss away; don't care */
+       }
        if (in == 'y') {
            fprintf(STDOUT, "type control-c\n");
            while (1) {
@@ -2048,8 +2051,9 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
        fflush(STDOUT);
        if (fscanf(stdin, "%c", &in) < 1)
            in = 0;
-       if (fscanf(stdin, "%c", &lf) < 0)       /* toss away */
-           ; /* don't care */
+       if (fscanf(stdin, "%c", &lf) < 0) {     /* toss away */
+           /* don't care */
+       }
        if (in == 'y') {
            fprintf(STDOUT, "type control-c\n");
            while (1) {