From: Jakub Kicinski <kuba@kernel.org>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
Oleksij Rempel <linux@rempel-privat.de>,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net: phylib: fix phy_read*_poll_timeout()
Date: Fri, 2 Jun 2023 10:10:58 -0700 [thread overview]
Message-ID: <20230602101058.7faf94bf@kernel.org> (raw)
In-Reply-To: <ZHoaF6O0Vlq9pikF@shell.armlinux.org.uk>
On Fri, 2 Jun 2023 17:34:31 +0100 Russell King (Oracle) wrote:
> On Fri, Jun 02, 2023 at 05:17:59PM +0100, Russell King (Oracle) wrote:
> > On Fri, Jun 02, 2023 at 09:05:39AM -0700, Jakub Kicinski wrote:
> > > Wait, did the version I proposed not work?
> > >
> > > https://lore.kernel.org/all/20230530121910.05b9f837@kernel.org/
> >
> > If we're into the business of throwing web URLs at each other for
> > messages we've already read, here's my one for you which contains
> > the explanation why your one is broken, and proposing my solution.
> >
> > https://lore.kernel.org/all/ZHZmBBDSVMf1WQWI@shell.armlinux.org.uk/
> >
> > To see exactly why yours is broken, see the paragraph starting
> > "The elephant in the room..."
Ah, yes, sorry, I'll admit I didn't get what you mean by the elephant
paragraph when I read that.
> If you don't like my solution, then I suppose another possibility would
> be:
>
> #define __phy_poll_read(phydev, regnum, val) \
> ({ \
> int __err; \
> __err = phy_read(phydev, regnum); \
> if (__err >= 0) \
> val = __err; \
> __err; \
> })
>
> #define phy_read_poll_timeout(phydev, regnum, val, cond, sleep_us, \
> timeout_us, sleep_before_read) \
> ({ \
> int __ret, __err; \
> __ret = read_poll_timeout(__phy_poll_read, __err, \
> __err < 0 || (cond), \
> sleep_us, timeout_us, sleep_before_read, phydev, regnum, val); \
> if (__err < 0) \
> __ret = __err; \
> ...
>
> but that brings with it the possibility of using an uninitialised
> "val" (e.g. if phy_read() returns an error on the first iteration.)
> and is way more horrid and even less easy to understand.
>
> Remember that we default to *not* warning about uninitialised variables
> when building the kernel, so this won't produce a warning - which I
> guess is probably why you didn't notice that your suggestion left "val"
> uninitialised.
Right :( Let's keep the patch as is.
next prev parent reply other threads:[~2023-06-02 17:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 15:48 [PATCH net-next] net: phylib: fix phy_read*_poll_timeout() Russell King (Oracle)
2023-06-02 4:33 ` Jakub Kicinski
2023-06-02 4:35 ` Jakub Kicinski
2023-06-02 8:53 ` Russell King (Oracle)
2023-06-02 16:05 ` Jakub Kicinski
2023-06-02 16:17 ` Russell King (Oracle)
2023-06-02 16:34 ` Russell King (Oracle)
2023-06-02 17:10 ` Jakub Kicinski [this message]
2023-06-03 6:40 ` patchwork-bot+netdevbpf
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=20230602101058.7faf94bf@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=linux@armlinux.org.uk \
--cc=linux@rempel-privat.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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.