linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise
@ 2022-08-31  4:09 Ziyang Xuan
  2022-08-31  4:09 ` [PATCH next-next 1/2] net: vlan: remove unnecessary err variable in vlan_init_net() Ziyang Xuan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ziyang Xuan @ 2022-08-31  4:09 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, morbo, netdev; +Cc: linux-kernel

Give two small refactors to make code more concise.

Ziyang Xuan (2):
  net: vlan: remove unnecessary err variable in vlan_init_net()
  net: vlan: reduce indentation level in __vlan_find_dev_deep_rcu()

 net/8021q/vlan.c      |  5 +----
 net/8021q/vlan_core.c | 22 +++++++++-------------
 2 files changed, 10 insertions(+), 17 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH next-next 1/2] net: vlan: remove unnecessary err variable in vlan_init_net()
  2022-08-31  4:09 [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise Ziyang Xuan
@ 2022-08-31  4:09 ` Ziyang Xuan
  2022-08-31  4:09 ` [PATCH next-next 2/2] net: vlan: reduce indentation level in __vlan_find_dev_deep_rcu() Ziyang Xuan
  2022-09-01 13:28 ` [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise Paolo Abeni
  2 siblings, 0 replies; 5+ messages in thread
From: Ziyang Xuan @ 2022-08-31  4:09 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, morbo, netdev; +Cc: linux-kernel

Return vlan_init_net() directly in vlan_init_net(), remove unnecessary
err variable. Thus code looks more concise.

Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 net/8021q/vlan.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index e40aa3e3641c..aaef80fdd852 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -658,13 +658,10 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
 static int __net_init vlan_init_net(struct net *net)
 {
 	struct vlan_net *vn = net_generic(net, vlan_net_id);
-	int err;
 
 	vn->name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
 
-	err = vlan_proc_init(net);
-
-	return err;
+	return vlan_proc_init(net);
 }
 
 static void __net_exit vlan_exit_net(struct net *net)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH next-next 2/2] net: vlan: reduce indentation level in __vlan_find_dev_deep_rcu()
  2022-08-31  4:09 [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise Ziyang Xuan
  2022-08-31  4:09 ` [PATCH next-next 1/2] net: vlan: remove unnecessary err variable in vlan_init_net() Ziyang Xuan
@ 2022-08-31  4:09 ` Ziyang Xuan
  2022-09-01 13:28 ` [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise Paolo Abeni
  2 siblings, 0 replies; 5+ messages in thread
From: Ziyang Xuan @ 2022-08-31  4:09 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, morbo, netdev; +Cc: linux-kernel

If vlan_info is NULL in __vlan_find_dev_deep_rcu(), else { ... } is
unnecessary. Remove it to reduce indentation level.

Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 net/8021q/vlan_core.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 5aa8144101dc..027d4ebed9c0 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -77,23 +77,19 @@ struct net_device *__vlan_find_dev_deep_rcu(struct net_device *dev,
 					__be16 vlan_proto, u16 vlan_id)
 {
 	struct vlan_info *vlan_info = rcu_dereference(dev->vlan_info);
+	struct net_device *upper_dev;
 
-	if (vlan_info) {
+	if (vlan_info)
 		return vlan_group_get_device(&vlan_info->grp,
 					     vlan_proto, vlan_id);
-	} else {
-		/*
-		 * Lower devices of master uppers (bonding, team) do not have
-		 * grp assigned to themselves. Grp is assigned to upper device
-		 * instead.
-		 */
-		struct net_device *upper_dev;
 
-		upper_dev = netdev_master_upper_dev_get_rcu(dev);
-		if (upper_dev)
-			return __vlan_find_dev_deep_rcu(upper_dev,
-						    vlan_proto, vlan_id);
-	}
+	/* Lower devices of master uppers (bonding, team) do not have
+	 * grp assigned to themselves. Grp is assigned to upper device
+	 * instead.
+	 */
+	upper_dev = netdev_master_upper_dev_get_rcu(dev);
+	if (upper_dev)
+		return __vlan_find_dev_deep_rcu(upper_dev, vlan_proto, vlan_id);
 
 	return NULL;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise
  2022-08-31  4:09 [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise Ziyang Xuan
  2022-08-31  4:09 ` [PATCH next-next 1/2] net: vlan: remove unnecessary err variable in vlan_init_net() Ziyang Xuan
  2022-08-31  4:09 ` [PATCH next-next 2/2] net: vlan: reduce indentation level in __vlan_find_dev_deep_rcu() Ziyang Xuan
@ 2022-09-01 13:28 ` Paolo Abeni
  2022-09-02  1:12   ` Ziyang Xuan (William)
  2 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2022-09-01 13:28 UTC (permalink / raw)
  To: Ziyang Xuan, davem, edumazet, kuba, morbo, netdev; +Cc: linux-kernel

Hello,

On Wed, 2022-08-31 at 12:09 +0800, Ziyang Xuan wrote:
> Give two small refactors to make code more concise.
> 
> Ziyang Xuan (2):
>   net: vlan: remove unnecessary err variable in vlan_init_net()
>   net: vlan: reduce indentation level in __vlan_find_dev_deep_rcu()
> 
>  net/8021q/vlan.c      |  5 +----
>  net/8021q/vlan_core.c | 22 +++++++++-------------
>  2 files changed, 10 insertions(+), 17 deletions(-)

The patches look correct to me, but I think is better to defer this
kind of nun-functional refactors to some work actually doing new stuff,
to avoid unneeded noise.

Note that I merged a few other clean-up recently, but e.g. they at
least formally removed some unneeded branch.

Sorry, I'm not going to apply this series.

Cheers,

Paolo


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise
  2022-09-01 13:28 ` [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise Paolo Abeni
@ 2022-09-02  1:12   ` Ziyang Xuan (William)
  0 siblings, 0 replies; 5+ messages in thread
From: Ziyang Xuan (William) @ 2022-09-02  1:12 UTC (permalink / raw)
  To: Paolo Abeni, davem, edumazet, kuba, morbo, netdev; +Cc: linux-kernel



在 2022/9/1 21:28, Paolo Abeni 写道:
> Hello,
> 
> On Wed, 2022-08-31 at 12:09 +0800, Ziyang Xuan wrote:
>> Give two small refactors to make code more concise.
>>
>> Ziyang Xuan (2):
>>   net: vlan: remove unnecessary err variable in vlan_init_net()
>>   net: vlan: reduce indentation level in __vlan_find_dev_deep_rcu()
>>
>>  net/8021q/vlan.c      |  5 +----
>>  net/8021q/vlan_core.c | 22 +++++++++-------------
>>  2 files changed, 10 insertions(+), 17 deletions(-)
> 
> The patches look correct to me, but I think is better to defer this
> kind of nun-functional refactors to some work actually doing new stuff,
> to avoid unneeded noise.
> 
> Note that I merged a few other clean-up recently, but e.g. they at
> least formally removed some unneeded branch.
> 
> Sorry, I'm not going to apply this series.

No problem, I will try to dig deeper.

> 
> Cheers,
> 
> Paolo
> 
> .
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-02  1:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31  4:09 [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise Ziyang Xuan
2022-08-31  4:09 ` [PATCH next-next 1/2] net: vlan: remove unnecessary err variable in vlan_init_net() Ziyang Xuan
2022-08-31  4:09 ` [PATCH next-next 2/2] net: vlan: reduce indentation level in __vlan_find_dev_deep_rcu() Ziyang Xuan
2022-09-01 13:28 ` [PATCH next-next 0/2] net: vlan: two small refactors to make code more concise Paolo Abeni
2022-09-02  1:12   ` Ziyang Xuan (William)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).