diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2018-10-24 22:10:41 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2018-10-25 21:27:31 +0200 |
commit | dc5dce04cb4d0d31f755763a010abb5631226c35 (patch) | |
tree | 90acc4ae8625cb88ccc6cb6698ecef5b049241f0 | |
parent | 7295e5d0a2fcd0328f00f80ac044b75b9df80326 (diff) | |
download | ccache-dc5dce04cb4d0d31f755763a010abb5631226c35.tar.gz |
Use double for limit_multiple
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”.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/conf.c | 2 | ||||
-rw-r--r-- | src/conf.h | 2 | ||||
-rw-r--r-- | src/confitems.c | 10 | ||||
-rw-r--r-- | src/confitems.gperf | 2 | ||||
-rw-r--r-- | src/confitems.h | 4 | ||||
-rw-r--r-- | src/confitems_lookup.c | 2 | ||||
-rw-r--r-- | src/stats.c | 2 | ||||
-rw-r--r-- | unittest/framework.c | 8 | ||||
-rw-r--r-- | unittest/framework.h | 10 | ||||
-rw-r--r-- | unittest/test_conf.c | 4 |
11 files changed, 23 insertions, 25 deletions
diff --git a/configure.ac b/configure.ac index 5ac51345..d354ee18 100644 --- a/configure.ac +++ b/configure.ac @@ -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" @@ -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; @@ -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; diff --git a/src/confitems.c b/src/confitems.c index de6c8e1a..6e6e22af 100644 --- a/src/confitems.c +++ b/src/confitems.c @@ -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); } diff --git a/src/confitems.gperf b/src/confitems.gperf index af9f82da..8d6a7675 100644 --- a/src/confitems.gperf +++ b/src/confitems.gperf @@ -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) diff --git a/src/confitems.h b/src/confitems.h index e811b579..3ac501ea 100644 --- a/src/confitems.h +++ b/src/confitems.h @@ -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); diff --git a/src/confitems_lookup.c b/src/confitems_lookup.c index 0e2c4fa3..02a6efd7 100644 --- a/src/confitems_lookup.c +++ b/src/confitems_lookup.c @@ -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)} diff --git a/src/stats.c b/src/stats.c index bfd79a8f..51265aa2 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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); } } diff --git a/unittest/framework.c b/unittest/framework.c index 797822ff..3893f914 100644 --- a/unittest/framework.c +++ b/unittest/framework.c @@ -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); diff --git a/unittest/framework.h b/unittest/framework.h index 317c2ca0..b23abfb3 100644 --- a/unittest/framework.h +++ b/unittest/framework.h @@ -85,10 +85,10 @@ // ============================================================================ -#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, diff --git a/unittest/test_conf.c b/unittest/test_conf.c index 9938adda..849a2c0b 100644 --- a/unittest/test_conf.c +++ b/unittest/test_conf.c @@ -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); |