All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: make dev_close void
@ 2017-07-18 22:59 Stephen Hemminger
  2017-07-18 22:59 ` [PATCH net-next 1/3] bluetooth: 6lowpan dev_close never returns error Stephen Hemminger
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Stephen Hemminger @ 2017-07-18 22:59 UTC (permalink / raw)
  To: yisen.zhuang, salil.mehta, davem, marcel, gustavo, johan.hedberg
  Cc: netdev, linux-bluetooth, Stephen Hemminger

Noticed while working on other changes. Why is dev_close()
returning int, it should be void.  Should also change
ndo_close to be void, but that requires more work and someone
with more coccinelle foo (smpl) than me.

Stephen Hemminger (3):
  bluetooth: 6lowpan dev_close never returns error
  hns: remove useless void cast
  net: make dev_close and related functions void

 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c |  2 +-
 include/linux/netdevice.h                        |  4 ++--
 net/bluetooth/6lowpan.c                          |  4 +---
 net/core/dev.c                                   | 26 ++++++++++--------------
 4 files changed, 15 insertions(+), 21 deletions(-)

-- 
2.11.0

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

* [PATCH net-next 1/3] bluetooth: 6lowpan dev_close never returns error
  2017-07-18 22:59 [PATCH net-next 0/3] net: make dev_close void Stephen Hemminger
@ 2017-07-18 22:59 ` Stephen Hemminger
  2017-07-21 10:37   ` kbuild test robot
  2017-07-18 22:59 ` [PATCH net-next 2/3] hns: remove useless void cast Stephen Hemminger
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2017-07-18 22:59 UTC (permalink / raw)
  To: yisen.zhuang, salil.mehta, davem, marcel, gustavo, johan.hedberg
  Cc: netdev, linux-bluetooth, Stephen Hemminger

The function dev_close in current kernel will never return an
error. Later changes will make it void.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 net/bluetooth/6lowpan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index ab3b654b05cc..e542b8959d88 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -621,9 +621,7 @@ static void ifdown(struct net_device *netdev)
 	int err;
 
 	rtnl_lock();
-	err = dev_close(netdev);
-	if (err < 0)
-		BT_INFO("iface %s cannot be closed (%d)", netdev->name, err);
+	dev_close(netdev);
 	rtnl_unlock();
 }
 
-- 
2.11.0

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

* [PATCH net-next 2/3] hns: remove useless void cast
  2017-07-18 22:59 [PATCH net-next 0/3] net: make dev_close void Stephen Hemminger
  2017-07-18 22:59 ` [PATCH net-next 1/3] bluetooth: 6lowpan dev_close never returns error Stephen Hemminger
@ 2017-07-18 22:59 ` Stephen Hemminger
       [not found] ` <20170718225927.15944-1-sthemmin-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>
  2017-07-19 23:42 ` [PATCH net-next 0/3] net: make dev_close void David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2017-07-18 22:59 UTC (permalink / raw)
  To: yisen.zhuang, salil.mehta, davem, marcel, gustavo, johan.hedberg
  Cc: netdev, linux-bluetooth, Stephen Hemminger

There is no need to cast away return value of dev_close.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
index a8db27e86a11..78cb20c67aa6 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
@@ -595,7 +595,7 @@ static void hns_nic_self_test(struct net_device *ndev,
 		set_bit(NIC_STATE_TESTING, &priv->state);
 
 		if (if_running)
-			(void)dev_close(ndev);
+			dev_close(ndev);
 
 		for (i = 0; i < SELF_TEST_TPYE_NUM; i++) {
 			if (!st_param[i][1])
-- 
2.11.0

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

* [PATCH net-next 3/3] net: make dev_close and related functions void
  2017-07-18 22:59 [PATCH net-next 0/3] net: make dev_close void Stephen Hemminger
@ 2017-07-18 22:59     ` Stephen Hemminger
  2017-07-18 22:59 ` [PATCH net-next 2/3] hns: remove useless void cast Stephen Hemminger
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2017-07-18 22:59 UTC (permalink / raw)
  To: yisen.zhuang-hv44wF8Li93QT0dZR+AlfA,
	salil.mehta-hv44wF8Li93QT0dZR+AlfA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	marcel-kz+m5ild9QBg9hUCZPvPmw, gustavo-THi1TnShQwVAfugRpC6u6w,
	johan.hedberg-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA, Stephen Hemminger

There is no useful return value from dev_close. All paths return 0.
Change dev_close and helper functions to void.

Signed-off-by: Stephen Hemminger <sthemmin-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>
---
 include/linux/netdevice.h |  4 ++--
 net/core/dev.c            | 26 +++++++++++---------------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c60351b84323..614642eb7eb7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2432,8 +2432,8 @@ struct net_device *dev_get_by_name_rcu(struct net *net, const char *name);
 struct net_device *__dev_get_by_name(struct net *net, const char *name);
 int dev_alloc_name(struct net_device *dev, const char *name);
 int dev_open(struct net_device *dev);
-int dev_close(struct net_device *dev);
-int dev_close_many(struct list_head *head, bool unlink);
+void dev_close(struct net_device *dev);
+void dev_close_many(struct list_head *head, bool unlink);
 void dev_disable_lro(struct net_device *dev);
 int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *newskb);
 int dev_queue_xmit(struct sk_buff *skb);
diff --git a/net/core/dev.c b/net/core/dev.c
index 467420eda02e..d1b9c9b6c970 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1413,7 +1413,7 @@ int dev_open(struct net_device *dev)
 }
 EXPORT_SYMBOL(dev_open);
 
