]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Use double for limit_multiple
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 24 Oct 2018 20:10:41 +0000 (22:10 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 25 Oct 2018 19:27:31 +0000 (21:27 +0200)
This allows for removing the -Wno-double-promotion and
-Wno-float-conversion options which are not available for the clang
version currently used for “make analyze”.

configure.ac
src/conf.c
src/conf.h
src/confitems.c
src/confitems.gperf
src/confitems.h
src/confitems_lookup.c
src/stats.c
unittest/framework.c
unittest/framework.h
unittest/test_conf.c

index 5ac513453a102324233d713d1b6ce78a9a635d3a..d354ee18196691aa3f58b38eef42f7763d8cf757 100644 (file)
@@ -58,8 +58,6 @@ if test "$ac_compiler_clang" = yes; then
     more_warnings="$more_warnings -Weverything"
     more_warnings="$more_warnings -Wno-conversion"
     more_warnings="$more_warnings -Wno-disabled-macro-expansion"
-    more_warnings="$more_warnings -Wno-double-promotion"
-    more_warnings="$more_warnings -Wno-float-conversion"
     more_warnings="$more_warnings -Wno-format-nonliteral"
     more_warnings="$more_warnings -Wno-padded"
     more_warnings="$more_warnings -Wno-shorten-64-to-32"
index cd1b6dbd3b9e538079c815235a0255983db1a84a..b9ca0a2401a0152f82327f3fa16875d0e82c65f6 100644 (file)
@@ -138,7 +138,7 @@ conf_create(void)
        conf->hash_dir = true;
        conf->ignore_headers_in_manifest = x_strdup("");
        conf->keep_comments_cpp = false;
-       conf->limit_multiple = 0.8f;
+       conf->limit_multiple = 0.8;
        conf->log_file = x_strdup("");
        conf->max_files = 0;
        conf->max_size = (uint64_t)5 * 1000 * 1000 * 1000;
index 9c9e28f42cf02e98de4be994daac39a27a9a6b27..f45d09b58b9e2afc0ebe54b9c199b1119b8ef229 100644 (file)
@@ -20,7 +20,7 @@ struct conf {
        bool hash_dir;
        char *ignore_headers_in_manifest;
        bool keep_comments_cpp;
-       float limit_multiple;
+       double limit_multiple;
        char *log_file;
        unsigned max_files;
        uint64_t max_size;
index de6c8e1ae1e300ab60cf06ca4a0b8c0b0578e88f..6e6e22af4b845541647686f3e81c6b143f3450e3 100644 (file)
@@ -64,12 +64,12 @@ confitem_format_env_string(void *value)
 }
 
 bool
-confitem_parse_float(const char *str, void *result, char **errmsg)
+confitem_parse_double(const char *str, void *result, char **errmsg)
 {
-       float *value = (float *)result;
+       double *value = (double *)result;
        errno = 0;
        char *endptr;
-       float x = strtof(str, &endptr);
+       double x = strtod(str, &endptr);
        if (errno == 0 && *str != '\0' && *endptr == '\0') {
                *value = x;
                return true;
@@ -80,9 +80,9 @@ confitem_parse_float(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_float(void *value)
+confitem_format_double(void *value)
 {
-       float *x = (float *)value;
+       double *x = (double *)value;
        return format("%.1f", *x);
 }
 
index af9f82daae86a8a02a476d6dc0dc1e2d8db62de0..8d6a76756e827142add09cdcf82b3d468e7ae6f6 100644 (file)
@@ -36,7 +36,7 @@ hard_link,           12, ITEM(hard_link, bool)
 hash_dir,            13, ITEM(hash_dir, bool)
 ignore_headers_in_manifest, 14, ITEM(ignore_headers_in_manifest, env_string)
 keep_comments_cpp,   15, ITEM(keep_comments_cpp, bool)
-limit_multiple,      16, ITEM(limit_multiple, float)
+limit_multiple,      16, ITEM(limit_multiple, double)
 log_file,            17, ITEM(log_file, env_string)
 max_files,           18, ITEM(max_files, unsigned)
 max_size,            19, ITEM(max_size, size)
index e811b57927b31b149205c191287817cd734ea2a5..3ac501eac6d2b9302e291760f97d15708c0ff81a 100644 (file)
@@ -22,8 +22,8 @@ char *confitem_format_bool(void *value);
 bool confitem_parse_env_string(const char *str, void *result, char **errmsg);
 char *confitem_format_env_string(void *value);
 
-bool confitem_parse_float(const char *str, void *result, char **errmsg);
-char *confitem_format_float(void *value);
+bool confitem_parse_double(const char *str, void *result, char **errmsg);
+char *confitem_format_double(void *value);
 
 bool confitem_parse_size(const char *str, void *result, char **errmsg);
 char *confitem_format_size(void *value);
index 0e2c4fa3e8362ef3b4cbd468bdeaa3ac288ee87c..02a6efd7b20bc6c5ba459aae51e7bef15e2d9f03 100644 (file)
@@ -177,7 +177,7 @@ confitems_get (register const char *str, register size_t len)
       {"",0,0,NULL,NULL,NULL}, {"",0,0,NULL,NULL,NULL},
       {"",0,0,NULL,NULL,NULL}, {"",0,0,NULL,NULL,NULL},
 #line 39 "src/confitems.gperf"
-      {"limit_multiple",      16, ITEM(limit_multiple, float)},
+      {"limit_multiple",      16, ITEM(limit_multiple, double)},
       {"",0,0,NULL,NULL,NULL},
 #line 37 "src/confitems.gperf"
       {"ignore_headers_in_manifest", 14, ITEM(ignore_headers_in_manifest, env_string)}
index bfd79a8fd1529b69e900f4390c77c70a5654063a..51265aa252951b1e2b22eee0f87f0cd0ffa9ecd5 100644 (file)
@@ -515,7 +515,7 @@ stats_summary(void)
                        unsigned hit = direct + preprocessed;
                        unsigned miss = counters->data[STATS_TOCACHE];
                        unsigned total = hit + miss;
-                       double percent = total > 0 ? (100.0f * hit) / total : 0.0f;
+                       double percent = total > 0 ? (100.0 * hit) / total : 0.0;
                        printf("cache hit rate                    %6.2f %%\n", percent);
                }
        }
index 797822ffde0387c4e07928bb1b4acf3da14bba1f..3893f9149b716f8b477547cdb1960b5834c73412 100644 (file)
@@ -172,15 +172,15 @@ cct_check_failed(const char *file, int line, const char *what,
 }
 
 bool
-cct_check_float_eq(const char *file, int line, const char *expression,
-                   double expected, double actual)
+cct_check_double_eq(const char *file, int line, const char *expression,
+                    double expected, double actual)
 {
        if (fabs(expected -  actual) < DBL_EPSILON) {
                cct_check_passed(file, line, expression);
                return true;
        } else {
-               char *exp_str = format("%.1f", (double)expected);
-               char *act_str = format("%.1f", (double)actual);
+               char *exp_str = format("%.1f", expected);
+               char *act_str = format("%.1f", actual);
                cct_check_failed(file, line, expression, exp_str, act_str);
                free(exp_str);
                free(act_str);
index 317c2ca0f56f4757f1815e53f62df47d459fbc7c..b23abfb33a4790f5e7f7302efd66d33754c17eb0 100644 (file)
 
 // ============================================================================
 
-#define CHECK_FLOAT_EQ(expected, actual) \
+#define CHECK_DOUBLE_EQ(expected, actual) \
        do { \
-               if (!cct_check_float_eq(__FILE__, __LINE__, #actual, (expected), \
-                                     (actual))) { \
+               if (!cct_check_double_eq(__FILE__, __LINE__, #actual, (expected), \
+                                        (actual))) { \
                        cct_test_end(); \
                        cct_suite_end(); \
                        return _test_counter; \
@@ -135,8 +135,8 @@ void cct_test_end(void);
 void cct_check_passed(const char *file, int line, const char *assertion);
 void cct_check_failed(const char *file, int line, const char *assertion,
                       const char *expected, const char *actual);
-bool cct_check_float_eq(const char *file, int line, const char *expression,
-                        double expected, double actual);
+bool cct_check_double_eq(const char *file, int line, const char *expression,
+                         double expected, double actual);
 bool cct_check_int_eq(const char *file, int line, const char *expression,
                       int64_t expected, int64_t actual);
 bool cct_check_str_eq(const char *file, int line, const char *expression,
index 9938adda6caaa48e86393f0d42382ac6da46a9c3..849a2c0b4c62cdf14bbc05853fab9b4639b2135e 100644 (file)
@@ -66,7 +66,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_DOUBLE_EQ(0.8, 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);
@@ -157,7 +157,7 @@ TEST(conf_read_valid_config)
        CHECK(!conf->hash_dir);
        CHECK_STR_EQ("a:b/c", conf->ignore_headers_in_manifest);
        CHECK(conf->keep_comments_cpp);
-       CHECK_FLOAT_EQ(1.0, conf->limit_multiple);
+       CHECK_DOUBLE_EQ(1.0, conf->limit_multiple);
        CHECK_STR_EQ_FREE1(format("%s%s", user, user), conf->log_file);
        CHECK_INT_EQ(17, conf->max_files);
        CHECK_INT_EQ(123 * 1000 * 1000, conf->max_size);