From a411366f57dcf39cc17b6d61d8332e520dff57d1 Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Wed, 23 May 2018 15:50:45 -0500 Subject: [PATCH] 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 Change-Id: I2b5e39fd8a3819e07077c2a4f28a9aa5ac432e1e Reviewed-on: https://gerrit.openafs.org/13081 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk --- src/aklog/aklog.c | 5 +++-- src/auth/ktc.c | 5 +++-- src/butm/file_tm.c | 20 ++++++++++++-------- src/rx/rx_rdwr.c | 4 +++- src/rx/rx_trace.c | 5 +++-- src/util/serverLog.c | 15 +++++++++------ src/viced/viced.c | 5 +++-- src/volser/vsprocs.c | 20 ++++++++++++-------- 8 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/aklog/aklog.c b/src/aklog/aklog.c index 1eaa95e..63b5a7f 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 b53479a..ecb9708 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 d25da70..fd4c8d7 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 4124658..1d1257c 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 94dc117..59cc646 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 41a07f5..a250d65 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 1ca05a6..4065f72 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 cd0e6b3..b879ebc 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) { -- 1.9.4