]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Adjust code as suggested by uncrustify
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 16 Mar 2016 19:04:09 +0000 (20:04 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 16 Mar 2016 19:04:09 +0000 (20:04 +0100)
args.c
ccache.c
conf.c
execute.c
hashutil.c
mdfour.c
test/test_argument_processing.c
util.c

diff --git a/args.c b/args.c
index a58848466addac9d025ffe014c0e1d19ab39f89b..655fdf32fa15198542706751c926da5e3537e709 100644 (file)
--- 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;
index 886b8521315d9927039e68b688d4577d6e9a2a02..64130c73e80e0df8fd2b037d80e6f4605d4b3807 100644 (file)
--- 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 de81cd5f92a7c692fa293879277294e49c38b67e..7620dc168f114a259acd5eb38803067a8167f9a7 100644 (file)
--- 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);
index 8681d5fc19b9946f5f6188a31befd57962e1d195..d7c75b8612f36453f6139006dd916d3d088f8137 100644 (file)
--- 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;
 }
 
index ad7a56f3142133da37f2ea04b9509f4346ad9c58..1860f5306a5d8f2f11853288db3c5a03177b2e8a 100644 (file)
@@ -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;
index 73736ba939f6aa15245a4393f1c99a30a01bea3c..30875dff1f8e691c2fb74cc1cc4c5070bd6459bd 100644 (file)
--- 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
index 6fc67ac5ea6a2f71c2fff987d045a209277304ce..461d4e968800c8affbdbb6129c8166800954d80f 100644 (file)
@@ -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 6564704aeaa7268ac5f139c6820ce5ecab226414..1a7f3fdd17a118e604fc4998074ca94c765907d5 100644 (file)
--- 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;
 }