From: Joel Rosdahl Date: Wed, 16 Mar 2016 19:04:09 +0000 (+0100) Subject: Adjust code as suggested by uncrustify X-Git-Tag: v3.3~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4f3ac7acd43d1440a3f3c4925c193f0fe91facd;p=thirdparty%2Fccache.git Adjust code as suggested by uncrustify --- diff --git a/args.c b/args.c index a58848466..655fdf32f 100644 --- a/args.c +++ b/args.c @@ -63,8 +63,9 @@ args_init_from_gcc_atfile(const char *filename) * quote */ quoting = '\0'; - if (!(argtext = read_text_file(filename, 0))) + if (!(argtext = read_text_file(filename, 0))) { return NULL; + } args = args_init(0, NULL); pos = argtext; @@ -108,8 +109,9 @@ args_init_from_gcc_atfile(const char *filename) case '\0': /* end of token */ *argpos = '\0'; - if (argbuf[0] != '\0') + if (argbuf[0] != '\0') { args_add(args, argbuf); + } argpos = argbuf; if (*pos == '\0') { goto out; diff --git a/ccache.c b/ccache.c index 886b85213..64130c73e 100644 --- a/ccache.c +++ b/ccache.c @@ -574,8 +574,9 @@ remember_include_file(char *path, struct mdfour *cpp_hash, bool system) /* stat fails on directories on win32 */ attributes = GetFileAttributes(path); if (attributes != INVALID_FILE_ATTRIBUTES && - attributes & FILE_ATTRIBUTE_DIRECTORY) + attributes & FILE_ATTRIBUTE_DIRECTORY) { goto ignore; + } #endif if (x_stat(path, &st) != 0) { @@ -698,8 +699,9 @@ make_relative_path(char *path) } #ifdef _WIN32 - if (path[0] == '/') + if (path[0] == '/') { path++; /* skip leading slash */ + } #endif /* x_realpath only works for existing paths, so if path doesn't exist, try @@ -1312,8 +1314,9 @@ get_object_name_from_cpp(struct args *args, struct mdfour *hash) add_pending_tmp_file(path_stdout); args_add(args, "-E"); - if (conf->keep_comments_cpp) + if (conf->keep_comments_cpp) { args_add(args, "-C"); + } args_add(args, input_file); add_prefix(args, conf->prefix_command_cpp); cc_log("Running preprocessor"); diff --git a/conf.c b/conf.c index de81cd5f9..7620dc168 100644 --- a/conf.c +++ b/conf.c @@ -578,7 +578,8 @@ conf_print_items(struct conf *conf, context); reformat(&s, "keep_comments_cpp = %s", bool_to_string(conf->keep_comments_cpp)); - printer(s, conf->item_origins[find_conf("keep_comments_cpp")->number], context); + printer(s, conf->item_origins[find_conf( + "keep_comments_cpp")->number], context); reformat(&s, "log_file = %s", conf->log_file); printer(s, conf->item_origins[find_conf("log_file")->number], context); diff --git a/execute.c b/execute.c index 8681d5fc1..d7c75b861 100644 --- a/execute.c +++ b/execute.c @@ -58,8 +58,9 @@ win32argvtos(char *prefix, char **argv) } while ((arg = argv[i++])); str = ptr = malloc(l + 1); - if (!str) + if (!str) { return NULL; + } i = 0; arg = prefix ? prefix : argv[i++]; @@ -74,14 +75,16 @@ win32argvtos(char *prefix, char **argv) case '"': bs = (bs << 1) + 1; default: - while (bs && bs--) + while (bs && bs--) { *ptr++ = '\\'; + } *ptr++ = arg[j]; } } bs <<= 1; - while (bs && bs--) + while (bs && bs--) { *ptr++ = '\\'; + } *ptr++ = '"'; *ptr++ = ' '; /* cppcheck-suppress unreadVariable */ @@ -99,8 +102,9 @@ win32getshell(char *path) const char *ext; ext = get_extension(path); - if (ext && strcasecmp(ext, ".sh") == 0 && (path_env = getenv("PATH"))) + if (ext && strcasecmp(ext, ".sh") == 0 && (path_env = getenv("PATH"))) { sh = find_executable_in_path("sh.exe", NULL, path_env); + } if (!sh && getenv("CCACHE_DETECT_SHEBANG")) { /* Detect shebang. */ FILE *fp; @@ -109,8 +113,9 @@ win32getshell(char *path) char buf[10]; fgets(buf, sizeof(buf), fp); buf[9] = 0; - if (str_eq(buf, "#!/bin/sh") && (path_env = getenv("PATH"))) + if (str_eq(buf, "#!/bin/sh") && (path_env = getenv("PATH"))) { sh = find_executable_in_path("sh.exe", NULL, path_env); + } fclose(fp); } } @@ -145,8 +150,9 @@ win32execute(char *path, char **argv, int doreturn, memset(&si, 0x00, sizeof(si)); sh = win32getshell(path); - if (sh) + if (sh) { path = sh; + } si.cb = sizeof(STARTUPINFO); if (fd_stdout != -1) { @@ -214,8 +220,9 @@ win32execute(char *path, char **argv, int doreturn, GetExitCodeProcess(pi.hProcess, &exitcode); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); - if (!doreturn) + if (!doreturn) { x_exit(exitcode); + } return exitcode; } diff --git a/hashutil.c b/hashutil.c index ad7a56f31..1860f5306 100644 --- a/hashutil.c +++ b/hashutil.c @@ -201,13 +201,15 @@ hash_command_output(struct mdfour *hash, const char *command, #ifdef _WIN32 /* trim leading space */ - while (isspace(*command)) + while (isspace(*command)) { command++; + } /* add "echo" command */ if (str_startswith(command, "echo")) { command = format("cmd.exe /c \"%s\"", command); cmd = true; - } else if (str_startswith(command, "%compiler%") && str_eq(compiler, "echo")) { + } else if (str_startswith(command, + "%compiler%") && str_eq(compiler, "echo")) { command = format("cmd.exe /c \"%s%s\"", compiler, command + 10); cmd = true; } else { @@ -228,11 +230,13 @@ hash_command_output(struct mdfour *hash, const char *command, memset(&si, 0x00, sizeof(si)); path = find_executable(args->argv[0], NULL); - if (!path) + if (!path) { path = args->argv[0]; + } sh = win32getshell(path); - if (sh) + if (sh) { path = sh; + } si.cb = sizeof(STARTUPINFO); CreatePipe(&pipe_out[0], &pipe_out[1], &sa, 0); @@ -241,16 +245,18 @@ hash_command_output(struct mdfour *hash, const char *command, si.hStdError = pipe_out[1]; si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); si.dwFlags = STARTF_USESTDHANDLES; - if (!cmd) + if (!cmd) { win32args = win32argvtos(sh, args->argv); - else - win32args = (char *) command; /* quoted */ + } else { + win32args = (char *) command; /* quoted */ + } ret = CreateProcess(path, win32args, NULL, NULL, 1, 0, NULL, NULL, &si, &pi); CloseHandle(pipe_out[1]); args_free(args); free(win32args); - if (cmd) - free((char *) command); /* original argument was replaced above */ + if (cmd) { + free((char *) command); /* original argument was replaced above */ + } if (ret == 0) { stats_update(STATS_COMPCHECK); return false; diff --git a/mdfour.c b/mdfour.c index 73736ba93..30875dff1 100644 --- a/mdfour.c +++ b/mdfour.c @@ -89,9 +89,10 @@ copy64(uint32_t *M, const unsigned char *in) #ifdef WORDS_BIGENDIAN int i; - for (i = 0; i < 16; i++) + for (i = 0; i < 16; i++) { M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | (in[i*4+1]<<8) | (in[i*4+0]<<0); + } #else memcpy(M, in, 16*4); #endif diff --git a/test/test_argument_processing.c b/test/test_argument_processing.c index 6fc67ac5e..461d4e968 100644 --- a/test/test_argument_processing.c +++ b/test/test_argument_processing.c @@ -49,14 +49,16 @@ get_posix_path(char *path) char *p; /* / escape volume */ - if (path[0] >= 'A' && path[0] <= 'Z' && path[1] == ':') + if (path[0] >= 'A' && path[0] <= 'Z' && path[1] == ':') { posix = format("/%s", path); - else + } else { posix = x_strdup(path); + } /* convert slashes */ for (p = posix; *p; p++) { - if (*p == '\\') + if (*p == '\\') { *p = '/'; + } } return posix; #endif diff --git a/util.c b/util.c index 6564704ae..1a7f3fdd1 100644 --- a/util.c +++ b/util.c @@ -711,8 +711,9 @@ x_strndup(const char *s, size_t n) #ifndef HAVE_STRNDUP size_t m; - if (!s) + if (!s) { return NULL; + } m = 0; while (m < n && s[m]) { m++; @@ -1145,7 +1146,9 @@ static BOOL GetFileNameFromHandle(HANDLE hFile, TCHAR *pszFilename, } // Go to the next NULL character. - while (*p++) ; + while (*p++) { + // Do nothing. + } } while (!bFound && *p); // end of string } } @@ -1174,8 +1177,9 @@ x_realpath(const char *path) #if HAVE_REALPATH p = realpath(path, ret); #elif defined(_WIN32) - if (path[0] == '/') + if (path[0] == '/') { path++; /* skip leading slash */ + } path_handle = CreateFile( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -1240,15 +1244,19 @@ strtok_r(char *str, const char *delim, char **saveptr) { int len; char *ret; - if (!str) + if (!str) { str = *saveptr; + } len = strlen(str); ret = strtok(str, delim); if (ret) { char *save = ret; - while (*save++) ; - if ((len + 1) == (intptr_t) (save - str)) + while (*save++) { + /* Do nothing. */ + } + if ((len + 1) == (intptr_t) (save - str)) { save--; + } *saveptr = save; } return ret; @@ -1426,10 +1434,12 @@ get_relative_path(const char *from, const char *to) #ifdef _WIN32 // Paths can be escaped by a slash for use with -isystem - if (from[0] == '/') + if (from[0] == '/') { from++; - if (to[0] == '/') + } + if (to[0] == '/') { to++; + } // Both paths are absolute, drop the drive letters assert(from[0] == to[0]); // Assume the same drive letter from += 2; @@ -1480,11 +1490,13 @@ is_absolute_path(const char *path) bool is_full_path(const char *path) { - if (strchr(path, '/')) + if (strchr(path, '/')) { return true; + } #ifdef _WIN32 - if (strchr(path, '\\')) + if (strchr(path, '\\')) { return true; + } #endif return false; }