From 1b37136633ab1e81f12d9782ca777b954b463c42 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Wed, 15 Apr 2020 06:38:42 -0400 Subject: KWSys 2020-04-15 (5ada375f) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 5ada375fcf564e837672eecbca2d522105daebf1 (master). Upstream Shortlog ----------------- Ben Boeckel (3): 83b20b65 clang-tidy: address `readability-braces-around-statements` lint 535633fa clang-tidy: address `readability-isolate-declaration` lint de210648 clang-tidy: address `readability-else-after-return` lint --- MD5.c | 6 ++++-- ProcessUNIX.c | 18 ++++++++++-------- testProcess.c | 3 ++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/MD5.c b/MD5.c index 7ae2630..fb18a5b 100644 --- a/MD5.c +++ b/MD5.c @@ -417,14 +417,16 @@ static void md5_finish(md5_state_t* pms, md5_byte_t digest[16]) int i; /* Save the length before padding. */ - for (i = 0; i < 8; ++i) + for (i = 0; i < 8; ++i) { data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); + } /* Pad to 56 bytes mod 64. */ md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); /* Append the length. */ md5_append(pms, data, 8); - for (i = 0; i < 16; ++i) + for (i = 0; i < 16; ++i) { digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); + } } #if defined(__clang__) && !defined(__INTEL_COMPILER) diff --git a/ProcessUNIX.c b/ProcessUNIX.c index d3a09ed..cc45529 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -1147,8 +1147,8 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length, read until the operation is not interrupted. */ while (((n = read(cp->PipeReadEnds[i], cp->PipeBuffer, KWSYSPE_PIPE_BUFFER_SIZE)) < 0) && - (errno == EINTR)) - ; + (errno == EINTR)) { + } if (n > 0) { /* We have data on this pipe. */ if (i == KWSYSPE_PIPE_SIGNAL) { @@ -1221,8 +1221,8 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length, /* Run select to block until data are available. Repeat call until it is not interrupted. */ while (((numReady = select(max + 1, &cp->PipeSet, 0, 0, timeout)) < 0) && - (errno == EINTR)) - ; + (errno == EINTR)) { + } /* Check result of select. */ if (numReady == 0) { @@ -1879,7 +1879,8 @@ static void kwsysProcessDestroy(kwsysProcess* cp) int i; /* Temporarily disable signals that access ForkPIDs. We don't want them to read a reaped PID, and writes to ForkPIDs are not atomic. */ - sigset_t mask, old_mask; + sigset_t mask; + sigset_t old_mask; sigemptyset(&mask); sigaddset(&mask, SIGINT); sigaddset(&mask, SIGTERM); @@ -1892,8 +1893,8 @@ static void kwsysProcessDestroy(kwsysProcess* cp) int result; while (((result = waitpid(cp->ForkPIDs[i], &cp->CommandExitCodes[i], WNOHANG)) < 0) && - (errno == EINTR)) - ; + (errno == EINTR)) { + } if (result > 0) { /* This child has termianted. */ cp->ForkPIDs[i] = 0; @@ -2567,7 +2568,8 @@ static void kwsysProcessKill(pid_t process_id) /* Make sure the process started and provided a valid header. */ if (ps && fscanf(ps, "%*[^\n]\n") != EOF) { /* Look for processes whose parent is the process being killed. */ - int pid, ppid; + int pid; + int ppid; while (fscanf(ps, KWSYSPE_PS_FORMAT, &pid, &ppid) == 2) { if (ppid == process_id) { /* Recursively kill this child and its children. */ diff --git a/testProcess.c b/testProcess.c index cde466a..74daa12 100644 --- a/testProcess.c +++ b/testProcess.c @@ -710,7 +710,8 @@ int main(int argc, const char* argv[]) free(argv0); #endif return r; - } else if (argc > 2 && strcmp(argv[1], "0") == 0) { + } + if (argc > 2 && strcmp(argv[1], "0") == 0) { /* This is the special debugging test to run a given command line. */ const char** cmd = argv + 2; -- cgit v0.12