]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix parentheses error in iconvconfig.c and ld-collate.c [BZ #24372]
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Thu, 21 Mar 2019 20:24:30 +0000 (17:24 -0300)
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Thu, 21 Mar 2019 20:53:03 +0000 (17:53 -0300)
When -Werror=parentheses is in use, iconvconfig.c builds fail with:

  iconvconfig.c: In function ‘write_output’:
  iconvconfig.c:1084:34: error: suggest parentheses around ‘+’ inside ‘>>’ [-Werror=parentheses]
     hash_size = next_prime (nnames + nnames >> 1);
                             ~~~~~~~^~~~~~~~

This patch adds parentheses to the expression.  Not where suggested by
the compiler warning, but where it produces the expected result, i.e.:
where it has the effect of multiplying nnames by 1.5.

Likewise for elem_size in ld-collate.c.

Tested for powerpc64le.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
ChangeLog
iconv/iconvconfig.c
locale/programs/ld-collate.c

index ba9b6151ed0c9a558aee28fcac16d92414efba71..f0ebd06b3688ada0e85b981f0fcbd451deef79ee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-03-05  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
+
+       [BZ #24372]
+       * iconv/iconvconfig.c (write_output): Add parentheses to get rid
+       of compiler warning.
+       * locale/programs/ld-collate.c (collate_output): Likewise.
+
 2019-03-21  DJ Delorie  <dj@redhat.com>
 
        [BZ #24372]
index 1e6066cdf0ddff33a146b4ee83f0160509eb3ef3..f75e46dc1668a5703fe330382d8917e892687195 100644 (file)
@@ -1081,7 +1081,7 @@ write_output (void)
      Creating a perfect hash table is not reasonable here.  Therefore
      we use open hashing and a table size which is the next prime 50%
      larger than the number of strings.  */
-  hash_size = next_prime (nnames + nnames >> 1);
+  hash_size = next_prime (nnames + (nnames >> 1));
   hash_table = (struct hash_entry *) xcalloc (hash_size,
                                              sizeof (struct hash_entry));
   /* Fill the hash table.  */
index 19b23c2453860a9c2e970d177c6f31a2e4e35afc..6baab6cfb0cc0b1cdd77213e41766a27480dd1e0 100644 (file)
@@ -2402,7 +2402,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
       runp = runp->next;
     }
   /* Add 50% and find the next prime number.  */
-  elem_size = next_prime (elem_size + elem_size >> 1);
+  elem_size = next_prime (elem_size + (elem_size >> 1));
 
   /* Allocate the table.  Each entry consists of two words: the hash
      value and an index in a secondary table which provides the index