[PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini

Alan Modra amodra@gmail.com
Sun Jan 16 23:10:56 GMT 2022


On Sat, Jan 15, 2022 at 10:13:07PM -0500, Simon Marchi via Binutils wrote:
> --- a/bfd/elf64-ppc.c
> +++ b/bfd/elf64-ppc.c
> @@ -13129,7 +13129,7 @@ bool
>  ppc64_elf_check_init_fini (struct bfd_link_info *info)
>  {
>    return (check_pasted_section (info, ".init")
> -	  & check_pasted_section (info, ".fini"));
> +	  && check_pasted_section (info, ".fini"));
>  }
>  
>  /* See whether we can group stub sections together.  Grouping stub

I think I'd rather see this fixed by

  bool ret1 = check_pasted_section (info, ".init");
  bool ret2 = check_pasted_section (info, ".fini");
  return ret1 && ret1;

check_pasted_section has a side effect, and failure normally only
produces a warning.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list