ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show()
PATCH v2 1/1 ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show()
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.
---
v1 -> v2: https://lore.kernel.org/r/[email protected]/
* 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(-)
drivers/ptp/ptp_ocp.c +2 -2
@@ -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
Signature · 1 line
2.33.0
Quoted 17 lines · 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); ^
Quoted 7 lines
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")Suggested-by Jonathan Lemon <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Quoted 21 lines · On Thu, 16 Sep 2021 22:41:14 -0700 Jonathan Lemon wrote:
Quoted 20 lines · 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.
Quoted 6 lines
Quoted 4 lines
Fixes a62a56d04e63 ("ptp: ocp: Enable 4th timestamper / PPS generator")Suggested-by Jonathan Lemon <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>Acked-by Jonathan Lemon <[email protected]>
Applied, thanks!