]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Clean up after a8ca6ad3
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 29 Jul 2016 15:51:44 +0000 (17:51 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 29 Jul 2016 16:26:41 +0000 (18:26 +0200)
MANUAL.txt
ccache.c
ccache.h
cleanup.c
conf.c
test/framework.h
test/test_conf.c

index 47a5e92947ff774b41fd20aa059cf3c5a6ddd923..d42e21c91ebb3bcacf03d730323cdfcb0164b150 100644 (file)
@@ -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*)::
 
index aa749a3a83ab247ec32f45a74abe368bc7c48e06..20ab1aa1fcf9174959bcaa389c13009ac6c9f722 100644 (file)
--- 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;
index 7ab03212f605b2658212c0cb999c99a20b360286..f0839b3d807551dc983b80dc88b98674aeb0280c 100644 (file)
--- 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
index db37bb1bcaaf670c7af8081b1ed68bb29094730f..428a64b52b4dcb5072833c5d14f18938dc976e08 100644 (file)
--- 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 1dad62b302b5275bbcc3ce4a27a49e01782e2c9b..97cef2f269320458189cb5c386c7ac35893de1bc 100644 (file)
--- 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);
index 3980a66bf7c8668d36e10093d7089f26ad2e180e..d1aa6a715a5946ddbf4434f078ac89990d9df8d1 100644 (file)
@@ -82,6 +82,8 @@
                } \
        } while (false)
 
+// ============================================================================
+
 #define CHECK_FLOAT_EQ(expected, actual) \
        do { \
                if (!cct_check_float_eq(__FILE__, __LINE__, #actual, (expected), \
index 511c41f4290c35ae9e2fa15215b2115d94676928..ea43e2efe153182285d49c56ff0158ef3d199247 100644 (file)
@@ -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);