]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Add braces to empty conditional blocks
authorPat Riehecky <riehecky@fnal.gov>
Wed, 23 May 2018 20:50:45 +0000 (15:50 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 8 Jun 2018 12:47:04 +0000 (08:47 -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

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>
(cherry picked from commit a411366f57dcf39cc17b6d61d8332e520dff57d1)

Change-Id: I9243105d75878487ec965070d3946e8d683f264b
Reviewed-on: https://gerrit.openafs.org/13149
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: PatRiehecky <jcpunk@gmail.com>
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 1eaa95e89366ca244fbdaf1d87009db7d1e41345..63b5a7f754c9ba6262ee959a5fa2080fe672b78b 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 b53479a2e2a355264c33fe7aac77e9f50dccf000..ecb97081c09e03a8294a404ac27a2384774c1fe0 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 d25da70472bf98cf21522646e60776cbbeaa7cbe..fd4c8d75061c1c396be976d0741099dc02c8b132 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 4124658e55947e1ae519f273d78d15ee702d1357..1d1257c9166a4467f30ac067daa8849e73d1cd92 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 94dc117140e3851dd1d746fb3abf2ab54bd2b8f2..59cc646a252f21e0dcf2f8b0d39a760b2e6ff3f4 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 41a07f5de85c7b565ae8c267374d53ecda707d9c..a250d6533ceb10f9108d3434b4da2e59f6deaaf7 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 1ca05a603252e8b4ca2872cbf9b83d30e14d7037..4065f72d6adbdd387fc065727dfbfca2edfdeeba 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 cd0e6b3894c0d31f6958e6326dfa4a66913e606e..b879ebc9ed13bf33f90e8adab5e4c195d3f325a6 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) {