Simplify power of two test

Message ID 20191015061412.GO10114@bubble.grove.modra.org
State New
Headers show
Series
  • Simplify power of two test
Related show

Commit Message

Alan Modra Oct. 15, 2019, 6:14 a.m.
* bfd.c (bfd_check_compression_header): Check for powers of two
	with x == (x & -x).


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/bfd/bfd.c b/bfd/bfd.c
index af2c192260..b3078eaa52 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2635,7 +2635,7 @@  bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
 	  chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign);
 	}
       if (chdr.ch_type == ELFCOMPRESS_ZLIB
-	  && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign)))
+	  && chdr.ch_addralign == (chdr.ch_addralign & -chdr.ch_addralign))
 	{
 	  *uncompressed_size = chdr.ch_size;
 	  *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign);