]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Convert inline "if"s to "if"s with body
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 16 Nov 2014 13:49:26 +0000 (14:49 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 16 Nov 2014 13:49:26 +0000 (14:49 +0100)
args.c
ccache.c
cleanup.c
execute.c
mdfour.c
unify.c
util.c

diff --git a/args.c b/args.c
index 67c61160c411576f46c704e2eddb55fc2e689776..2b17779a15028bb45483f2c77fece95e46a0a747 100644 (file)
--- a/args.c
+++ b/args.c
@@ -202,7 +202,9 @@ void
 args_free(struct args *args)
 {
        int i;
-       if (!args) return;
+       if (!args) {
+               return;
+       }
        for (i = 0; i < args->argc; ++i) {
                if (args->argv[i]) {
                        free(args->argv[i]);
index 0f356c0ab3f3c4964e5ac40866bac9711e76ca78..3b73c648c4f9f90494ec4e25e35516c309a4af5c 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -265,7 +265,9 @@ static const char *
 temp_dir()
 {
        static char *path = NULL;
-       if (path) return path;  /* Memoize */
+       if (path) {
+               return path; /* Memoize */
+       }
        path = conf->temporary_dir;
        if (str_eq(path, "")) {
                path = format("%s/tmp", conf->cache_dir);
index 0de706258e097ff5790ea11e9ad9fab8d3afcfe2..a8b4cf0b9020d2795cc9c46c84f393111d2e0437 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-2006 Andrew Tridgell
- * Copyright (C) 2009-2011, 2013 Joel Rosdahl
+ * Copyright (C) 2009-2014 Joel Rosdahl
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -58,7 +58,9 @@ traverse_fn(const char *fname, struct stat *st)
 {
        char *p;
 
-       if (!S_ISREG(st->st_mode)) return;
+       if (!S_ISREG(st->st_mode)) {
+               return;
+       }
 
        p = basename(fname);
        if (str_eq(p, "stats")) {
@@ -233,7 +235,9 @@ static void wipe_fn(const char *fname, struct stat *st)
 {
        char *p;
 
-       if (!S_ISREG(st->st_mode)) return;
+       if (!S_ISREG(st->st_mode)) {
+               return;
+       }
 
        p = basename(fname);
        if (str_eq(p, "stats")) {
index 7bc86f06c94f510ca4cfb86f7cb4455904cad17c..78f1e4b7888e9a948c58ee92042e4e10c252ecf8 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -182,7 +182,9 @@ execute(char **argv, int fd_out, int fd_err)
 
        cc_log_argv("Executing ", argv);
        pid = fork();
-       if (pid == -1) fatal("Failed to fork: %s", strerror(errno));
+       if (pid == -1) {
+               fatal("Failed to fork: %s", strerror(errno));
+       }
 
        if (pid == 0) {
                /* Child. */
index a3218391729f8955bf2236c409a3a14d98422943..06bc17fa6e0f6a376f6b49be82b7eb8ff48216cb 100644 (file)
--- a/mdfour.c
+++ b/mdfour.c
@@ -130,7 +130,9 @@ void mdfour_tail(const unsigned char *in, size_t n)
 
        b = m->totalN * 8;
 
-       if (n) memcpy(buf, in, n);
+       if (n) {
+               memcpy(buf, in, n);
+       }
        buf[n] = 0x80;
 
        if (n <= 55) {
@@ -171,7 +173,9 @@ mdfour_update(struct mdfour *md, const unsigned char *in, size_t n)
 
        if (md->tail_len) {
                size_t len = 64 - md->tail_len;
-               if (len > n) len = n;
+               if (len > n) {
+                       len = n;
+               }
                memcpy(md->tail+md->tail_len, in, len);
                md->tail_len += len;
                n -= len;
diff --git a/unify.c b/unify.c
index b10b3f5d98b55f139944593aaa5ba66ea4b95a5a..3128623db8b39e3e7c4b3453bbe27a5f7ae261a0 100644 (file)
--- a/unify.c
+++ b/unify.c
@@ -64,15 +64,25 @@ build_table(void)
        int i;
        static bool done;
 
-       if (done) return;
+       if (done) {
+               return;
+       }
        done = true;
 
        memset(tokens, 0, sizeof(tokens));
        for (c = 0; c < 128; c++) {
-               if (isalpha(c) || c == '_') tokens[c].type |= C_ALPHA;
-               if (isdigit(c)) tokens[c].type |= C_DIGIT;
-               if (isspace(c)) tokens[c].type |= C_SPACE;
-               if (isxdigit(c)) tokens[c].type |= C_HEX;
+               if (isalpha(c) || c == '_') {
+                       tokens[c].type |= C_ALPHA;
+               }
+               if (isdigit(c)) {
+                       tokens[c].type |= C_DIGIT;
+               }
+               if (isspace(c)) {
+                       tokens[c].type |= C_SPACE;
+               }
+               if (isxdigit(c)) {
+                       tokens[c].type |= C_HEX;
+               }
        }
        tokens['\''].type |= C_QUOTE;
        tokens['"'].type |= C_QUOTE;
diff --git a/util.c b/util.c
index 30c14cc967facc2d36489247f5ed11f6d71296e8..f453959e534a71ab6b34684347c286235eccab32 100644 (file)
--- a/util.c
+++ b/util.c
@@ -555,12 +555,16 @@ create_cachedirtag(const char *dir)
                goto error;
        }
        f = fopen(filename, "w");
-       if (!f) goto error;
+       if (!f) {
+               goto error;
+       }
        if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) {
                fclose(f);
                goto error;
        }
-       if (fclose(f)) goto error;
+       if (fclose(f)) {
+               goto error;
+       }
 success:
        free(filename);
        return 0;
@@ -582,7 +586,9 @@ format(const char *format, ...)
        }
        va_end(ap);
 
-       if (!*ptr) fatal("Internal error in format");
+       if (!*ptr) {
+               fatal("Internal error in format");
+       }
        return ptr;
 }
 
@@ -677,7 +683,9 @@ void *
 x_realloc(void *ptr, size_t size)
 {
        void *p2;
-       if (!ptr) return x_malloc(size);
+       if (!ptr) {
+               return x_malloc(size);
+       }
        p2 = realloc(ptr, size);
        if (!p2) {
                fatal("x_realloc: Could not allocate %lu bytes", (unsigned long)size);
@@ -712,7 +720,9 @@ reformat(char **ptr, const char *format, ...)
        }
        va_end(ap);
 
-       if (!ptr) fatal("Out of memory in reformat");
+       if (!ptr) {
+               fatal("Out of memory in reformat");
+       }
        if (saved) {
                free(saved);
        }
@@ -728,16 +738,24 @@ traverse(const char *dir, void (*fn)(const char *, struct stat *))
        struct dirent *de;
 
        d = opendir(dir);
-       if (!d) return;
+       if (!d) {
+               return;
+       }
 
        while ((de = readdir(d))) {
                char *fname;
                struct stat st;
 
-               if (str_eq(de->d_name, ".")) continue;
-               if (str_eq(de->d_name, "..")) continue;
+               if (str_eq(de->d_name, ".")) {
+                       continue;
+               }
+               if (str_eq(de->d_name, "..")) {
+                       continue;
+               }
 
-               if (strlen(de->d_name) == 0) continue;
+               if (strlen(de->d_name) == 0) {
+                       continue;
+               }
 
                fname = format("%s/%s", dir, de->d_name);
                if (lstat(fname, &st)) {
@@ -766,10 +784,14 @@ basename(const char *path)
 {
        char *p;
        p = strrchr(path, '/');
-       if (p) path = p + 1;
+       if (p) {
+               path = p + 1;
+       }
 #ifdef _WIN32
        p = strrchr(path, '\\');
-       if (p) path = p + 1;
+       if (p) {
+               path = p + 1;
+       }
 #endif
 
        return x_strdup(path);