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]);
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);
/*
* 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
{
char *p;
- if (!S_ISREG(st->st_mode)) return;
+ if (!S_ISREG(st->st_mode)) {
+ return;
+ }
p = basename(fname);
if (str_eq(p, "stats")) {
{
char *p;
- if (!S_ISREG(st->st_mode)) return;
+ if (!S_ISREG(st->st_mode)) {
+ return;
+ }
p = basename(fname);
if (str_eq(p, "stats")) {
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. */
b = m->totalN * 8;
- if (n) memcpy(buf, in, n);
+ if (n) {
+ memcpy(buf, in, n);
+ }
buf[n] = 0x80;
if (n <= 55) {
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;
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;
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;
}
va_end(ap);
- if (!*ptr) fatal("Internal error in format");
+ if (!*ptr) {
+ fatal("Internal error in format");
+ }
return ptr;
}
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);
}
va_end(ap);
- if (!ptr) fatal("Out of memory in reformat");
+ if (!ptr) {
+ fatal("Out of memory in reformat");
+ }
if (saved) {
free(saved);
}
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)) {
{
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);