From: Joel Rosdahl Date: Sun, 16 Nov 2014 13:49:26 +0000 (+0100) Subject: Convert inline "if"s to "if"s with body X-Git-Tag: v3.2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a0e2315b525f5e8ddee7174b58f3cf6233bba86;p=thirdparty%2Fccache.git Convert inline "if"s to "if"s with body --- diff --git a/args.c b/args.c index 67c61160c..2b17779a1 100644 --- 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]); diff --git a/ccache.c b/ccache.c index 0f356c0ab..3b73c648c 100644 --- 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); diff --git a/cleanup.c b/cleanup.c index 0de706258..a8b4cf0b9 100644 --- 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")) { diff --git a/execute.c b/execute.c index 7bc86f06c..78f1e4b78 100644 --- 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. */ diff --git a/mdfour.c b/mdfour.c index a32183917..06bc17fa6 100644 --- 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 b10b3f5d9..3128623db 100644 --- 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 30c14cc96..f453959e5 100644 --- 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);