-static int __dev_close_many(struct list_head *head)
+static void __dev_close_many(struct list_head *head)
 {
 	struct net_device *dev;
 
@@ -1455,23 +1455,18 @@ static int __dev_close_many(struct list_head *head)
 		dev->flags &= ~IFF_UP;
 		netpoll_poll_enable(dev);
 	}
-
-	return 0;
 }
 
-static int __dev_close(struct net_device *dev)
+static void __dev_close(struct net_device *dev)
 {
-	int retval;
 	LIST_HEAD(single);
 
 	list_add(&dev->close_list, &single);
-	retval = __dev_close_many(&single);
+	__dev_close_many(&single);
 	list_del(&single);
-
-	return retval;
 }
 
-int dev_close_many(struct list_head *head, bool unlink)
+void dev_close_many(struct list_head *head, bool unlink)
 {
 	struct net_device *dev, *tmp;
 
@@ -1488,8 +1483,6 @@ int dev_close_many(struct list_head *head, bool unlink)
 		if (unlink)
 			list_del_init(&dev->close_list);
 	}
-
-	return 0;
 }
 EXPORT_SYMBOL(dev_close_many);
 
@@ -1502,7 +1495,7 @@ EXPORT_SYMBOL(dev_close_many);
  *	is then deactivated and finally a %NETDEV_DOWN is sent to the notifier
  *	chain.
  */
-int dev_close(struct net_device *dev)
+void dev_close(struct net_device *dev)
 {
 	if (dev->flags & IFF_UP) {
 		LIST_HEAD(single);
@@ -1511,7 +1504,6 @@ int dev_close(struct net_device *dev)
 		dev_close_many(&single, true);
 		list_del(&single);
 	}
-	return 0;
 }
 EXPORT_SYMBOL(dev_close);
 
@@ -6725,8 +6717,12 @@ int __dev_change_flags(struct net_device *dev, unsigned int flags)
 	 */
 
 	ret = 0;
