Commit 87b57076 authored by Ben Boeckel's avatar Ben Boeckel Committed by Brad King
Browse files

clang-tidy: address readability-braces-around-statements lints

parent ccab3808
......@@ -229,9 +229,10 @@ static void md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/)
# else
# define xbuf X /* (static only) */
# endif
for (i = 0; i < 16; ++i, xp += 4)
for (i = 0; i < 16; ++i, xp += 4) {
xbuf[i] =
(md5_word_t)(xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24));
}
}
#endif
}
......@@ -369,34 +370,39 @@ static void md5_append(md5_state_t* pms, const md5_byte_t* data, size_t nbytes)
size_t offset = (pms->count[0] >> 3) & 63;
md5_word_t nbits = (md5_word_t)(nbytes << 3);
if (nbytes <= 0)
if (nbytes <= 0) {
return;
}
/* Update the message length. */
pms->count[1] += (md5_word_t)(nbytes >> 29);
pms->count[0] += nbits;
if (pms->count[0] < nbits)
if (pms->count[0] < nbits) {
pms->count[1]++;
}
/* Process an initial partial block. */
if (offset) {
size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
memcpy(pms->buf + offset, p, copy);
if (offset + copy < 64)
if (offset + copy < 64) {
return;
}
p += copy;
left -= copy;
md5_process(pms, pms->buf);
}
/* Process full blocks. */
for (; left >= 64; p += 64, left -= 64)
for (; left >= 64; p += 64, left -= 64) {
md5_process(pms, p);
}
/* Process a final partial block. */
if (left)
if (left) {
memcpy(pms->buf, p, left);
}
}
/* Finish the message and return the digest. */
......
......@@ -432,8 +432,8 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
char const* const* c = command;
kwsysProcess_ptrdiff_t n = 0;
kwsysProcess_ptrdiff_t i = 0;
while (*c++)
;
while (*c++) {
}
n = c - command - 1;
newCommands[cp->NumberOfCommands] =
(char**)malloc((size_t)(n + 1) * sizeof(char*));
......@@ -787,8 +787,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/* Some platforms specify that the chdir call may be
interrupted. Repeat the call until it finishes. */
while (((r = chdir(cp->WorkingDirectory)) < 0) && (errno == EINTR))
;
while (((r = chdir(cp->WorkingDirectory)) < 0) && (errno == EINTR)) {
}
if (r < 0) {
kwsysProcessCleanup(cp, 1);
return;
......@@ -1014,8 +1014,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
if (cp->RealWorkingDirectory) {
/* Some platforms specify that the chdir call may be
interrupted. Repeat the call until it finishes. */
while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR))
;
while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR)) {
}
free(cp->RealWorkingDirectory);
cp->RealWorkingDirectory = 0;
}
......@@ -1450,8 +1450,8 @@ void kwsysProcess_Kill(kwsysProcess* cp)
/* Reap the child. Keep trying until the call is not
interrupted. */
while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) && (errno == EINTR))
;
while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) && (errno == EINTR)) {
}
}
}
......@@ -1591,16 +1591,16 @@ static void kwsysProcessCleanup(kwsysProcess* cp, int error)
/* Reap the child. Keep trying until the call is not
interrupted. */
while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
}
}
}
/* Restore the working directory. */
if (cp->RealWorkingDirectory) {
while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR))
;
while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR)) {
}
}
}
......@@ -1636,8 +1636,8 @@ static void kwsysProcessCleanupDescriptor(int* pfd)
if (pfd && *pfd > 2) {
/* Keep trying to close until it is not interrupted by a
* signal. */
while ((close(*pfd) < 0) && (errno == EINTR))
;
while ((close(*pfd) < 0) && (errno == EINTR)) {
}
*pfd = -1;
}
}
......@@ -1662,8 +1662,8 @@ static void kwsysProcessClosePipes(kwsysProcess* cp)
read until the operation is not interrupted. */
while ((read(cp->PipeReadEnds[i], cp->PipeBuffer,
KWSYSPE_PIPE_BUFFER_SIZE) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
}
#endif
......@@ -1819,8 +1819,8 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
/* Make sure the child is in the process group before we proceed. This
avoids race conditions with calls to the kill function that we make for
signalling process groups. */
while ((readRes = read(pgidPipe[0], &tmp, 1)) > 0)
;
while ((readRes = read(pgidPipe[0], &tmp, 1)) > 0) {
}
if (readRes < 0) {
sigprocmask(SIG_SETMASK, &old_mask, 0);
kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]);
......@@ -1848,8 +1848,8 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
/* Keep trying to read until the operation is not interrupted. */
while (((n = read(si->ErrorPipe[0], cp->ErrorMessage + total,
(size_t)(KWSYSPE_PIPE_BUFFER_SIZE - total))) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
if (n > 0) {
total += n;
}
......@@ -2436,8 +2436,8 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
} else {
/* Use the error pipe to report the pid to the real parent. */
while ((write(si->ErrorPipe[1], &child_pid, sizeof(child_pid)) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
/* Exit without cleanup. The parent holds all resources. */
kwsysProcessExit();
......@@ -2450,12 +2450,12 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
pid_t child_pid;
int status;
while ((read(si->ErrorPipe[0], &child_pid, sizeof(child_pid)) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
/* Wait for the intermediate process to exit and clean it up. */
while ((waitpid(middle_pid, &status, 0) < 0) && (errno == EINTR))
;
while ((waitpid(middle_pid, &status, 0) < 0) && (errno == EINTR)) {
}
return child_pid;
}
} else {
......@@ -2728,8 +2728,8 @@ static int kwsysProcessesAdd(kwsysProcess* cp)
sigemptyset(&newSigAction.sa_mask);
while ((sigaction(SIGCHLD, &newSigAction,
&kwsysProcessesOldSigChldAction) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
/* Install our handler for SIGINT / SIGTERM. Repeat call until
it is not interrupted. */
......@@ -2737,15 +2737,15 @@ static int kwsysProcessesAdd(kwsysProcess* cp)
sigaddset(&newSigAction.sa_mask, SIGTERM);
while ((sigaction(SIGINT, &newSigAction,
&kwsysProcessesOldSigIntAction) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
sigemptyset(&newSigAction.sa_mask);
sigaddset(&newSigAction.sa_mask, SIGINT);
while ((sigaction(SIGTERM, &newSigAction,
&kwsysProcessesOldSigIntAction) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
}
}
......@@ -2776,14 +2776,14 @@ static void kwsysProcessesRemove(kwsysProcess* cp)
/* Restore the signal handlers. Repeat call until it is not
interrupted. */
while ((sigaction(SIGCHLD, &kwsysProcessesOldSigChldAction, 0) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
while ((sigaction(SIGINT, &kwsysProcessesOldSigIntAction, 0) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
while ((sigaction(SIGTERM, &kwsysProcessesOldSigTermAction, 0) < 0) &&
(errno == EINTR))
;
(errno == EINTR)) {
}
/* Free the table of process pointers since it is now empty.
This is safe because the signal handler has been removed. */
......@@ -2869,8 +2869,8 @@ static void kwsysProcessesSignalHandler(int signum
memset(&defSigAction, 0, sizeof(defSigAction));
defSigAction.sa_handler = SIG_DFL;
sigemptyset(&defSigAction.sa_mask);
while ((sigaction(signum, &defSigAction, 0) < 0) && (errno == EINTR))
;
while ((sigaction(signum, &defSigAction, 0) < 0) && (errno == EINTR)) {
}
/* Unmask the signal. */
sigemptyset(&unblockSet);
sigaddset(&unblockSet, signum);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment