[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZK+4udwfawcJq5qC@corigine.com>
Date: Thu, 13 Jul 2023 09:41:29 +0100
From: Simon Horman <simon.horman@...igine.com>
To: yunchuan <yunchuan@...china.com>
Cc: mostrows@...thlink.net, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, xeb@...l.ru,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: Re: [PATCH net-next v2 03/10] net: ppp: Remove unnecessary (void*)
conversions
On Wed, Jul 12, 2023 at 09:44:40AM +0800, yunchuan wrote:
> On 2023/7/12 01:50, Simon Horman wrote:
> > > - struct sock *sk = (struct sock *)chan->private;
> > > + struct sock *sk = chan->private;
> > > struct pppox_sock *po = pppox_sk(sk);
> > > struct net_device *dev = po->pppoe_dev;
> > Hi,
> >
> > Please don't break reverse xmas tree ordering - longest line to shortest -
> > of local variable declarations in Networking code.
>
> Hi,
>
> This can't be reversed because it depends on the first declaration.
> Should I change it like this?
>
> - struct sock *sk = (struct sock *)chan->private;
> - struct pppox_sock *po = pppox_sk(sk);
> + struct pppox_sock *po = pppox_sk(chan->private);
> struct net_device *dev = po->pppoe_dev;
> + struct sock *sk = chan->private;
>
> But this seems to be bad. As the advice of Andrew[1] and Dan[2]:
>
> "
>
> When dealing with existing broken reverse Christmas tree, please don't
> make it worse with a change. But actually fixing it should be in a
> different patch.
>
> We want patches to be obviously correct. By removing the cast and
> moving variables around, it is less obvious it is correct, than having
> two patches.
>
> "
Thanks, I agree this is a good approach.
Powered by blists - more mailing lists