From: Joel Rosdahl Date: Sat, 16 Jul 2011 15:57:52 +0000 (+0200) Subject: config: Use log_file from conf struct X-Git-Tag: v3.2~222 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5dae03bd122764707429035745bf83643c628323;p=thirdparty%2Fccache.git config: Use log_file from conf struct --- diff --git a/ccache.c b/ccache.c index 0deaaf42b..45d214be6 100644 --- a/ccache.c +++ b/ccache.c @@ -76,9 +76,6 @@ struct conf *conf = NULL; /* current working directory taken from $PWD, or getcwd() if $PWD is bad */ char *current_working_dir = NULL; -/* the debug logfile name, if set */ -char *cache_logfile = NULL; - /* the original argument list */ static struct args *orig_args; @@ -1829,8 +1826,6 @@ initialize(void) exitfn_add_nullary(stats_flush); exitfn_add_nullary(clean_up_tmp_files); - /* check for logging early so cc_log messages start working ASAP */ - cache_logfile = getenv("CCACHE_LOGFILE"); cc_log("=== CCACHE STARTED ========================================="); /* the user might have set CCACHE_UMASK */ @@ -1853,7 +1848,6 @@ cc_reset(void) { conf_free(conf); conf = NULL; free(current_working_dir); current_working_dir = NULL; - cache_logfile = NULL; args_free(orig_args); orig_args = NULL; free(input_file); input_file = NULL; free(output_obj); output_obj = NULL; diff --git a/stats.c b/stats.c index 511456900..3d02c2d69 100644 --- a/stats.c +++ b/stats.c @@ -204,7 +204,6 @@ stats_flush(void) bool need_cleanup = false; bool should_flush = false; int i; - extern char *cache_logfile; if (getenv("CCACHE_NOSTATS")) return; @@ -225,6 +224,7 @@ stats_flush(void) * A NULL stats_file means that we didn't get past calculate_object_hash(), * so we just choose one of stats files in the 16 subdirectories. */ + assert(conf); stats_dir = format("%s/%x", conf->cache_dir, hash_from_int(getpid()) % 16); stats_file = format("%s/stats", stats_dir); free(stats_dir); @@ -241,7 +241,7 @@ stats_flush(void) stats_write(stats_file, counters); lockfile_release(stats_file); - if (cache_logfile) { + if (!str_eq(conf->log_file, "")) { for (i = 0; i < STATS_END; ++i) { if (counter_updates->data[stats_info[i].stat] != 0 && !(stats_info[i].flags & FLAG_NOZERO)) { diff --git a/test/framework.c b/test/framework.c index c366afeec..85b4bd4b1 100644 --- a/test/framework.c +++ b/test/framework.c @@ -115,8 +115,6 @@ cct_suite_end() void cct_test_begin(const char *name) { - extern char *cache_logfile; - ++total_tests; if (verbose) { printf("--- TEST: %s ---\n", name); @@ -128,7 +126,6 @@ cct_test_begin(const char *name) putenv("CCACHE_CONFIG_PATH=/dev/null"); cc_reset(); - cache_logfile = getenv("CCACHE_LOGFILE"); } void diff --git a/util.c b/util.c index 810ccc7fb..6f8b35f7f 100644 --- a/util.c +++ b/util.c @@ -18,6 +18,7 @@ */ #include "ccache.h" +#include "conf.h" #include @@ -38,15 +39,16 @@ static FILE *logfile; static bool init_log(void) { - extern char *cache_logfile; + extern struct conf *conf; if (logfile) { return true; } - if (!cache_logfile) { + assert(conf); + if (str_eq(conf->log_file, "")) { return false; } - logfile = fopen(cache_logfile, "a"); + logfile = fopen(conf->log_file, "a"); if (logfile) { return true; } else {