* [PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini @ 2022-01-16 3:13 Simon Marchi 2022-01-16 23:10 ` Alan Modra 0 siblings, 1 reply; 5+ messages in thread From: Simon Marchi @ 2022-01-16 3:13 UTC (permalink / raw) To: binutils; +Cc: Simon Marchi 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 &&. Change-Id: I849e1b2401bea5f4d8ef3ab9af99ba9e3ef42490 --- bfd/elf64-ppc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index ea9e60217bc..ae5af11d596 100644 --- 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 -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini 2022-01-16 3:13 [PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini Simon Marchi @ 2022-01-16 23:10 ` Alan Modra 2022-01-17 10:50 ` Simon Marchi 0 siblings, 1 reply; 5+ messages in thread From: Alan Modra @ 2022-01-16 23:10 UTC (permalink / raw) To: Simon Marchi; +Cc: binutils 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini 2022-01-16 23:10 ` Alan Modra @ 2022-01-17 10:50 ` Simon Marchi 2022-01-17 11:14 ` Alan Modra 0 siblings, 1 reply; 5+ messages in thread From: Simon Marchi @ 2022-01-17 10:50 UTC (permalink / raw) To: Alan Modra; +Cc: binutils On 2022-01-16 18:10, Alan Modra wrote: > 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. > No problem, here's the updated patch. From bb27b41b2cd0dc4ebbbc8de6cfc5b691281695f1 Mon Sep 17 00:00:00 2001 From: Simon Marchi <simon.marchi@efficios.com> Date: Sat, 15 Jan 2022 22:13:07 -0500 Subject: [PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index ea9e60217bc3..206d85b319da 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -13128,8 +13128,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 base-commit: ab31da6aff52fe3206cba98c03d7f74159da8677 -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini 2022-01-17 10:50 ` Simon Marchi @ 2022-01-17 11:14 ` Alan Modra 2022-01-18 4:15 ` Simon Marchi 0 siblings, 1 reply; 5+ messages in thread From: Alan Modra @ 2022-01-17 11:14 UTC (permalink / raw) To: Simon Marchi; +Cc: binutils On Mon, Jan 17, 2022 at 05:50:46AM -0500, Simon Marchi wrote: > > > On 2022-01-16 18:10, Alan Modra wrote: > > 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. > > > > No problem, here's the updated patch. Thanks, please commit. -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini 2022-01-17 11:14 ` Alan Modra @ 2022-01-18 4:15 ` Simon Marchi 0 siblings, 0 replies; 5+ messages in thread From: Simon Marchi @ 2022-01-18 4:15 UTC (permalink / raw) To: Alan Modra; +Cc: binutils On 2022-01-17 06:14, Alan Modra wrote: > Thanks, please commit. Done, thanks. Simon ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-18 4:15 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-01-16 3:13 [PATCH] bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini Simon Marchi 2022-01-16 23:10 ` Alan Modra 2022-01-17 10:50 ` Simon Marchi 2022-01-17 11:14 ` Alan Modra 2022-01-18 4:15 ` Simon Marchi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).