All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Lemon <jonathan.lemon@gmail.com>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Richard Cochran <richardcochran@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show()
Date: Thu, 16 Sep 2021 21:29:33 -0700	[thread overview]
Message-ID: <20210917042933.d42m5ijbiiqrctxp@bsd-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210916194351.3860836-1-nathan@kernel.org>

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

      reply	other threads:[~2021-09-17  4:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 19:43 [PATCH] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show() Nathan Chancellor
2021-09-17  4:29 ` Jonathan Lemon [this message]

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=20210917042933.d42m5ijbiiqrctxp@bsd-mbp.dhcp.thefacebook.com \
    --to=jonathan.lemon@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --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.