* [PATCH net-next v2] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show()
@ 2021-09-17 4:52 Nathan Chancellor
2021-09-17 5:41 ` Jonathan Lemon
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2021-09-17 4:52 UTC (permalink / raw)
To: Richard Cochran, Jonathan Lemon, David S. Miller, Jakub Kicinski
Cc: netdev, linux-kernel, llvm, Nathan Chancellor
Clang warns twice:
drivers/ptp/ptp_ocp.c:2065:16: error: operator '?:' has lower precedence
than '&'; '&' will be evaluated first
[-Werror,-Wbitwise-conditional-parentheses]
on & map ? " ON" : "OFF", src);
~~~~~~~~ ^
drivers/ptp/ptp_ocp.c:2065:16: note: place parentheses around the '&'
expression to silence this warning
on & map ? " ON" : "OFF", src);
^
( )
drivers/ptp/ptp_ocp.c:2065:16: note: place parentheses around the '?:'
expression to evaluate it first
on & map ? " ON" : "OFF", src);
^
on and map are both booleans so this should be a logical AND, which
clears up the operator precedence issue.
Fixes: a62a56d04e63 ("ptp: ocp: Enable 4th timestamper / PPS generator")
Link: https://github.com/ClangBuiltLinux/linux/issues/1457
Suggested-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
v1 -> v2: https://lore.kernel.org/r/20210916194351.3860836-1-nathan@kernel.org/
* Change fix from adding parentheses to moving from bitwise to logical
AND. Thanks to Jonathan for catching that both operands were boolean,
which I unfortunately missed.
drivers/ptp/ptp_ocp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 844b1401cc5d..c26708f486cf 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -2062,11 +2062,11 @@ ptp_ocp_summary_show(struct seq_file *s, void *data)
on = ioread32(&ts_reg->enable);
map = !!(bp->pps_req_map & OCP_REQ_TIMESTAMP);
seq_printf(s, "%7s: %s, src: %s\n", "TS3",
- on & map ? " ON" : "OFF", src);
+ on && map ? " ON" : "OFF", src);
map = !!(bp->pps_req_map & OCP_REQ_PPS);
seq_printf(s, "%7s: %s, src: %s\n", "PPS",
- on & map ? " ON" : "OFF", src);
+ on && map ? " ON" : "OFF", src);
}
if (bp->irig_out) {
base-commit: 8dc84dcd7f74b50f81de3dbf6f6b5b146e3a8eea
--
2.33.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show()
2021-09-17 4:52 [PATCH net-next v2] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show() Nathan Chancellor
@ 2021-09-17 5:41 ` Jonathan Lemon
2021-09-17 17:32 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Lemon @ 2021-09-17 5:41 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Richard Cochran, David S. Miller, Jakub Kicinski, netdev,
linux-kernel, llvm
On Thu, Sep 16, 2021 at 09:52:05PM -0700, Nathan Chancellor wrote:
> Clang warns twice:
>
> drivers/ptp/ptp_ocp.c:2065:16: error: operator '?:' has lower precedence
> than '&'; '&' will be evaluated first
> [-Werror,-Wbitwise-conditional-parentheses]
> on & map ? " ON" : "OFF", src);
> ~~~~~~~~ ^
> drivers/ptp/ptp_ocp.c:2065:16: note: place parentheses around the '&'
> expression to silence this warning
> on & map ? " ON" : "OFF", src);
> ^
> ( )
> drivers/ptp/ptp_ocp.c:2065:16: note: place parentheses around the '?:'
> expression to evaluate it first
> on & map ? " ON" : "OFF", src);
> ^
>
> on and map are both booleans so this should be a logical AND, which
> clears up the operator precedence issue.
>
> Fixes: a62a56d04e63 ("ptp: ocp: Enable 4th timestamper / PPS generator")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1457
> Suggested-by: Jonathan Lemon <jonathan.lemon@gmail.com>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show()
2021-09-17 5:41 ` Jonathan Lemon
@ 2021-09-17 17:32 ` Jakub Kicinski
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2021-09-17 17:32 UTC (permalink / raw)
To: Jonathan Lemon, Nathan Chancellor
Cc: Richard Cochran, David S. Miller, netdev, linux-kernel, llvm
On Thu, 16 Sep 2021 22:41:14 -0700 Jonathan Lemon wrote:
> On Thu, Sep 16, 2021 at 09:52:05PM -0700, Nathan Chancellor wrote:
> > Clang warns twice:
> >
> > drivers/ptp/ptp_ocp.c:2065:16: error: operator '?:' has lower precedence
> > than '&'; '&' will be evaluated first
> > [-Werror,-Wbitwise-conditional-parentheses]
> > on & map ? " ON" : "OFF", src);
> > ~~~~~~~~ ^
> > drivers/ptp/ptp_ocp.c:2065:16: note: place parentheses around the '&'
> > expression to silence this warning
> > on & map ? " ON" : "OFF", src);
> > ^
> > ( )
> > drivers/ptp/ptp_ocp.c:2065:16: note: place parentheses around the '?:'
> > expression to evaluate it first
> > on & map ? " ON" : "OFF", src);
> > ^
> >
> > on and map are both booleans so this should be a logical AND, which
> > clears up the operator precedence issue.
> >
> > Fixes: a62a56d04e63 ("ptp: ocp: Enable 4th timestamper / PPS generator")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1457
> > Suggested-by: Jonathan Lemon <jonathan.lemon@gmail.com>
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-17 17:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 4:52 [PATCH net-next v2] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show() Nathan Chancellor
2021-09-17 5:41 ` Jonathan Lemon
2021-09-17 17:32 ` Jakub Kicinski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.