From: Joel Rosdahl Date: Fri, 29 Jul 2016 15:51:44 +0000 (+0200) Subject: Clean up after a8ca6ad3 X-Git-Tag: v3.3~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e5ad447c074366d78a5dc6137c63d91a030510d;p=thirdparty%2Fccache.git Clean up after a8ca6ad3 --- diff --git a/MANUAL.txt b/MANUAL.txt index 47a5e9294..d42e21c91 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -399,8 +399,8 @@ WRAPPERS>>. *limit_multiple* (*CCACHE_LIMIT_MULTIPLE*):: - Sets the limit when cleaning up. Files are deleted (in LRU order) - until the levels are below the limit. The default is 0.8 (= 80%). + Sets the limit when cleaning up. Files are deleted (in LRU order) until the + levels are below the limit. The default is 0.8 (= 80%). *log_file* (*CCACHE_LOGFILE*):: diff --git a/ccache.c b/ccache.c index aa749a3a8..20ab1aa1f 100644 --- a/ccache.c +++ b/ccache.c @@ -3143,8 +3143,7 @@ ccache(int argc, char *argv[]) conf->direct_mode = false; } - if (conf->limit_multiple < 0.0) conf->limit_multiple = 0.0; - if (conf->limit_multiple > 1.0) conf->limit_multiple = 1.0; + conf->limit_multiple = MIN(MAX(conf->limit_multiple, 0.0), 1.0); // Arguments (except -E) to send to the preprocessor. struct args *preprocessor_args; diff --git a/ccache.h b/ccache.h index 7ab03212f..f0839b3d8 100644 --- a/ccache.h +++ b/ccache.h @@ -287,5 +287,8 @@ void add_exe_ext_if_no_to_fullpath(char *full_path_win_ext, size_t max_size, #ifndef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif #endif // ifndef CCACHE_H diff --git a/cleanup.c b/cleanup.c index db37bb1bc..428a64b52 100644 --- a/cleanup.c +++ b/cleanup.c @@ -174,11 +174,9 @@ cleanup_dir(struct conf *conf, const char *dir) { cc_log("Cleaning up cache directory %s", dir); - /* - * When "max files" or "max cache size" is reached, one of the 16 cache - * subdirectories is cleaned up. When doing so, files are deleted (in LRU - * order) until the levels are below limit_multiple. - */ + // When "max files" or "max cache size" is reached, one of the 16 cache + // subdirectories is cleaned up. When doing so, files are deleted (in LRU + // order) until the levels are below limit_multiple. cache_size_threshold = conf->max_size * conf->limit_multiple / 16; files_in_cache_threshold = conf->max_files * conf->limit_multiple / 16; diff --git a/conf.c b/conf.c index 1dad62b30..97cef2f26 100644 --- a/conf.c +++ b/conf.c @@ -63,10 +63,9 @@ static bool parse_float(const char *str, void *result, char **errmsg) { float *value = (float *)result; - float x; - char *endptr; errno = 0; - x = strtof(str, &endptr); + char *endptr; + float x = strtof(str, &endptr); if (errno == 0 && *str != '\0' && *endptr == '\0') { *value = x; return true; @@ -580,7 +579,7 @@ conf_print_items(struct conf *conf, printer(s, conf->item_origins[find_conf( "keep_comments_cpp")->number], context); - reformat(&s, "limit_multiple = %.1f", (double) conf->limit_multiple); + reformat(&s, "limit_multiple = %.1f", (double)conf->limit_multiple); printer(s, conf->item_origins[find_conf("limit_multiple")->number], context); reformat(&s, "log_file = %s", conf->log_file); diff --git a/test/framework.h b/test/framework.h index 3980a66bf..d1aa6a715 100644 --- a/test/framework.h +++ b/test/framework.h @@ -82,6 +82,8 @@ } \ } while (false) +// ============================================================================ + #define CHECK_FLOAT_EQ(expected, actual) \ do { \ if (!cct_check_float_eq(__FILE__, __LINE__, #actual, (expected), \ diff --git a/test/test_conf.c b/test/test_conf.c index 511c41f42..ea43e2efe 100644 --- a/test/test_conf.c +++ b/test/test_conf.c @@ -64,6 +64,7 @@ TEST(conf_create) CHECK(conf->hash_dir); CHECK_STR_EQ("", conf->ignore_headers_in_manifest); CHECK(!conf->keep_comments_cpp); + CHECK_FLOAT_EQ(0.8f, conf->limit_multiple); CHECK_STR_EQ("", conf->log_file); CHECK_INT_EQ(0, conf->max_files); CHECK_INT_EQ((uint64_t)5 * 1000 * 1000 * 1000, conf->max_size);