]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_in...
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 16 Jan 2022 03:13:07 +0000 (22:13 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 18 Jan 2022 04:14:57 +0000 (23:14 -0500)
I see this error with clang-14:

      CC       elf64-ppc.lo
    /home/smarchi/src/binutils-gdb/bfd/elf64-ppc.c:13131:11: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
      return (check_pasted_section (info, ".init")
             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix by replacing & with &&.  But given that the check_pasted_section
function has side-effects and we want to make sure both calls are made,
assign to temporary variables before evaluating the `&&`.

Change-Id: I849e1b2401bea5f4d8ef3ab9af99ba9e3ef42490

bfd/elf64-ppc.c

index 0f945797b492ddd5ee70bfc5944e40ec884296a1..923c7a3b4073ea39c8e2b6695d227f86703576f9 100644 (file)
@@ -13202,8 +13202,10 @@ check_pasted_section (struct bfd_link_info *info, const char *name)
 bool
 ppc64_elf_check_init_fini (struct bfd_link_info *info)
 {
-  return (check_pasted_section (info, ".init")
-         & check_pasted_section (info, ".fini"));
+  bool ret1 = check_pasted_section (info, ".init");
+  bool ret2 = check_pasted_section (info, ".fini");
+
+  return ret1 && ret2;
 }
 
 /* See whether we can group stub sections together.  Grouping stub