linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/net/usb/r8152: change rtl8152_system_suspend to be void function
@ 2018-08-08 14:26 zhong jiang
  2018-08-09  1:42 ` zhong jiang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: zhong jiang @ 2018-08-08 14:26 UTC (permalink / raw)
  To: davem, edumazet; +Cc: netdev, linux-kernel

rtl8152_system_suspend defines the variable "ret", but it is not modified
after initialization. Further, I find that any of the callees do not
handle the return value. So It is safe to drop the variable and make it to
be void function.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/net/usb/r8152.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 124211a..cc51ac8 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -4412,10 +4412,9 @@ static int rtl8152_runtime_suspend(struct r8152 *tp)
 	return ret;
 }
 
-static int rtl8152_system_suspend(struct r8152 *tp)
+static void rtl8152_system_suspend(struct r8152 *tp)
 {
 	struct net_device *netdev = tp->netdev;
-	int ret = 0;
 
 	netif_device_detach(netdev);
 
@@ -4429,8 +4428,6 @@ static int rtl8152_system_suspend(struct r8152 *tp)
 		tp->rtl_ops.down(tp);
 		napi_enable(napi);
 	}
-
-	return ret;
 }
 
 static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
@@ -4443,7 +4440,7 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
 	if (PMSG_IS_AUTO(message))
 		ret = rtl8152_runtime_suspend(tp);
 	else
-		ret = rtl8152_system_suspend(tp);
+		rtl8152_system_suspend(tp);
 
 	mutex_unlock(&tp->control);
 
-- 
1.7.12.4


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

* Re: [PATCH] drivers/net/usb/r8152: change rtl8152_system_suspend to be void function
  2018-08-08 14:26 [PATCH] drivers/net/usb/r8152: change rtl8152_system_suspend to be void function zhong jiang
@ 2018-08-09  1:42 ` zhong jiang
  2018-08-09  3:47 ` kbuild test robot
  2018-08-12 22:09 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: zhong jiang @ 2018-08-09  1:42 UTC (permalink / raw)
  To: davem, edumazet; +Cc: netdev, linux-kernel

Igore the patch, will repost, Thanks
On 2018/8/8 22:26, zhong jiang wrote:
> rtl8152_system_suspend defines the variable "ret", but it is not modified
> after initialization. Further, I find that any of the callees do not
> handle the return value. So It is safe to drop the variable and make it to
> be void function.
>
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  drivers/net/usb/r8152.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 124211a..cc51ac8 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -4412,10 +4412,9 @@ static int rtl8152_runtime_suspend(struct r8152 *tp)
>  	return ret;
>  }
>  
> -static int rtl8152_system_suspend(struct r8152 *tp)
> +static void rtl8152_system_suspend(struct r8152 *tp)
>  {
>  	struct net_device *netdev = tp->netdev;
> -	int ret = 0;
>  
>  	netif_device_detach(netdev);
>  
> @@ -4429,8 +4428,6 @@ static int rtl8152_system_suspend(struct r8152 *tp)
>  		tp->rtl_ops.down(tp);
>  		napi_enable(napi);
>  	}
> -
> -	return ret;
>  }
>  
>  static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
> @@ -4443,7 +4440,7 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
>  	if (PMSG_IS_AUTO(message))
>  		ret = rtl8152_runtime_suspend(tp);
>  	else
> -		ret = rtl8152_system_suspend(tp);
> +		rtl8152_system_suspend(tp);
>  
>  	mutex_unlock(&tp->control);
>  



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

* Re: [PATCH] drivers/net/usb/r8152: change rtl8152_system_suspend to be void function
  2018-08-08 14:26 [PATCH] drivers/net/usb/r8152: change rtl8152_system_suspend to be void function zhong jiang
  2018-08-09  1:42 ` zhong jiang
