From: Havard Graff Date: Tue, 24 Apr 2018 20:05:01 +0000 (+0200) Subject: Fix some casting warnings X-Git-Tag: v3.5~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f160d60c87e75183cbedcfb5cffb5650dea366b;p=thirdparty%2Fccache.git Fix some casting warnings --- diff --git a/src/cleanup.c b/src/cleanup.c index 969b8d2bc..20dc77f78 100644 --- a/src/cleanup.c +++ b/src/cleanup.c @@ -164,8 +164,8 @@ clean_up_dir(struct conf *conf, const char *dir, double 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 = round(conf->max_size * limit_multiple / 16); - files_in_cache_threshold = round(conf->max_files * limit_multiple / 16); + cache_size_threshold = (uint64_t)round(conf->max_size * limit_multiple / 16); + files_in_cache_threshold = (size_t)round(conf->max_files * limit_multiple / 16); num_files = 0; cache_size = 0; diff --git a/src/conf.c b/src/conf.c index fbc06af77..0ba5e2c11 100644 --- a/src/conf.c +++ b/src/conf.c @@ -377,7 +377,7 @@ conf_free(struct conf *conf) free(conf->prefix_command); free(conf->prefix_command_cpp); free(conf->temporary_dir); - free(conf->item_origins); + free((void *)conf->item_origins); /* Workaround for MSVC warning */ free(conf); } diff --git a/src/hashtable.c b/src/hashtable.c index 02ab45427..29cf78ab5 100644 --- a/src/hashtable.c +++ b/src/hashtable.c @@ -51,7 +51,7 @@ static const unsigned int primes[] = { 805306457, 1610612741 }; const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]); -const float max_load_factor = 0.65; +const float max_load_factor = 0.65f; /*****************************************************************************/ struct hashtable * diff --git a/src/snprintf.c b/src/snprintf.c index b935ee930..bc72a5f33 100644 --- a/src/snprintf.c +++ b/src/snprintf.c @@ -1202,7 +1202,7 @@ again: * Factor of ten with the number of digits needed for the fractional * part. For example, if the precision is 3, the mask will be 1000. */ - mask = mypow10(precision); + mask = (UINTMAX_T)mypow10(precision); /* * We "cheat" by converting the fractional part to integer by * multiplying by a factor of ten. @@ -1454,7 +1454,7 @@ cast(LDOUBLE value) if (value >= UINTMAX_MAX) return UINTMAX_MAX; - result = value; + result = (UINTMAX_T)value; /* * At least on NetBSD/sparc64 3.0.2 and 4.99.30, casting long double to * an integer type converts e.g. 1.9 to 2 instead of 1 (which violates diff --git a/src/util.c b/src/util.c index dcb8f658e..e86323175 100644 --- a/src/util.c +++ b/src/util.c @@ -983,7 +983,7 @@ parse_size_with_suffix(const char *str, uint64_t *size) // Default suffix: G. x *= 1000 * 1000 * 1000; } - *size = x; + *size = (uint64_t)x; return true; }