[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210917042933.d42m5ijbiiqrctxp@bsd-mbp.dhcp.thefacebook.com>
Date: Thu, 16 Sep 2021 21:29:33 -0700
From: Jonathan Lemon <jonathan.lemon@...il.com>
To: Nathan Chancellor <nathan@...nel.org>
Cc: Richard Cochran <richardcochran@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] ptp: ocp: Avoid operator precedence warning in
ptp_ocp_summary_show()
On Thu, Sep 16, 2021 at 12:43:51PM -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);
> ^
>
> 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.
Actually, the correct fix is to change '&' to '&&', so a logical
operation is done instead of an arithmetic operation. I believe
this will silence the warning from clang.
--
Jonathan
Powered by blists - more mailing lists