@ 2018-08-09  3:47 ` kbuild test robot
  2018-08-12 22:09 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2018-08-09  3:47 UTC (permalink / raw)
  To: zhong jiang; +Cc: kbuild-all, davem, edumazet, netdev, linux-kernel

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

Hi zhong,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on v4.18-rc8 next-20180808]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/zhong-jiang/drivers-net-usb-r8152-change-rtl8152_system_suspend-to-be-void-function/20180809-111737
config: i386-randconfig-x017-201831 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/net//usb/r8152.c: In function 'rtl8152_suspend':
>> drivers/net//usb/r8152.c:4447:9: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return ret;
            ^~~

vim +/ret +4447 drivers/net//usb/r8152.c

8fb280616 hayeswang   2017-01-10  4432  
8fb280616 hayeswang   2017-01-10  4433  static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
8fb280616 hayeswang   2017-01-10  4434  {
8fb280616 hayeswang   2017-01-10  4435  	struct r8152 *tp = usb_get_intfdata(intf);
8fb280616 hayeswang   2017-01-10  4436  	int ret;
8fb280616 hayeswang   2017-01-10  4437  
8fb280616 hayeswang   2017-01-10  4438  	mutex_lock(&tp->control);
8fb280616 hayeswang   2017-01-10  4439  
8fb280616 hayeswang   2017-01-10  4440  	if (PMSG_IS_AUTO(message))
a9c54ad2c hayeswang   2017-01-25  4441  		ret = rtl8152_runtime_suspend(tp);
8fb280616 hayeswang   2017-01-10  4442  	else
31b61d6a0 zhong jiang 2018-08-08  4443  		rtl8152_system_suspend(tp);
8fb280616 hayeswang   2017-01-10  4444  
b54032736 hayeswang   2014-10-09  4445  	mutex_unlock(&tp->control);
b54032736 hayeswang   2014-10-09  4446  
6cc69f2a4 hayeswang   2014-10-17 @4447  	return ret;
ac718b693 hayeswang   2013-05-02  4448  }
ac718b693 hayeswang   2013-05-02  4449  

:::::: The code at line 4447 was first introduced by commit
:::::: 6cc69f2a404dea8641d6cf97c0fbe8d24579e259 r8152: return -EBUSY for runtime suspend

:::::: TO: hayeswang <hayeswang@realtek.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
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: 33626 bytes --]

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

* Re: [PATCH] drivers/net/usb/r8152: change rtl8152_system_suspend to be void function
  2018-08-08 14:26 [PATCH] drivers/net/usb/r8152: change rtl8152_system_suspend to be void function zhong jiang
  2018-08-09  1:42 ` zhong jiang
  2018-08-09  3:47 ` kbuild test robot
@ 2018-08-12 22:09 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-08-12 22:09 UTC (permalink / raw)
  To: kbuild, zhong jiang; +Cc: kbuild-all, davem, edumazet, netdev, linux-kernel

Hi zhong,

Thank you for the patch! Perhaps something to improve:

url:    https://github.com/0day-ci/linux/commits/zhong-jiang/drivers-net-usb-r8152-change-rtl8152_system_suspend-to-be-void-function/20180809-111737

New smatch warnings:
drivers/net/usb/r8152.c:4447 rtl8152_suspend() error: uninitialized symbol 'ret'.

Old smatch warnings:
drivers/net/usb/r8152.c:4660 rtl8152_get_strings() error: memcpy() '*rtl8152_gstrings' too small (32 vs 416)

# https://github.com/0day-ci/linux/commit/31b61d6a0989c067332fa1ae07055b3e406c17cd
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 31b61d6a0989c067332fa1ae07055b3e406c17cd
vim +/ret +4447 drivers/net/usb/r8152.c

8fb280616 hayeswang   2017-01-10  4432  
8fb280616 hayeswang   2017-01-10  4433  static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
8fb280616 hayeswang   2017-01-10  4434  {
8fb280616 hayeswang   2017-01-10  4435  	struct r8152 *tp = usb_get_intfdata(intf);
8fb280616 hayeswang   2017-01-10  4436  	int ret;
8fb280616 hayeswang   2017-01-10  4437  
8fb280616 hayeswang   2017-01-10  4438  	mutex_lock(&tp->control);
8fb280616 hayeswang   2017-01-10  4439  
8fb280616 hayeswang   2017-01-10  4440  	if (PMSG_IS_AUTO(message))
a9c54ad2c hayeswang   2017-01-25  4441  		ret = rtl8152_runtime_suspend(tp);
8fb280616 hayeswang   2017-01-10  4442  	else
31b61d6a0 zhong jiang 2018-08-08  4443  		rtl8152_system_suspend(tp);
8fb280616 hayeswang   2017-01-10  4444  
b54032736 hayeswang   2014-10-09  4445  	mutex_unlock(&tp->control);
b54032736 hayeswang   2014-10-09  4446  
6cc69f2a4 hayeswang   2014-10-17 @4447  	return ret;
ac718b693 hayeswang   2013-05-02  4448  }
ac718b693 hayeswang   2013-05-02  4449  

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

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

end of thread, other threads:[~2018-08-12 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-08 14:26 [PATCH] drivers/net/usb/r8152: change rtl8152_system_suspend to be void function zhong jiang
2018-08-09  1:42 ` zhong jiang
2018-08-09  3:47 ` kbuild test robot
2018-08-12 22:09 ` Dan Carpenter

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).