]> Savannah Git Hosting - gnulib.git/commitdiff
hash: add casts-to-float to avoid clang-10 warnings
authorJim Meyering <meyering@fb.com>
Wed, 30 Dec 2020 03:34:55 +0000 (19:34 -0800)
committerJim Meyering <meyering@fb.com>
Wed, 30 Dec 2020 03:36:50 +0000 (19:36 -0800)
* 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.

ChangeLog
lib/hash.c

index 2af7a42c79001724f04a59abfd3fd7e6aadd2769..cc4e45665574db07c1a8ef08932ee0284c2e7435 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-12-29  Jim Meyering  <meyering@fb.com>
+
+       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.
+
 2020-12-29  Paul Eggert  <eggert@cs.ucla.edu>
 
        canonicalize: fix size overflow treatment
index 2d64c82e59ec4d339b3445b4df64c9a50f021b7b..e5ae96ce6002c4da66e33334e4782166ddcbc599 100644 (file)
@@ -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.  */