From: Pat Riehecky Date: Wed, 23 May 2018 20:50:45 +0000 (-0500) Subject: Add braces to empty conditional blocks X-Git-Tag: upstream/1.8.1_pre2^2~26 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=47694e2976034cef094be5f0b5d0fd0c5bc16893;p=packages%2Fo%2Fopenafs.git Add braces to empty conditional blocks 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 Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk (cherry picked from commit a411366f57dcf39cc17b6d61d8332e520dff57d1) Change-Id: I9243105d75878487ec965070d3946e8d683f264b Reviewed-on: https://gerrit.openafs.org/13149 Tested-by: BuildBot Reviewed-by: PatRiehecky Reviewed-by: Benjamin Kaduk --- diff --git a/src/aklog/aklog.c b/src/aklog/aklog.c index 1eaa95e89..63b5a7f75 100644 --- a/src/aklog/aklog.c +++ b/src/aklog/aklog.c @@ -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); diff --git a/src/auth/ktc.c b/src/auth/ktc.c index b53479a2e..ecb97081c 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -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) diff --git a/src/butm/file_tm.c b/src/butm/file_tm.c index d25da7047..fd4c8d750 100644 --- a/src/butm/file_tm.c +++ b/src/butm/file_tm.c @@ -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 */ diff --git a/src/rx/rx_rdwr.c b/src/rx/rx_rdwr.c index 4124658e5..1d1257c91 100644 --- a/src/rx/rx_rdwr.c +++ b/src/rx/rx_rdwr.c @@ -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; diff --git a/src/rx/rx_trace.c b/src/rx/rx_trace.c index 94dc11714..59cc646a2 100644 --- a/src/rx/rx_trace.c +++ b/src/rx/rx_trace.c @@ -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 diff --git a/src/util/serverLog.c b/src/util/serverLog.c index 41a07f5de..a250d6533 100644 --- a/src/util/serverLog.c +++ b/src/util/serverLog.c @@ -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); diff --git a/src/viced/viced.c b/src/viced/viced.c index 1ca05a603..4065f72d6 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -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 diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c index cd0e6b389..b879ebc9e 100644 --- a/src/volser/vsprocs.c +++ b/src/volser/vsprocs.c @@ -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) {