From b5294d87a7306f77c0e9ddf0f904d224ca99a752 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sat, 1 Aug 2015 22:56:03 +0200 Subject: [PATCH] Update source code style according to uncrustify --- args.c | 8 ++-- cleanup.c | 3 +- compopt.c | 8 ++-- conf.c | 10 ++--- dev.mk.in | 3 +- execute.c | 28 ++++++------ exitfn.c | 2 +- hash.c | 2 +- hashutil.c | 17 ++++--- language.c | 6 ++- manifest.c | 26 +++++------ mdfour.c | 10 +++-- murmurhashneutral2.c | 4 +- stats.c | 12 +++-- test/framework.c | 2 +- test/main.c | 16 +++---- test/test_args.c | 12 ++--- test/test_argument_processing.c | 42 +++++++++--------- test/test_conf.c | 78 +++++++++++++++++---------------- test/test_hash.c | 4 +- test/test_hashutil.c | 48 ++++++++++---------- test/test_util.c | 7 +-- unify.c | 8 ++-- util.c | 74 ++++++++++++++----------------- 24 files changed, 215 insertions(+), 215 deletions(-) diff --git a/args.c b/args.c index 91fc47e7b..a58848466 100644 --- a/args.c +++ b/args.c @@ -103,7 +103,7 @@ args_init_from_gcc_atfile(const char *filename) if (quoting) { break; } - /* Fall through */ + /* Fall through */ case '\0': /* end of token */ @@ -179,9 +179,9 @@ args_insert(struct args *dest, int index, struct args *src, bool replace) } dest->argv = (char **)x_realloc( - dest->argv, - (src->argc + dest->argc + 1 - offset) * - sizeof(char *)); + dest->argv, + (src->argc + dest->argc + 1 - offset) * + sizeof(char *)); /* Shift arguments over */ for (i = dest->argc; i >= index + offset; i--) { diff --git a/cleanup.c b/cleanup.c index 981423d9a..df945e7b6 100644 --- a/cleanup.c +++ b/cleanup.c @@ -68,7 +68,8 @@ traverse_fn(const char *fname, struct stat *st) } if (str_startswith(p, ".nfs")) { - /* Ignore temporary NFS files that may be left for open but deleted files. */ + /* Ignore temporary NFS files that may be left for open but deleted + * files. */ goto out; } diff --git a/compopt.c b/compopt.c index 26e15917b..f774fc16f 100644 --- a/compopt.c +++ b/compopt.c @@ -104,8 +104,8 @@ find(const char *option) struct compopt key; key.name = option; return bsearch( - &key, compopts, sizeof(compopts) / sizeof(compopts[0]), - sizeof(compopts[0]), compare_compopts); + &key, compopts, sizeof(compopts) / sizeof(compopts[0]), + sizeof(compopts[0]), compare_compopts); } static const struct compopt * @@ -114,8 +114,8 @@ find_prefix(const char *option) struct compopt key; key.name = option; return bsearch( - &key, compopts, sizeof(compopts) / sizeof(compopts[0]), - sizeof(compopts[0]), compare_prefix_compopts); + &key, compopts, sizeof(compopts) / sizeof(compopts[0]), + sizeof(compopts[0]), compare_prefix_compopts); } /* Runs fn on the first two characters of option. */ diff --git a/conf.c b/conf.c index 92c70c064..cc092f24d 100644 --- a/conf.c +++ b/conf.c @@ -157,7 +157,7 @@ parse_unsigned(const char *str, void *result, char **errmsg) } } -static const char* +static const char * bool_to_string(bool value) { return value ? "true" : "false"; @@ -193,9 +193,9 @@ verify_dir_levels(void *value, char **errmsg) } #define ITEM(name, type) \ - parse_##type, offsetof(struct conf, name), NULL + parse_ ## type, offsetof(struct conf, name), NULL #define ITEM_V(name, type, verification) \ - parse_##type, offsetof(struct conf, name), verify_##verification + parse_ ## type, offsetof(struct conf, name), verify_ ## verification #include "confitems_lookup.c" #include "envtoconfitems_lookup.c" @@ -438,8 +438,8 @@ conf_update_from_environment(struct conf *conf, char **errmsg) } if (!handle_conf_setting( - conf, env_to_conf_item->conf_name, q, &errmsg2, true, negate, - "environment")) { + conf, env_to_conf_item->conf_name, q, &errmsg2, true, negate, + "environment")) { *errmsg = format("%s: %s", key, errmsg2); free(errmsg2); free(key); diff --git a/dev.mk.in b/dev.mk.in index 635c57a55..1261ad3a8 100644 --- a/dev.mk.in +++ b/dev.mk.in @@ -89,7 +89,8 @@ dist_files = \ uncrustify_exclude_files = \ getopt_long.c \ hashtable.c \ - hashtable_itr.c + hashtable_itr.c \ + snprintf.c ifneq ($(shell sed 's/.*"\(.*\)".*/\1/' version.c 2>/dev/null),$(version)) $(shell echo 'const char CCACHE_VERSION[] = "$(version)";' >version.c) diff --git a/execute.c b/execute.c index 3b57a6971..f48e67cea 100644 --- a/execute.c +++ b/execute.c @@ -186,23 +186,23 @@ win32execute(char *path, char **argv, int doreturn, DWORD dw = GetLastError(); FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, - 0, NULL); + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, + 0, NULL); lpDisplayBuf = - (LPVOID) LocalAlloc(LMEM_ZEROINIT, - (lstrlen((LPCTSTR) lpMsgBuf) - + lstrlen((LPCTSTR) __FILE__) + 200) - * sizeof(TCHAR)); + (LPVOID) LocalAlloc(LMEM_ZEROINIT, + (lstrlen((LPCTSTR) lpMsgBuf) + + lstrlen((LPCTSTR) __FILE__) + 200) + * sizeof(TCHAR)); _snprintf((LPTSTR) lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), TEXT("%s failed with error %d: %s"), __FILE__, dw, lpMsgBuf); cc_log("can't execute %s; OS returned error: %s", - full_path_win_ext, (char*)lpDisplayBuf); + full_path_win_ext, (char *)lpDisplayBuf); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); @@ -220,10 +220,8 @@ win32execute(char *path, char **argv, int doreturn, #else -/* - execute a compiler backend, capturing all output to the given paths - the full path to the compiler to run is in argv[0] -*/ +/* Execute a compiler backend, capturing all output to the given paths the full + * path to the compiler to run is in argv[0]. */ int execute(char **argv, int fd_out, int fd_err) { @@ -264,7 +262,7 @@ execute(char **argv, int fd_out, int fd_err) /* * Find an executable by name in $PATH. Exclude any that are links to * exclude_name. -*/ + */ char * find_executable(const char *name, const char *exclude_name) { diff --git a/exitfn.c b/exitfn.c index 5d76eeead..29b7b9f16 100644 --- a/exitfn.c +++ b/exitfn.c @@ -33,7 +33,7 @@ static struct exit_function *exit_functions; static void call_nullary_exit_function(void *context) { - struct nullary_exit_function *p = (struct nullary_exit_function*)context; + struct nullary_exit_function *p = (struct nullary_exit_function *)context; p->function(); free(p); } diff --git a/hash.c b/hash.c index 795073789..6f23bb94d 100644 --- a/hash.c +++ b/hash.c @@ -86,7 +86,7 @@ hash_string(struct mdfour *md, const char *s) void hash_string_length(struct mdfour *md, const char *s, int length) { - hash_buffer(md, s, length); + hash_buffer(md, s, length); } void diff --git a/hashutil.c b/hashutil.c index b8103a630..6c4b2799f 100644 --- a/hashutil.c +++ b/hashutil.c @@ -43,7 +43,7 @@ int file_hashes_equal(struct file_hash *fh1, struct file_hash *fh2) { return memcmp(fh1->hash, fh2->hash, 16) == 0 - && fh1->size == fh2->size; + && fh1->size == fh2->size; } /* @@ -82,9 +82,8 @@ check_for_temporal_macros(const char *str, size_t len) if (str[i - 5] == 'D' && str[i - 4] == 'A' && str[i - 3] == 'T') { result |= HASH_SOURCE_CODE_FOUND_DATE; - } - else if (str[i - 5] == 'T' && str[i - 4] == 'I' && - str[i - 3] == 'M') { + } else if (str[i - 5] == 'T' && str[i - 4] == 'I' && + str[i - 3] == 'M') { result |= HASH_SOURCE_CODE_FOUND_TIME; } } @@ -104,8 +103,8 @@ check_for_temporal_macros(const char *str, size_t len) */ int hash_source_code_string( - struct conf *conf, struct mdfour *hash, const char *str, size_t len, - const char *path) + struct conf *conf, struct mdfour *hash, const char *str, size_t len, + const char *path) { int result = HASH_SOURCE_CODE_OK; @@ -223,9 +222,9 @@ hash_command_output(struct mdfour *hash, const char *command, CreatePipe(&pipe_out[0], &pipe_out[1], &sa, 0); SetHandleInformation(pipe_out[0], HANDLE_FLAG_INHERIT, 0); si.hStdOutput = pipe_out[1]; - si.hStdError = pipe_out[1]; - si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); - si.dwFlags = STARTF_USESTDHANDLES; + si.hStdError = pipe_out[1]; + si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); + si.dwFlags = STARTF_USESTDHANDLES; win32args = win32argvtos(sh, args->argv); ret = CreateProcess(path, win32args, NULL, NULL, 1, 0, NULL, NULL, &si, &pi); CloseHandle(pipe_out[1]); diff --git a/language.c b/language.c index 110066ac9..78c4a7d02 100644 --- a/language.c +++ b/language.c @@ -61,7 +61,8 @@ static const struct { {".HXX", "c++-header"}, {".tcc", "c++-header"}, {".TCC", "c++-header"}, - {NULL, NULL}}; + {NULL, NULL} +}; /* * Supported languages and corresponding preprocessed languages. @@ -84,7 +85,8 @@ static const struct { {"objc++-cpp-output", "objective-c++-cpp-output"}, {"objective-c++-header", "objective-c++-cpp-output"}, {"objective-c++-cpp-output", "objective-c++-cpp-output"}, - {NULL, NULL}}; + {NULL, NULL} +}; /* * Guess the language of a file based on its extension. Returns NULL if the diff --git a/manifest.c b/manifest.c index 1dcf83f68..8a0ecbbcb 100644 --- a/manifest.c +++ b/manifest.c @@ -71,7 +71,7 @@ static const uint32_t MAX_MANIFEST_ENTRIES = 100; static const uint32_t MAX_MANIFEST_FILE_INFO_ENTRIES = 10000; #define ccache_static_assert(e) \ - do { enum { ccache_static_assert__ = 1/(e) }; } while (false) + do { enum { ccache_static_assert__ = 1/(e) }; } while (false) struct file_info { /* Index to n_files. */ @@ -160,7 +160,7 @@ free_manifest(struct manifest *mf) } #define READ_BYTE(var) \ - do { \ + do { \ int ch_; \ ch_ = gzgetc(f); \ if (ch_ == EOF) { \ @@ -170,7 +170,7 @@ free_manifest(struct manifest *mf) } while (false) #define READ_INT(size, var) \ - do { \ + do { \ int ch_; \ size_t i_; \ (var) = 0; \ @@ -185,7 +185,7 @@ free_manifest(struct manifest *mf) } while (false) #define READ_STR(var) \ - do { \ + do { \ char buf_[1024]; \ size_t i_; \ int ch_; \ @@ -206,7 +206,7 @@ free_manifest(struct manifest *mf) } while (false) #define READ_BYTES(n, var) \ - do { \ + do { \ size_t i_; \ int ch_; \ for (i_ = 0; i_ < (n); i_++) { \ @@ -288,8 +288,8 @@ read_manifest(gzFile f) for (i = 0; i < mf->n_objects; i++) { READ_INT(4, mf->objects[i].n_file_info_indexes); mf->objects[i].file_info_indexes = - x_calloc(mf->objects[i].n_file_info_indexes, - sizeof(*mf->objects[i].file_info_indexes)); + x_calloc(mf->objects[i].n_file_info_indexes, + sizeof(*mf->objects[i].file_info_indexes)); for (j = 0; j < mf->objects[i].n_file_info_indexes; j++) { READ_INT(4, mf->objects[i].file_info_indexes[j]); } @@ -306,7 +306,7 @@ error: } #define WRITE_INT(size, var) \ - do { \ + do { \ uint8_t ch_; \ size_t i_; \ for (i_ = 0; i_ < (size); i_++) { \ @@ -318,14 +318,14 @@ error: } while (false) #define WRITE_STR(var) \ - do { \ + do { \ if (gzputs(f, var) == EOF || gzputc(f, '\0') == EOF) { \ goto error; \ } \ } while (false) #define WRITE_BYTES(n, var) \ - do { \ + do { \ size_t i_; \ for (i_ = 0; i_ < (n); i_++) { \ if (gzputc(f, (var)[i_]) == EOF) { \ @@ -415,8 +415,7 @@ verify_object(struct conf *conf, struct manifest *mf, struct object *obj, && MAX(st->mtime, st->ctime) >= time_of_compilation) { cc_log("size/mtime/ctime hit for %s", path); continue; - } - else { + } else { cc_log("size/mtime/ctime miss for %s", path); } } @@ -532,8 +531,7 @@ get_file_hash_index(struct manifest *mf, && time_of_compilation > MAX(file_stat.st_mtime, file_stat.st_ctime)) { fi.mtime = file_stat.st_mtime; fi.ctime = file_stat.st_ctime; - } - else { + } else { fi.mtime = -1; fi.ctime = -1; } diff --git a/mdfour.c b/mdfour.c index 06bc17fa6..43b5bb61b 100644 --- a/mdfour.c +++ b/mdfour.c @@ -30,8 +30,10 @@ static struct mdfour *m; #define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32))) #define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s) -#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s) -#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s) +#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c, \ + d) + M[k] + 0x5A827999)&MASK32,s) +#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c, \ + d) + M[k] + 0x6ED9EBA1)&MASK32,s) /* this applies md4 to 64 byte chunks */ static void @@ -88,7 +90,7 @@ copy64(uint32_t *M, const unsigned char *in) 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); + (in[i*4+1]<<8) | (in[i*4+0]<<0); #else memcpy(M, in, 16*4); #endif @@ -155,7 +157,7 @@ mdfour_update(struct mdfour *md, const unsigned char *in, size_t n) #ifdef CCACHE_DEBUG_HASH if (getenv("CCACHE_DEBUG_HASH")) { - FILE* f = fopen("ccache-debug-hash.bin", "a"); + FILE *f = fopen("ccache-debug-hash.bin", "a"); fwrite(in, 1, n, f); fclose(f); } diff --git a/murmurhashneutral2.c b/murmurhashneutral2.c index e625ba8b4..cd891335a 100644 --- a/murmurhashneutral2.c +++ b/murmurhashneutral2.c @@ -18,7 +18,7 @@ murmurhashneutral2(const void *key, int len, unsigned int seed) while (len >= 4) { unsigned int k; - k = data[0]; + k = data[0]; k |= data[1] << 8; k |= data[2] << 16; k |= data[3] << 24; @@ -39,7 +39,7 @@ murmurhashneutral2(const void *key, int len, unsigned int seed) case 3: h ^= data[2] << 16; case 2: h ^= data[1] << 8; case 1: h ^= data[0]; - h *= m; + h *= m; }; h ^= h >> 13; diff --git a/stats.c b/stats.c index 72985b46e..d6f428eea 100644 --- a/stats.c +++ b/stats.c @@ -78,10 +78,14 @@ static struct { { STATS_DEVICE, "output to a non-regular file ", NULL, 0 }, { STATS_NOINPUT, "no input file ", NULL, 0 }, { STATS_BADEXTRAFILE, "error hashing extra file ", NULL, 0 }, - { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS }, - { STATS_TOTALSIZE, "cache size ", display_size_times_1024 , FLAG_NOZERO|FLAG_ALWAYS }, - { STATS_OBSOLETE_MAXFILES, "OBSOLETE", NULL, FLAG_NOZERO|FLAG_NEVER}, - { STATS_OBSOLETE_MAXSIZE, "OBSOLETE", NULL, FLAG_NOZERO|FLAG_NEVER}, + { STATS_NUMFILES, "files in cache ", NULL, + FLAG_NOZERO|FLAG_ALWAYS }, + { STATS_TOTALSIZE, "cache size ", + display_size_times_1024, FLAG_NOZERO|FLAG_ALWAYS }, + { STATS_OBSOLETE_MAXFILES, "OBSOLETE", NULL, + FLAG_NOZERO|FLAG_NEVER}, + { STATS_OBSOLETE_MAXSIZE, "OBSOLETE", NULL, + FLAG_NOZERO|FLAG_NEVER}, { STATS_NONE, NULL, NULL, 0 } }; diff --git a/test/framework.c b/test/framework.c index 3590d032c..c15e2f025 100644 --- a/test/framework.c +++ b/test/framework.c @@ -39,7 +39,7 @@ static const char COLOR_END[] = "\x1b[m"; static const char COLOR_GREEN[] = "\x1b[32m"; static const char COLOR_RED[] = "\x1b[31m"; -#define COLOR(tty, color) ((tty) ? COLOR_##color : "") +#define COLOR(tty, color) ((tty) ? COLOR_ ## color : "") static int is_tty(int fd) diff --git a/test/main.c b/test/main.c index 82f96699c..15943cf53 100644 --- a/test/main.c +++ b/test/main.c @@ -24,23 +24,23 @@ #include "getopt_long.h" #endif -#define SUITE(name) unsigned suite_##name(unsigned); +#define SUITE(name) unsigned suite_ ## name(unsigned); #include "test/suites.h" #undef SUITE const char USAGE_TEXT[] = - "Usage:\n" - " test [options]\n" - "\n" - "Options:\n" - " -h, --help print this help text\n" - " -v, --verbose enable verbose logging of tests\n"; + "Usage:\n" + " test [options]\n" + "\n" + "Options:\n" + " -h, --help print this help text\n" + " -v, --verbose enable verbose logging of tests\n"; int main(int argc, char **argv) { suite_fn suites[] = { -#define SUITE(name) &suite_##name, +#define SUITE(name) &suite_ ## name, #include "test/suites.h" #undef SUITE NULL diff --git a/test/test_args.c b/test/test_args.c index 27c6fb9d0..d0a3bac55 100644 --- a/test/test_args.c +++ b/test/test_args.c @@ -64,8 +64,8 @@ TEST(args_init_from_gcc_atfile) { struct args *args; const char *argtext = - "first\rsec\\\tond\tthi\\\\rd\nfourth \tfif\\ th \"si'x\\\" th\"" - " 'seve\nth'\\"; + "first\rsec\\\tond\tthi\\\\rd\nfourth \tfif\\ th \"si'x\\\" th\"" + " 'seve\nth'\\"; create_file("gcc_atfile", argtext); @@ -198,13 +198,13 @@ TEST(args_insert) CHECK_INT_EQ(9, args->argc); args_insert(args, 1, src5, false); CHECK_STR_EQ_FREE2( - "first one alpha beta gamma second beta gamma fourth fifth", - args_to_string(args)); + "first one alpha beta gamma second beta gamma fourth fifth", + args_to_string(args)); CHECK_INT_EQ(10, args->argc); args_insert(args, 1, src6, false); CHECK_STR_EQ_FREE2( - "first one alpha beta gamma second beta gamma fourth fifth", - args_to_string(args)); + "first one alpha beta gamma second beta gamma fourth fifth", + args_to_string(args)); CHECK_INT_EQ(10, args->argc); args_free(args); diff --git a/test/test_argument_processing.c b/test/test_argument_processing.c index e0a447949..5f75654a0 100644 --- a/test/test_argument_processing.c +++ b/test/test_argument_processing.c @@ -79,7 +79,7 @@ TEST(preprocessor_only_flags_should_only_be_sent_to_the_preprocessor) " -include test.h -include-pch test.pch -iprefix . -iquote ." \ " -isysroot . -isystem . -iwithprefix . -iwithprefixbefore ." \ " -DTEST_MACRO -DTEST_MACRO2=1 -F. -trigraphs -fworking-directory" \ - " -fno-working-directory -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 "\ + " -fno-working-directory -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 " \ " -MQ mq1 -MQ mq2 -Wp,-MD,wpmd -Wp,-MMD,wpmmd" struct args *orig = args_init_from_string(CMD " -c foo.c -o foo.o"); struct args *exp_cpp = args_init_from_string(CMD); @@ -98,9 +98,9 @@ TEST(preprocessor_only_flags_should_only_be_sent_to_the_preprocessor) TEST(dependency_flags_that_take_an_argument_should_not_require_space_delimiter) { struct args *orig = args_init_from_string( - "cc -c -MMD -MFfoo.d -MT mt -MTmt -MQmq foo.c -o foo.o"); + "cc -c -MMD -MFfoo.d -MT mt -MTmt -MQmq foo.c -o foo.o"); struct args *exp_cpp = args_init_from_string( - "cc -MMD -MFfoo.d -MT mt -MTmt -MQmq"); + "cc -MMD -MFfoo.d -MT mt -MTmt -MQmq"); struct args *exp_cc = args_init_from_string("cc -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); @@ -137,9 +137,9 @@ TEST(sysroot_should_be_rewritten_if_basedir_is_used) TEST(MF_flag_with_immediate_argument_should_work_as_last_argument) { struct args *orig = args_init_from_string( - "cc -c foo.c -o foo.o -MMD -MT bar -MFfoo.d"); + "cc -c foo.c -o foo.o -MMD -MT bar -MFfoo.d"); struct args *exp_cpp = args_init_from_string( - "cc -MMD -MT bar -MFfoo.d"); + "cc -MMD -MT bar -MFfoo.d"); struct args *exp_cc = args_init_from_string("cc -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); @@ -154,9 +154,9 @@ TEST(MF_flag_with_immediate_argument_should_work_as_last_argument) TEST(MT_flag_with_immediate_argument_should_work_as_last_argument) { struct args *orig = args_init_from_string( - "cc -c foo.c -o foo.o -MMD -MFfoo.d -MT foo -MTbar"); + "cc -c foo.c -o foo.o -MMD -MFfoo.d -MT foo -MTbar"); struct args *exp_cpp = args_init_from_string( - "cc -MMD -MFfoo.d -MT foo -MTbar"); + "cc -MMD -MFfoo.d -MT foo -MTbar"); struct args *exp_cc = args_init_from_string("cc -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); @@ -171,9 +171,9 @@ TEST(MT_flag_with_immediate_argument_should_work_as_last_argument) TEST(MQ_flag_with_immediate_argument_should_work_as_last_argument) { struct args *orig = args_init_from_string( - "cc -c foo.c -o foo.o -MMD -MFfoo.d -MQ foo -MQbar"); + "cc -c foo.c -o foo.o -MMD -MFfoo.d -MQ foo -MQbar"); struct args *exp_cpp = args_init_from_string( - "cc -MMD -MFfoo.d -MQ foo -MQbar"); + "cc -MMD -MFfoo.d -MQ foo -MQbar"); struct args *exp_cc = args_init_from_string("cc -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); @@ -188,9 +188,9 @@ TEST(MQ_flag_with_immediate_argument_should_work_as_last_argument) TEST(MQ_flag_without_immediate_argument_should_not_add_MQobj) { struct args *orig = args_init_from_string( - "gcc -c -MD -MP -MFfoo.d -MQ foo.d foo.c"); + "gcc -c -MD -MP -MFfoo.d -MQ foo.d foo.c"); struct args *exp_cpp = args_init_from_string( - "gcc -MD -MP -MFfoo.d -MQ foo.d"); + "gcc -MD -MP -MFfoo.d -MQ foo.d"); struct args *exp_cc = args_init_from_string("gcc -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); @@ -205,9 +205,9 @@ TEST(MQ_flag_without_immediate_argument_should_not_add_MQobj) TEST(MT_flag_without_immediate_argument_should_not_add_MTobj) { struct args *orig = args_init_from_string( - "gcc -c -MD -MP -MFfoo.d -MT foo.d foo.c"); + "gcc -c -MD -MP -MFfoo.d -MT foo.d foo.c"); struct args *exp_cpp = args_init_from_string( - "gcc -MD -MP -MFfoo.d -MT foo.d"); + "gcc -MD -MP -MFfoo.d -MT foo.d"); struct args *exp_cc = args_init_from_string("gcc -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); @@ -222,9 +222,9 @@ TEST(MT_flag_without_immediate_argument_should_not_add_MTobj) TEST(MQ_flag_with_immediate_argument_should_not_add_MQobj) { struct args *orig = args_init_from_string( - "gcc -c -MD -MP -MFfoo.d -MQfoo.d foo.c"); + "gcc -c -MD -MP -MFfoo.d -MQfoo.d foo.c"); struct args *exp_cpp = args_init_from_string( - "gcc -MD -MP -MFfoo.d -MQfoo.d"); + "gcc -MD -MP -MFfoo.d -MQfoo.d"); struct args *exp_cc = args_init_from_string("gcc -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); @@ -239,9 +239,9 @@ TEST(MQ_flag_with_immediate_argument_should_not_add_MQobj) TEST(MT_flag_with_immediate_argument_should_not_add_MQobj) { struct args *orig = args_init_from_string( - "gcc -c -MD -MP -MFfoo.d -MTfoo.d foo.c"); + "gcc -c -MD -MP -MFfoo.d -MTfoo.d foo.c"); struct args *exp_cpp = args_init_from_string( - "gcc -MD -MP -MFfoo.d -MTfoo.d"); + "gcc -MD -MP -MFfoo.d -MTfoo.d"); struct args *exp_cc = args_init_from_string("gcc -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); @@ -256,7 +256,7 @@ TEST(MT_flag_with_immediate_argument_should_not_add_MQobj) TEST(fprofile_flag_with_existing_dir_should_be_rewritten_to_real_path) { struct args *orig = args_init_from_string( - "gcc -c -fprofile-generate=some/dir foo.c"); + "gcc -c -fprofile-generate=some/dir foo.c"); struct args *exp_cpp = args_init_from_string("gcc"); struct args *exp_cc = args_init_from_string("gcc"); struct args *act_cpp = NULL, *act_cc = NULL; @@ -281,11 +281,11 @@ TEST(fprofile_flag_with_existing_dir_should_be_rewritten_to_real_path) TEST(fprofile_flag_with_nonexisting_dir_not_be_rewritten) { struct args *orig = args_init_from_string( - "gcc -c -fprofile-generate=some/dir foo.c"); + "gcc -c -fprofile-generate=some/dir foo.c"); struct args *exp_cpp = args_init_from_string( - "gcc -fprofile-generate=some/dir"); + "gcc -fprofile-generate=some/dir"); struct args *exp_cc = args_init_from_string( - "gcc -fprofile-generate=some/dir -c"); + "gcc -fprofile-generate=some/dir -c"); struct args *act_cpp = NULL, *act_cc = NULL; create_file("foo.c", ""); diff --git a/test/test_conf.c b/test/test_conf.c index 46be7807a..df344c553 100644 --- a/test/test_conf.c +++ b/test/test_conf.c @@ -89,38 +89,38 @@ TEST(conf_read_valid_config) user = getenv("USER"); CHECK_STR_EQ("rabbit", user); create_file( - "ccache.conf", - "base_dir = /$USER/foo/${USER} \n" - "cache_dir=\n" - "cache_dir = $USER$/${USER}/.ccache\n" - "\n" - "\n" - " #A comment\n" - " cache_dir_levels = 4\n" - "\t compiler = foo\n" - "compiler_check = none\n" - "compression=true\n" - "compression_level= 2\n" - "cpp_extension = .foo\n" - "direct_mode = false\n" - "disable = true\n" - "extra_files_to_hash = a:b c:$USER\n" - "hard_link = true\n" - "hash_dir = true\n" - "log_file = $USER${USER} \n" - "max_files = 17\n" - "max_size = 123M\n" - "path = $USER.x\n" - "prefix_command = x$USER\n" - "read_only = true\n" - "read_only_direct = true\n" - "recache = true\n" - "run_second_cpp = true\n" - "sloppiness = file_macro ,time_macros, include_file_mtime,include_file_ctime,file_stat_matches pch_defines \n" - "stats = false\n" - "temporary_dir = ${USER}_foo\n" - "umask = 777\n" - "unify = true"); /* Note: no newline */ + "ccache.conf", + "base_dir = /$USER/foo/${USER} \n" + "cache_dir=\n" + "cache_dir = $USER$/${USER}/.ccache\n" + "\n" + "\n" + " #A comment\n" + " cache_dir_levels = 4\n" + "\t compiler = foo\n" + "compiler_check = none\n" + "compression=true\n" + "compression_level= 2\n" + "cpp_extension = .foo\n" + "direct_mode = false\n" + "disable = true\n" + "extra_files_to_hash = a:b c:$USER\n" + "hard_link = true\n" + "hash_dir = true\n" + "log_file = $USER${USER} \n" + "max_files = 17\n" + "max_size = 123M\n" + "path = $USER.x\n" + "prefix_command = x$USER\n" + "read_only = true\n" + "read_only_direct = true\n" + "recache = true\n" + "run_second_cpp = true\n" + "sloppiness = file_macro ,time_macros, include_file_mtime,include_file_ctime,file_stat_matches pch_defines \n" + "stats = false\n" + "temporary_dir = ${USER}_foo\n" + "umask = 777\n" + "unify = true"); /* Note: no newline */ CHECK(conf_read(conf, "ccache.conf", &errmsg)); CHECK(!errmsg); @@ -288,12 +288,14 @@ TEST(verify_dir_levels) create_file("ccache.conf", "cache_dir_levels = 0"); CHECK(!conf_read(conf, "ccache.conf", &errmsg)); - CHECK_STR_EQ_FREE2("ccache.conf:1: cache directory levels must be between 1 and 8", - errmsg); + CHECK_STR_EQ_FREE2( + "ccache.conf:1: cache directory levels must be between 1 and 8", + errmsg); create_file("ccache.conf", "cache_dir_levels = 9"); CHECK(!conf_read(conf, "ccache.conf", &errmsg)); - CHECK_STR_EQ_FREE2("ccache.conf:1: cache directory levels must be between 1 and 8", - errmsg); + CHECK_STR_EQ_FREE2( + "ccache.conf:1: cache directory levels must be between 1 and 8", + errmsg); conf_free(conf); } @@ -366,8 +368,8 @@ TEST(conf_print_items) true, true, SLOPPY_FILE_MACRO|SLOPPY_INCLUDE_FILE_MTIME| - SLOPPY_INCLUDE_FILE_CTIME|SLOPPY_TIME_MACROS| - SLOPPY_FILE_STAT_MATCHES, + SLOPPY_INCLUDE_FILE_CTIME|SLOPPY_TIME_MACROS| + SLOPPY_FILE_STAT_MATCHES, false, "td", 022, diff --git a/test/test_hash.c b/test/test_hash.c index b9d58fbd6..46f65db97 100644 --- a/test/test_hash.c +++ b/test/test_hash.c @@ -42,7 +42,9 @@ TEST(test_vectors_from_rfc_1320_should_be_correct) CHECK_STR_EQ_FREE2("d9130a8164549fe818874806e1c7014b-14", hash_result(&h)); hash_start(&h); - hash_string(&h, "12345678901234567890123456789012345678901234567890123456789012345678901234567890"); + hash_string( + &h, + "12345678901234567890123456789012345678901234567890123456789012345678901234567890"); CHECK_STR_EQ_FREE2("e33b4ddc9c38f2199c3e7b164fcc0536-80", hash_result(&h)); } diff --git a/test/test_hashutil.c b/test/test_hashutil.c index 98316f014..9b6fd3495 100644 --- a/test/test_hashutil.c +++ b/test/test_hashutil.c @@ -102,38 +102,38 @@ TEST(hash_multicommand_output_error_handling) TEST(check_for_temporal_macros) { const char time_start[] = - "__TIME__\n" - "int a;\n"; + "__TIME__\n" + "int a;\n"; const char time_middle[] = - "#define a __TIME__\n" - "int a;\n"; + "#define a __TIME__\n" + "int a;\n"; const char time_end[] = - "#define a __TIME__"; + "#define a __TIME__"; const char date_start[] = - "__DATE__\n" - "int ab;\n"; + "__DATE__\n" + "int ab;\n"; const char date_middle[] = - "#define ab __DATE__\n" - "int ab;\n"; + "#define ab __DATE__\n" + "int ab;\n"; const char date_end[] = - "#define ab __DATE__"; + "#define ab __DATE__"; const char no_temporal[] = - "#define ab _ _DATE__\n" - "#define ab __ DATE__\n" - "#define ab __D ATE__\n" - "#define ab __DA TE__\n" - "#define ab __DAT E__\n" - "#define ab __DATE __\n" - "#define ab __DATE_ _\n" - "#define ab _ _TIME__\n" - "#define ab __ TIME__\n" - "#define ab __T IME__\n" - "#define ab __TI ME__\n" - "#define ab __TIM E__\n" - "#define ab __TIME __\n" - "#define ab __TIME_ _\n"; + "#define ab _ _DATE__\n" + "#define ab __ DATE__\n" + "#define ab __D ATE__\n" + "#define ab __DA TE__\n" + "#define ab __DAT E__\n" + "#define ab __DATE __\n" + "#define ab __DATE_ _\n" + "#define ab _ _TIME__\n" + "#define ab __ TIME__\n" + "#define ab __T IME__\n" + "#define ab __TI ME__\n" + "#define ab __TIM E__\n" + "#define ab __TIME __\n" + "#define ab __TIME_ _\n"; CHECK(check_for_temporal_macros(time_start + 0, sizeof(time_start) - 0)); CHECK(!check_for_temporal_macros(time_start + 1, sizeof(time_start) - 1)); diff --git a/test/test_util.c b/test/test_util.c index 156789d63..395546fe9 100644 --- a/test/test_util.c +++ b/test/test_util.c @@ -77,7 +77,8 @@ TEST(get_relative_path) TEST(format_hash_as_string) { unsigned char hash[16] = { - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"}; + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + }; CHECK_STR_EQ_FREE2("00000000000000000000000000000000", format_hash_as_string(hash, -1)); @@ -154,8 +155,8 @@ TEST(format_parsable_size_with_suffix) CHECK_STR_EQ_FREE2("1.0G", format_parsable_size_with_suffix(1000 * 1000 * 1000)); CHECK_STR_EQ_FREE2( - "17.1G", - format_parsable_size_with_suffix(17.11 * 1000 * 1000 * 1000)); + "17.1G", + format_parsable_size_with_suffix(17.11 * 1000 * 1000 * 1000)); } TEST(parse_size_with_suffix) diff --git a/unify.c b/unify.c index 3128623db..6f19ea809 100644 --- a/unify.c +++ b/unify.c @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + */ /* * C/C++ unifier @@ -137,7 +137,7 @@ unify(struct mdfour *hash, unsigned char *p, size_t size) build_table(); - for (ofs = 0; ofs < size;) { + for (ofs = 0; ofs < size; ) { if (p[ofs] == '#') { if ((size-ofs) > 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) { do { @@ -169,7 +169,7 @@ unify(struct mdfour *hash, unsigned char *p, size_t size) pushchar(hash, p[ofs]); ofs++; } while (ofs < size && - ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.')); + ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.')); if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) { do { pushchar(hash, p[ofs]); @@ -246,7 +246,7 @@ unify(struct mdfour *hash, unsigned char *p, size_t size) /* hash a file that consists of preprocessor output, but remove any line number information from the hash -*/ + */ int unify_hash(struct mdfour *hash, const char *fname) { diff --git a/util.c b/util.c index 5cc9795cc..2526bbe49 100644 --- a/util.c +++ b/util.c @@ -74,7 +74,7 @@ log_prefix(bool log_updated_time) if (log_updated_time) { gettimeofday(&tv, NULL); #ifdef __MINGW64_VERSION_MAJOR - tm = localtime((time_t*)&tv.tv_sec); + tm = localtime((time_t *)&tv.tv_sec); #else tm = localtime(&tv.tv_sec); #endif @@ -569,22 +569,22 @@ get_hostname(void) DWORD dw = last_error; FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, 0, NULL); + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &lpMsgBuf, 0, NULL); lpDisplayBuf = (LPVOID) LocalAlloc( - LMEM_ZEROINIT, - (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) __FILE__) + 200) - * sizeof(TCHAR)); + LMEM_ZEROINIT, + (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) __FILE__) + 200) + * sizeof(TCHAR)); _snprintf((LPTSTR) lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), TEXT("%s failed with error %d: %s"), __FILE__, dw, lpMsgBuf); - cc_log("can't get hostname OS returned error: %s", (char*)lpDisplayBuf); + cc_log("can't get hostname OS returned error: %s", (char *)lpDisplayBuf); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); @@ -634,10 +634,10 @@ format_hash_as_string(const unsigned char *hash, int size) } char const CACHEDIR_TAG[] = - "Signature: 8a477f597d28d172789f06886806bc55\n" - "# This file is a cache directory tag created by ccache.\n" - "# For information about cache directory tags, see:\n" - "# http://www.brynosaurus.com/cachedir/\n"; + "Signature: 8a477f597d28d172789f06886806bc55\n" + "# This file is a cache directory tag created by ccache.\n" + "# For information about cache directory tags, see:\n" + "# http://www.brynosaurus.com/cachedir/\n"; int create_cachedirtag(const char *dir) @@ -690,9 +690,7 @@ format(const char *format, ...) return ptr; } -/* - this is like strdup() but dies if the malloc fails -*/ +/* This is like strdup() but dies if the malloc fails. */ char * x_strdup(const char *s) { @@ -704,9 +702,7 @@ x_strdup(const char *s) return ret; } -/* - this is like strndup() but dies if the malloc fails -*/ +/* This is like strndup() but dies if the malloc fails. */ char * x_strndup(const char *s, size_t n) { @@ -734,9 +730,7 @@ x_strndup(const char *s, size_t n) return ret; } -/* - this is like malloc() but dies if the malloc fails -*/ +/* This is like malloc() but dies if the malloc fails. */ void * x_malloc(size_t size) { @@ -774,9 +768,7 @@ x_calloc(size_t nmemb, size_t size) return ret; } -/* - this is like realloc() but dies if the malloc fails -*/ +/* This is like realloc() but dies if the malloc fails. */ void * x_realloc(void *ptr, size_t size) { @@ -1087,10 +1079,8 @@ parse_size_with_suffix(const char *str, uint64_t *size) } -/* - a sane realpath() function, trying to cope with stupid path limits and - a broken API -*/ +/* A sane realpath() function, trying to cope with stupid path limits and a + * broken API. */ char * x_realpath(const char *path) { @@ -1106,8 +1096,8 @@ x_realpath(const char *path) p = realpath(path, ret); #elif defined(_WIN32) path_handle = CreateFile( - path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); + path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE != path_handle) { GetFinalPathNameByHandle(path_handle, ret, maxlen, FILE_NAME_NORMALIZED); CloseHandle(path_handle); @@ -1171,7 +1161,7 @@ strtok_r(char *str, const char *delim, char **saveptr) ret = strtok(str, delim); if (ret) { char *save = ret; - while (*save++); + while (*save++) ; if ((len + 1) == (intptr_t) (save - str)) save--; *saveptr = save; @@ -1459,22 +1449,22 @@ x_rename(const char *oldpath, const char *newpath) DWORD dw = GetLastError(); FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, - 0, NULL); + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, + 0, NULL); lpDisplayBuf = (LPVOID) LocalAlloc( - LMEM_ZEROINIT, - (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) __FILE__) + 40) - * sizeof(TCHAR)); + LMEM_ZEROINIT, + (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) __FILE__) + 40) + * sizeof(TCHAR)); _snprintf((LPTSTR) lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), TEXT("%s failed with error %d: %s"), __FILE__, dw, lpMsgBuf); cc_log("can't rename file %s to %s OS returned error: %s", - oldpath, newpath, (char*) lpDisplayBuf); + oldpath, newpath, (char *) lpDisplayBuf); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); -- 2.47.2