From: Anders F Björklund Date: Sun, 8 Apr 2018 13:28:58 +0000 (+0200) Subject: Convert float config to double, add rounding X-Git-Tag: v3.4.3~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=390035abfa4e174ac0b1528435e2d001d39654a8;p=thirdparty%2Fccache.git Convert float config to double, add rounding We were getting different results when converting "float" to integers, on 32-bit versus 64-bit platforms. So use "roundf". Also exposed a typo in another testsuite, where we only cleaned files as a result of roundoff... Make cleaning explicit again. --- diff --git a/src/cleanup.c b/src/cleanup.c index 1fc78e27f..dbb657843 100644 --- a/src/cleanup.c +++ b/src/cleanup.c @@ -17,6 +17,9 @@ #include "ccache.h" +#include +#include + static struct files { char *fname; time_t mtime; @@ -162,8 +165,8 @@ clean_up_dir(struct conf *conf, const char *dir, float 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 * limit_multiple / 16; - files_in_cache_threshold = conf->max_files * limit_multiple / 16; + cache_size_threshold = roundf(conf->max_size * limit_multiple / 16); + files_in_cache_threshold = roundf(conf->max_files * limit_multiple / 16); num_files = 0; cache_size = 0; diff --git a/test/suites/cleanup.bash b/test/suites/cleanup.bash index 8eaac4f6e..45dccb083 100644 --- a/test/suites/cleanup.bash +++ b/test/suites/cleanup.bash @@ -152,7 +152,7 @@ SUITE_cleanup() { TEST ".o file is removed before .stderr" prepare_cleanup_test_dir $CCACHE_DIR/a - $CCACHE -F 474 -M 0 >/dev/null + $CCACHE -F 464 -M 0 >/dev/null backdate 0 $CCACHE_DIR/a/result9-4017.stderr $CCACHE -c >/dev/null expect_file_missing $CCACHE_DIR/a/result9-4017.stderr @@ -167,7 +167,7 @@ SUITE_cleanup() { TEST ".stderr file is not removed before .o" prepare_cleanup_test_dir $CCACHE_DIR/a - $CCACHE -F 474 -M 0 >/dev/null + $CCACHE -F 464 -M 0 >/dev/null backdate 0 $CCACHE_DIR/a/result9-4017.o $CCACHE -c >/dev/null expect_file_exists $CCACHE_DIR/a/result9-4017.stderr