d8307d
commit 5abcddd7949270998c6e8d99fdbbba821b664f8b
d8307d
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
d8307d
Date:   Thu Mar 21 17:24:30 2019 -0300
d8307d
d8307d
    Fix parentheses error in iconvconfig.c and ld-collate.c [BZ #24372]
d8307d
    
d8307d
    When -Werror=parentheses is in use, iconvconfig.c builds fail with:
d8307d
    
d8307d
      iconvconfig.c: In function ‘write_output’:
d8307d
      iconvconfig.c:1084:34: error: suggest parentheses around ‘+’ inside ‘>>’ [-Werror=parentheses]
d8307d
         hash_size = next_prime (nnames + nnames >> 1);
d8307d
                                 ~~~~~~~^~~~~~~~
d8307d
    
d8307d
    This patch adds parentheses to the expression.  Not where suggested by
d8307d
    the compiler warning, but where it produces the expected result, i.e.:
d8307d
    where it has the effect of multiplying nnames by 1.5.
d8307d
    
d8307d
    Likewise for elem_size in ld-collate.c.
d8307d
    
d8307d
    Tested for powerpc64le.
d8307d
    
d8307d
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
d8307d
d8307d
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
d8307d
index 696fc8d31231ca2d..b6fef1553cbbdd3d 100644
d8307d
--- a/iconv/iconvconfig.c
d8307d
+++ b/iconv/iconvconfig.c
d8307d
@@ -1081,7 +1081,7 @@ write_output (void)
d8307d
      Creating a perfect hash table is not reasonable here.  Therefore
d8307d
      we use open hashing and a table size which is the next prime 50%
d8307d
      larger than the number of strings.  */
d8307d
-  hash_size = next_prime (nnames + nnames >> 1);
d8307d
+  hash_size = next_prime (nnames + (nnames >> 1));
d8307d
   hash_table = (struct hash_entry *) xcalloc (hash_size,
d8307d
 					      sizeof (struct hash_entry));
d8307d
   /* Fill the hash table.  */
d8307d
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
d8307d
index 9a1639b999d0e2aa..a5530655fd5638b5 100644
d8307d
--- a/locale/programs/ld-collate.c
d8307d
+++ b/locale/programs/ld-collate.c
d8307d
@@ -2402,7 +2402,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
d8307d
       runp = runp->next;
d8307d
     }
d8307d
   /* Add 50% and find the next prime number.  */
d8307d
-  elem_size = next_prime (elem_size + elem_size >> 1);
d8307d
+  elem_size = next_prime (elem_size + (elem_size >> 1));
d8307d
 
d8307d
   /* Allocate the table.  Each entry consists of two words: the hash
d8307d
      value and an index in a secondary table which provides the index