Skip to content

Commit 1a575cd

Browse files
nathanchancekuba-moo
authored andcommitted
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. Fixes: a62a56d ("ptp: ocp: Enable 4th timestamper / PPS generator") Link: ClangBuiltLinux/linux#1457 Suggested-by: Jonathan Lemon <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Acked-by: Jonathan Lemon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5ef8a02 commit 1a575cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/ptp/ptp_ocp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,11 +2062,11 @@ ptp_ocp_summary_show(struct seq_file *s, void *data)
20622062
on = ioread32(&ts_reg->enable);
20632063
map = !!(bp->pps_req_map & OCP_REQ_TIMESTAMP);
20642064
seq_printf(s, "%7s: %s, src: %s\n", "TS3",
2065-
on & map ? " ON" : "OFF", src);
2065+
on && map ? " ON" : "OFF", src);
20662066

20672067
map = !!(bp->pps_req_map & OCP_REQ_PPS);
20682068
seq_printf(s, "%7s: %s, src: %s\n", "PPS",
2069-
on & map ? " ON" : "OFF", src);
2069+
on && map ? " ON" : "OFF", src);
20702070
}
20712071

20722072
if (bp->irig_out) {

0 commit comments

Comments
 (0)