All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kyle Swenson <kyle.swenson@est.tech>,
	Simon Horman <horms@kernel.org>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	thomas.petazzoni@bootlin.com,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net v2] net: pse-pd: tps23881: Fix boolean evaluation for bitmask checks
Date: Wed, 2 Oct 2024 07:31:56 -0700	[thread overview]
Message-ID: <20241002073156.447d06c4@kernel.org> (raw)
In-Reply-To: <20241002145302.701e74d8@kmaincent-XPS-13-7390>

On Wed, 2 Oct 2024 14:53:02 +0200 Kory Maincent wrote:
> On Wed, 2 Oct 2024 05:27:32 -0700
> Jakub Kicinski <kuba@kernel.org> wrote:
> 
> > On Wed, 2 Oct 2024 05:24:31 -0700 Jakub Kicinski wrote:  
> > > On Wed,  2 Oct 2024 12:23:40 +0200 Kory Maincent wrote:    
> > > > In the case of 4-pair PoE, this led to incorrect enabled and
> > > > delivering status values.      
> > > 
> > > Could you elaborate? The patch looks like a noop I must be missing some
> > > key aspect..    
> > 
> > Reading the discussion on v1 it seems you're doing this to be safe,
> > because there was a problem with x &= val & MASK; elsewhere.
> > If that's the case, please resend to net-next and make it clear it's
> > not a fix.  
> 
> Indeed it fixes this issue.

Is "this" here the &= issue or the sentence from the commit message?

> Why do you prefer to have it on net-next instead of a net? We agreed with
> Oleksij that it's where it should land. Do we have missed something?

The patch is a noop, AFAICT. Are you saying it changes how the code
behaves? 

The patch only coverts cases which are 

	ena = val & MASK;

the automatic type conversion will turn this into:

	ena = bool(val & MASK);
which is the same as:
	ena = !!(val & MASK);

The problem you were seeing earlier was that:

	ena &= val & MASK;

will be converted to:

	ena = ena & (val & MASK);

and that is:

	ena = bool(int(ena) & (val & MASK));
                   ^^^

IOW ena gets promoted to int for the & operation.
This problem does not occur with simple assignment.

  reply	other threads:[~2024-10-02 14:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 10:23 [PATCH net v2] net: pse-pd: tps23881: Fix boolean evaluation for bitmask checks Kory Maincent
2024-10-02 12:24 ` Jakub Kicinski
2024-10-02 12:27   ` Jakub Kicinski
2024-10-02 12:53     ` Kory Maincent
2024-10-02 14:31       ` Jakub Kicinski [this message]
2024-10-02 15:00         ` Kory Maincent
2024-10-02 15:02           ` Jakub Kicinski

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=20241002073156.447d06c4@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kory.maincent@bootlin.com \
    --cc=kyle.swenson@est.tech \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=thomas.petazzoni@bootlin.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.