-	if ((old_flags ^ flags) & IFF_UP)
-		ret = ((old_flags & IFF_UP) ? __dev_close : __dev_open)(dev);
+	if ((old_flags ^ flags) & IFF_UP) {
+		if (old_flags & IFF_UP)
+			__dev_close(dev);
+		else
+			ret = __dev_open(dev);
+	}
 
 	if ((flags ^ dev->gflags) & IFF_PROMISC) {
 		int inc = (flags & IFF_PROMISC) ? 1 : -1;
-- 
2.11.0

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

* [PATCH net-next 3/3] net: make dev_close and related functions void
@ 2017-07-18 22:59     ` Stephen Hemminger
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2017-07-18 22:59 UTC (permalink / raw)
  To: yisen.zhuang, salil.mehta, davem, marcel, gustavo, johan.hedberg
  Cc: netdev, linux-bluetooth, Stephen Hemminger

There is no useful return value from dev_close. All paths return 0.
Change dev_close and helper functions to void.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 include/linux/netdevice.h |  4 ++--
 net/core/dev.c            | 26 +++++++++++---------------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c60351b84323..614642eb7eb7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2432,8 +2432,8 @@ struct net_device *dev_get_by_name_rcu(struct net *net, const char *name);
 struct net_device *__dev_get_by_name(struct net *net, const char *name);
 int dev_alloc_name(struct net_device *dev, const char *name);
 int dev_open(struct net_device *dev);
-int dev_close(struct net_device *dev);
-int dev_close_many(struct list_head *head, bool unlink);
+void dev_close(struct net_device *dev);
+void dev_close_many(struct list_head *head, bool unlink);
 void dev_disable_lro(struct net_device *dev);
 int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *newskb);
 int dev_queue_xmit(struct sk_buff *skb);
diff --git a/net/core/dev.c b/net/core/dev.c
index 467420eda02e..d1b9c9b6c970 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1413,7 +1413,7 @@ int dev_open(struct net_device *dev)
 }
 EXPORT_SYMBOL(dev_open);
 
-static int __dev_close_many(struct list_head *head)
+static void __dev_close_many(struct list_head *head)
 {
 	struct net_device *dev;
 
@@ -1455,23 +1455,18 @@ static int __dev_close_many(struct list_head *head)
 		dev->flags &= ~IFF_UP;
 		netpoll_poll_enable(dev);
 	}
-
-	return 0;
 }
 
-static int __dev_close(struct net_device *dev)
+static void __dev_close(struct net_device *dev)
 {
-	int retval;
 	LIST_HEAD(single);
 
 	list_add(&dev->close_list, &single);
-	retval = __dev_close_many(&single);
+	__dev_close_many(&single);
 	list_del(&single);
-
-	return retval;
 }
 
-int dev_close_many(struct list_head *head, bool unlink)
+void dev_close_many(struct list_head *head, bool unlink)
 {
 	struct net_device *dev, *tmp;
 
@@ -1488,8 +1483,6 @@ int dev_close_many(struct list_head *head, bool unlink)
 		if (unlink)
 			list_del_init(&dev->close_list);
 	}
-
-	return 0;
 }
 EXPORT_SYMBOL(dev_close_many);
 
@@ -1502,7 +1495,7 @@ EXPORT_SYMBOL(dev_close_many);
  *	is then deactivated and finally a %NETDEV_DOWN is sent to the notifier
  *	chain.
  */
-int dev_close(struct net_device *dev)
+void dev_close(struct net_device *dev)
 {
 	if (dev->flags & IFF_UP) {
 		LIST_HEAD(single);
@@ -1511,7 +1504,6 @@ int dev_close(struct net_device *dev)
 		dev_close_many(&single, true);
 		list_del(&single);
 	}
-	return 0;
 }
 EXPORT_SYMBOL(dev_close);
 
@@ -6725,8 +6717,12 @@ int __dev_change_flags(struct net_device *dev, unsigned int flags)
 	 */
 
 	ret = 0;
-	if ((old_flags ^ flags) & IFF_UP)
-		ret = ((old_flags & IFF_UP) ? __dev_close : __dev_open)(dev);
+	if ((old_flags ^ flags) & IFF_UP) {
+		if (old_flags & IFF_UP)
+			__dev_close(dev);
+		else
+			ret = __dev_open(dev);
+	}
 
 	if ((flags ^ dev->gflags) & IFF_PROMISC) {
 		int inc = (flags & IFF_PROMISC) ? 1 : -1;
-- 
2.11.0

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

* Re: [PATCH net-next 0/3] net: make dev_close void
  2017-07-18 22:59 [PATCH net-next 0/3] net: make dev_close void Stephen Hemminger
                   ` (2 preceding siblings ...)
       [not found] ` <20170718225927.15944-1-sthemmin-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>
@ 2017-07-19 23:42 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-07-19 23:42 UTC (permalink / raw)
  To: stephen
  Cc: yisen.zhuang, salil.mehta, marcel, gustavo, johan.hedberg,
	netdev, linux-bluetooth, sthemmin

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Tue, 18 Jul 2017 15:59:24 -0700

> Noticed while working on other changes. Why is dev_close()
> returning int, it should be void.  Should also change
> ndo_close to be void, but that requires more work and someone
> with more coccinelle foo (smpl) than me.

Series applied, thanks.

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

* Re: [PATCH net-next 1/3] bluetooth: 6lowpan dev_close never returns error
  2017-07-18 22:59 ` [PATCH net-next 1/3] bluetooth: 6lowpan dev_close never returns error Stephen Hemminger
@ 2017-07-21 10:37   ` kbuild test robot
  2017-07-22  6:42     ` Marcel Holtmann
  0 siblings, 1 reply; 8+ messages in thread
From: kbuild test robot @ 2017-07-21 10:37 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: kbuild-all, yisen.zhuang, salil.mehta, davem, marcel, gustavo,
	johan.hedberg, netdev, linux-bluetooth, Stephen Hemminger

[-- Attachment #1: Type: text/plain, Size: 1545 bytes --]

Hi Stephen,

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Stephen-Hemminger/net-make-dev_close-void/20170720-090123
config: x86_64-randconfig-a0-07211734 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   net/bluetooth/6lowpan.c: In function 'ifdown':
>> net/bluetooth/6lowpan.c:621: warning: unused variable 'err'

vim +/err +621 net/bluetooth/6lowpan.c

18722c24 Jukka Rissanen    2013-12-11  618  
7f118253 Jukka Rissanen    2014-06-18  619  static void ifdown(struct net_device *netdev)
7f118253 Jukka Rissanen    2014-06-18  620  {
7f118253 Jukka Rissanen    2014-06-18 @621  	int err;
7f118253 Jukka Rissanen    2014-06-18  622  
7f118253 Jukka Rissanen    2014-06-18  623  	rtnl_lock();
ca74f73e Stephen Hemminger 2017-07-18  624  	dev_close(netdev);
7f118253 Jukka Rissanen    2014-06-18  625  	rtnl_unlock();
7f118253 Jukka Rissanen    2014-06-18  626  }
7f118253 Jukka Rissanen    2014-06-18  627  

:::::: The code at line 621 was first introduced by commit
:::::: 7f118253820fc3ad38659485adb3ebdfe64820e1 Bluetooth: 6LoWPAN: Remove network devices when unloading

:::::: TO: Jukka Rissanen <jukka.rissanen@linux.intel.com>
:::::: CC: Marcel Holtmann <marcel@holtmann.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30222 bytes --]

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

* Re: [PATCH net-next 1/3] bluetooth: 6lowpan dev_close never returns error
  2017-07-21 10:37   ` kbuild test robot
@ 2017-07-22  6:42     ` Marcel Holtmann
  0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2017-07-22  6:42 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Stephen Hemminger, kbuild-all, yisen.zhuang, salil.mehta,
	David S. Miller, Gustavo F. Padovan, Johan Hedberg, netdev,
	linux-bluetooth, Stephen Hemminger

Hi Stephen,

> [auto build test WARNING on net-next/master]
> 
> url:    https://github.com/0day-ci/linux/commits/Stephen-Hemminger/net-make-dev_close-void/20170720-090123
> config: x86_64-randconfig-a0-07211734 (attached as .config)
> compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
> reproduce:
>        # save the attached .config to linux build tree
>        make ARCH=x86_64 
> 
> All warnings (new ones prefixed by >>):
> 
>   net/bluetooth/6lowpan.c: In function 'ifdown':
>>> net/bluetooth/6lowpan.c:621: warning: unused variable 'err'
> 
> vim +/err +621 net/bluetooth/6lowpan.c
> 
> 18722c24 Jukka Rissanen    2013-12-11  618  
> 7f118253 Jukka Rissanen    2014-06-18  619  static void ifdown(struct net_device *netdev)
> 7f118253 Jukka Rissanen    2014-06-18  620  {
> 7f118253 Jukka Rissanen    2014-06-18 @621  	int err;
> 7f118253 Jukka Rissanen    2014-06-18  622  
> 7f118253 Jukka Rissanen    2014-06-18  623  	rtnl_lock();
> ca74f73e Stephen Hemminger 2017-07-18  624  	dev_close(netdev);
> 7f118253 Jukka Rissanen    2014-06-18  625  	rtnl_unlock();
> 7f118253 Jukka Rissanen    2014-06-18  626  }
> 7f118253 Jukka Rissanen    2014-06-18  627  
> 
> :::::: The code at line 621 was first introduced by commit
> :::::: 7f118253820fc3ad38659485adb3ebdfe64820e1 Bluetooth: 6LoWPAN: Remove network devices when unloading
> 
> :::::: TO: Jukka Rissanen <jukka.rissanen@linux.intel.com>
> :::::: CC: Marcel Holtmann <marcel@holtmann.org>

are you going to send a fix for this?

Regards

Marcel

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

end of thread, other threads:[~2017-07-22  6:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-18 22:59 [PATCH net-next 0/3] net: make dev_close void Stephen Hemminger
2017-07-18 22:59 ` [PATCH net-next 1/3] bluetooth: 6lowpan dev_close never returns error Stephen Hemminger
2017-07-21 10:37   ` kbuild test robot
2017-07-22  6:42     ` Marcel Holtmann
2017-07-18 22:59 ` [PATCH net-next 2/3] hns: remove useless void cast Stephen Hemminger
     [not found] ` <20170718225927.15944-1-sthemmin-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>
2017-07-18 22:59   ` [PATCH net-next 3/3] net: make dev_close and related functions void Stephen Hemminger
2017-07-18 22:59     ` Stephen Hemminger
2017-07-19 23:42 ` [PATCH net-next 0/3] net: make dev_close void David Miller

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.