diff options
author | Jim Meyering <meyering@fb.com> | 2020-12-29 19:34:55 -0800 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2020-12-29 19:36:50 -0800 |
commit | 7fa203018d02d8f2b71a6be1240c3963a63cab1c (patch) | |
tree | 49896c10960f3c06436bb12eea87849321f32c21 /lib/hash.c | |
parent | 649e713c1e5452204253cb1029ea22c1b6effa2e (diff) | |
download | gnulib-7fa203018d02d8f2b71a6be1240c3963a63cab1c.tar.gz |
hash: add casts-to-float to avoid clang-10 warnings
* lib/hash.c (compute_bucket_size): Cast SIZE_MAX to float
to avoid this warning from clang-10 (for use in grep):
hash.c:501:11: error: implicit conversion from 'unsigned long' \
to 'float' changes value from 18446744073709551615 to \
18446744073709551616 [-Werror,-Wimplicit-int-float-conversion]
if (SIZE_MAX <= new_candidate)
(hash_insert_if_absent): Likewise.
Diffstat (limited to 'lib/hash.c')
-rw-r--r-- | lib/hash.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/hash.c b/lib/hash.c index 2d64c82e59..e5ae96ce60 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -498,7 +498,7 @@ compute_bucket_size (size_t candidate, const Hash_tuning *tuning) if (!tuning->is_n_buckets) { float new_candidate = candidate / tuning->growth_threshold; - if (SIZE_MAX <= new_candidate) + if ((float) SIZE_MAX <= new_candidate) return 0; candidate = new_candidate; } @@ -961,7 +961,7 @@ hash_insert_if_absent (Hash_table *table, void const *entry, : (table->n_buckets * tuning->growth_factor * tuning->growth_threshold)); - if (SIZE_MAX <= candidate) + if ((float) SIZE_MAX <= candidate) return -1; /* If the rehash fails, arrange to return NULL. */ |