From: Nathan Chancellor <nathan@kernel.org>
To: Richard Cochran <richardcochran@gmail.com>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show()
Date: Thu, 16 Sep 2021 12:43:51 -0700 [thread overview]
Message-ID: <20210916194351.3860836-1-nathan@kernel.org> (raw)
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);
^
It is clearly intentional that the bitwise operation be done before the
ternary operation so add the parentheses as it suggests to fix the
warning.
Fixes: a62a56d04e63 ("ptp: ocp: Enable 4th timestamper / PPS generator")
Link: https://github.com/ClangBuiltLinux/linux/issues/1457
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
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..4ba3fb254a92 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: 4b5a3ab17c6c942bd428984b6b37fe3c07f18ab3
--
2.33.0
next reply other threads:[~2021-09-16 19:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 19:43 Nathan Chancellor [this message]
2021-09-17 4:29 ` [PATCH] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show() Jonathan Lemon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210916194351.3860836-1-nathan@kernel.org \
--to=nathan@kernel.org \
--cc=davem@davemloft.net \
--cc=jonathan.lemon@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.