Message ID | 20230710064027.173298-1-suhui@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4830180vqx; Sun, 9 Jul 2023 23:56:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlFEpM39jDVVF/zHTf0V8ZJEcjCxYJSl6yTzndoTk/Y0NQo39quAvX4P3GoGJeuBERhjzFmy X-Received: by 2002:a17:906:56:b0:993:da0b:8783 with SMTP id 22-20020a170906005600b00993da0b8783mr9526758ejg.3.1688972209033; Sun, 09 Jul 2023 23:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688972209; cv=none; d=google.com; s=arc-20160816; b=SkxFzqQj9TJsQRTRc5g2ulGB1YISqO/PsNgOHVLZ6bBLPbQuwaKzZZnNzevy0pw508 raK6rDZpUfGxohhyVmPfnawCTL6IqfoLLFpceFwU72apanoFBT4Gq9XmljcfF7P7mA0B NcvSzTSf2Znhx6CW2vhTCOExiUgs8P1YHCFcJ35zILEBspoiTTWCbx4p7TbCON3M7Iys iFHghpF5+IYYTnqpS4298RimtCVisUPi07U7UMjJ8EpcDnCOeVYSuMNpm1Ky6jhh1OAG 6dx8oH3dFH13E6vXCA6ml3/qzC4JV6YebGMQScSUVmMQ1eeSETIE8uqMkiudv4scgtXl 5okA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=C3GsZE+DrBp2cV4Dp0OQIxR10u8k9vpXl3EeseQsO0o=; fh=RgLnCqcxbubtSCpdEiU3rrvyVhVk4JTJZemtgDIHHIA=; b=sTa4u3FuaBEy+PidFSpBsp8BPDU8NF4HeddxBtWV5laPldP2P/qHc4EqZKpIFNJK44 L9VpjPzsmf4L+AiqrEdg5XaoYnz81idsbicQ3VGE9M0HY6v1B5xk6N+uXyCQkIOHVoEn KlmD+sh4AZKrsSfb28xQ5dJm06KMCV+t7bDze2Kh32QqJeCH4DYT9WX3GEUgJq/JSc7V S/HNFPfi7INtCzL+7cfoIvrIFBNtx1sFWc/Mnq+CrXu1SXDajCvkhlJoml1u0crxMfsQ KHSwC3V5KIMUhDFFCP0AQO801vQMMJbY5lYd0FkCXOHbNFiLsSy4Boz7X2z/08zfnMRn RBhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rl7-20020a170907216700b00993629dea0csi8459195ejb.134.2023.07.09.23.56.25; Sun, 09 Jul 2023 23:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbjGJGkj (ORCPT <rfc822;ybw1215001957@gmail.com> + 99 others); Mon, 10 Jul 2023 02:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbjGJGkg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 10 Jul 2023 02:40:36 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 5AF768E; Sun, 9 Jul 2023 23:40:35 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 49965602B2DC6; Mon, 10 Jul 2023 14:40:32 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui <suhui@nfschina.com> To: mostrows@earthlink.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, xeb@mail.ru Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, wuych <yunchuan@nfschina.com> Subject: [PATCH net-next v2 03/10] net: ppp: Remove unnecessary (void*) conversions Date: Mon, 10 Jul 2023 14:40:27 +0800 Message-Id: <20230710064027.173298-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771015722952551990 X-GMAIL-MSGID: 1771015722952551990 |
Series |
Remove unnecessary (void*) conversions
|
|
Commit Message
Su Hui
July 10, 2023, 6:40 a.m. UTC
From: wuych <yunchuan@nfschina.com> Pointer variables of void * type do not require type cast. Signed-off-by: wuych <yunchuan@nfschina.com> --- drivers/net/ppp/pppoe.c | 4 ++-- drivers/net/ppp/pptp.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Comments
On Mon, Jul 10, 2023 at 02:40:27PM +0800, Su Hui wrote: > From: wuych <yunchuan@nfschina.com> > > Pointer variables of void * type do not require type cast. > > Signed-off-by: wuych <yunchuan@nfschina.com> > --- > drivers/net/ppp/pppoe.c | 4 ++-- > drivers/net/ppp/pptp.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c > index 3b79c603b936..ba8b6bd8233c 100644 > --- a/drivers/net/ppp/pppoe.c > +++ b/drivers/net/ppp/pppoe.c > @@ -968,7 +968,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) > ***********************************************************************/ > static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb) > { > - struct sock *sk = (struct sock *)chan->private; > + struct sock *sk = chan->private; > return __pppoe_xmit(sk, skb); > } > > @@ -976,7 +976,7 @@ static int pppoe_fill_forward_path(struct net_device_path_ctx *ctx, > struct net_device_path *path, > const struct ppp_channel *chan) > { > - 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.
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. " Wu Yunchuan [1] https://lore.kernel.org/all/23e98085-8f07-4ee2-8487-8e3b439b69f4@lunn.ch/ [2] https://lore.kernel.org/all/45519aec-6ec8-49e5-b5b2-1b52d336288c@kadam.mountain/ >
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.
On Mon, Jul 10, 2023 at 02:40:27PM +0800, Su Hui wrote: > From: wuych <yunchuan@nfschina.com> > > Pointer variables of void * type do not require type cast. > > Signed-off-by: wuych <yunchuan@nfschina.com> > --- > drivers/net/ppp/pppoe.c | 4 ++-- > drivers/net/ppp/pptp.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) Reviewed-by: Guillaume Nault <gnault@redhat.com> While there, you might want to also remove the useless casts in net/l2tp/l2tp_ppp.c and net/atm/pppoatm.c. > diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c > index 3b79c603b936..ba8b6bd8233c 100644 > --- a/drivers/net/ppp/pppoe.c > +++ b/drivers/net/ppp/pppoe.c > @@ -968,7 +968,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) > ***********************************************************************/ > static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb) > { > - struct sock *sk = (struct sock *)chan->private; > + struct sock *sk = chan->private; > return __pppoe_xmit(sk, skb); > } > > @@ -976,7 +976,7 @@ static int pppoe_fill_forward_path(struct net_device_path_ctx *ctx, > struct net_device_path *path, > const struct ppp_channel *chan) > { > - 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; > > diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c > index 32183f24e63f..6b3d3df99549 100644 > --- a/drivers/net/ppp/pptp.c > +++ b/drivers/net/ppp/pptp.c > @@ -148,7 +148,7 @@ static struct rtable *pptp_route_output(struct pppox_sock *po, > > static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) > { > - struct sock *sk = (struct sock *) chan->private; > + struct sock *sk = chan->private; > struct pppox_sock *po = pppox_sk(sk); > struct net *net = sock_net(sk); > struct pptp_opt *opt = &po->proto.pptp; > @@ -575,7 +575,7 @@ static int pptp_create(struct net *net, struct socket *sock, int kern) > static int pptp_ppp_ioctl(struct ppp_channel *chan, unsigned int cmd, > unsigned long arg) > { > - struct sock *sk = (struct sock *) chan->private; > + struct sock *sk = chan->private; > struct pppox_sock *po = pppox_sk(sk); > struct pptp_opt *opt = &po->proto.pptp; > void __user *argp = (void __user *)arg; > -- > 2.30.2 > >
On 2023/7/14 17:07, Guillaume Nault wrote: > On Mon, Jul 10, 2023 at 02:40:27PM +0800, Su Hui wrote: >> From: wuych <yunchuan@nfschina.com> >> >> Pointer variables of void * type do not require type cast. >> >> Signed-off-by: wuych <yunchuan@nfschina.com> >> --- >> drivers/net/ppp/pppoe.c | 4 ++-- >> drivers/net/ppp/pptp.c | 4 ++-- >> 2 files changed, 4 insertions(+), 4 deletions(-) > Reviewed-by: Guillaume Nault <gnault@redhat.com> > > While there, you might want to also remove the useless casts in > net/l2tp/l2tp_ppp.c and net/atm/pppoatm.c. Hi, Thanks four your reminder! There are about 20 useless casts in net. I will remove all of them. Wu Yunchuan >> diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c >> index 3b79c603b936..ba8b6bd8233c 100644 >> --- a/drivers/net/ppp/pppoe.c >> +++ b/drivers/net/ppp/pppoe.c >> @@ -968,7 +968,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) >> ***********************************************************************/ >> static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb) >> { >> - struct sock *sk = (struct sock *)chan->private; >> + struct sock *sk = chan->private; >> return __pppoe_xmit(sk, skb); >> } >> >> @@ -976,7 +976,7 @@ static int pppoe_fill_forward_path(struct net_device_path_ctx *ctx, >> struct net_device_path *path, >> const struct ppp_channel *chan) >> { >> - 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; >> >> diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c >> index 32183f24e63f..6b3d3df99549 100644 >> --- a/drivers/net/ppp/pptp.c >> +++ b/drivers/net/ppp/pptp.c >> @@ -148,7 +148,7 @@ static struct rtable *pptp_route_output(struct pppox_sock *po, >> >> static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) >> { >> - struct sock *sk = (struct sock *) chan->private; >> + struct sock *sk = chan->private; >> struct pppox_sock *po = pppox_sk(sk); >> struct net *net = sock_net(sk); >> struct pptp_opt *opt = &po->proto.pptp; >> @@ -575,7 +575,7 @@ static int pptp_create(struct net *net, struct socket *sock, int kern) >> static int pptp_ppp_ioctl(struct ppp_channel *chan, unsigned int cmd, >> unsigned long arg) >> { >> - struct sock *sk = (struct sock *) chan->private; >> + struct sock *sk = chan->private; >> struct pppox_sock *po = pppox_sk(sk); >> struct pptp_opt *opt = &po->proto.pptp; >> void __user *argp = (void __user *)arg; >> -- >> 2.30.2 >> >>
On Mon, Jul 17, 2023 at 09:33:30AM +0800, yunchuan wrote: > On 2023/7/14 17:07, Guillaume Nault wrote: > > On Mon, Jul 10, 2023 at 02:40:27PM +0800, Su Hui wrote: > > > From: wuych <yunchuan@nfschina.com> > > > > > > Pointer variables of void * type do not require type cast. > > > > > > Signed-off-by: wuych <yunchuan@nfschina.com> > > > --- > > > drivers/net/ppp/pppoe.c | 4 ++-- > > > drivers/net/ppp/pptp.c | 4 ++-- > > > 2 files changed, 4 insertions(+), 4 deletions(-) > > Reviewed-by: Guillaume Nault <gnault@redhat.com> > > > > While there, you might want to also remove the useless casts in > > net/l2tp/l2tp_ppp.c and net/atm/pppoatm.c. > > Hi, > > Thanks four your reminder! There are about 20 useless casts in net. > I will remove all of them. I was specifically pointing at l2tp_ppp.c and pppoatm.c because they convert the same kind of variable (chan->private) and cound be sqashed into this commit. But if you prefer to handle these separately, that's obviously fine too. > Wu Yunchuan > > > > diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c > > > index 3b79c603b936..ba8b6bd8233c 100644 > > > --- a/drivers/net/ppp/pppoe.c > > > +++ b/drivers/net/ppp/pppoe.c > > > @@ -968,7 +968,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) > > > ***********************************************************************/ > > > static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb) > > > { > > > - struct sock *sk = (struct sock *)chan->private; > > > + struct sock *sk = chan->private; > > > return __pppoe_xmit(sk, skb); > > > } > > > @@ -976,7 +976,7 @@ static int pppoe_fill_forward_path(struct net_device_path_ctx *ctx, > > > struct net_device_path *path, > > > const struct ppp_channel *chan) > > > { > > > - 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; > > > diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c > > > index 32183f24e63f..6b3d3df99549 100644 > > > --- a/drivers/net/ppp/pptp.c > > > +++ b/drivers/net/ppp/pptp.c > > > @@ -148,7 +148,7 @@ static struct rtable *pptp_route_output(struct pppox_sock *po, > > > static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) > > > { > > > - struct sock *sk = (struct sock *) chan->private; > > > + struct sock *sk = chan->private; > > > struct pppox_sock *po = pppox_sk(sk); > > > struct net *net = sock_net(sk); > > > struct pptp_opt *opt = &po->proto.pptp; > > > @@ -575,7 +575,7 @@ static int pptp_create(struct net *net, struct socket *sock, int kern) > > > static int pptp_ppp_ioctl(struct ppp_channel *chan, unsigned int cmd, > > > unsigned long arg) > > > { > > > - struct sock *sk = (struct sock *) chan->private; > > > + struct sock *sk = chan->private; > > > struct pppox_sock *po = pppox_sk(sk); > > > struct pptp_opt *opt = &po->proto.pptp; > > > void __user *argp = (void __user *)arg; > > > -- > > > 2.30.2 > > > > > > >
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c index 3b79c603b936..ba8b6bd8233c 100644 --- a/drivers/net/ppp/pppoe.c +++ b/drivers/net/ppp/pppoe.c @@ -968,7 +968,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) ***********************************************************************/ static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb) { - struct sock *sk = (struct sock *)chan->private; + struct sock *sk = chan->private; return __pppoe_xmit(sk, skb); } @@ -976,7 +976,7 @@ static int pppoe_fill_forward_path(struct net_device_path_ctx *ctx, struct net_device_path *path, const struct ppp_channel *chan) { - 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; diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c index 32183f24e63f..6b3d3df99549 100644 --- a/drivers/net/ppp/pptp.c +++ b/drivers/net/ppp/pptp.c @@ -148,7 +148,7 @@ static struct rtable *pptp_route_output(struct pppox_sock *po, static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) { - struct sock *sk = (struct sock *) chan->private; + struct sock *sk = chan->private; struct pppox_sock *po = pppox_sk(sk); struct net *net = sock_net(sk); struct pptp_opt *opt = &po->proto.pptp; @@ -575,7 +575,7 @@ static int pptp_create(struct net *net, struct socket *sock, int kern) static int pptp_ppp_ioctl(struct ppp_channel *chan, unsigned int cmd, unsigned long arg) { - struct sock *sk = (struct sock *) chan->private; + struct sock *sk = chan->private; struct pppox_sock *po = pppox_sk(sk); struct pptp_opt *opt = &po->proto.pptp; void __user *argp = (void __user *)arg;