diff mbox

[2/2] IB/rxe: remove unnecessary initialization

Message ID 1521339691-27879-2-git-send-email-yanjun.zhu@oracle.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Zhu Yanjun March 18, 2018, 2:21 a.m. UTC
The variable rc is assigned beforce it is used. So it is not
necessary to initialize it.

CC: Srinivas Eeda <srinivas.eeda@oracle.com>
CC: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
---
 drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

kernel test robot March 18, 2018, 7:03 a.m. UTC | #1
Hi Zhu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.16-rc5 next-20180316]
[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/Zhu-Yanjun/IB-rxe-optimize-the-recv-process/20180318-130259
config: i386-randconfig-x072-201811 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 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/infiniband/sw/rxe/rxe_verbs.c: In function 'rxe_query_port':
>> drivers/infiniband/sw/rxe/rxe_verbs.c:77:9: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return rc;
            ^~

vim +/rc +77 drivers/infiniband/sw/rxe/rxe_verbs.c

8700e3e7c Moni Shoua   2016-06-16  53  
8700e3e7c Moni Shoua   2016-06-16  54  static int rxe_query_port(struct ib_device *dev,
8700e3e7c Moni Shoua   2016-06-16  55  			  u8 port_num, struct ib_port_attr *attr)
8700e3e7c Moni Shoua   2016-06-16  56  {
8700e3e7c Moni Shoua   2016-06-16  57  	struct rxe_dev *rxe = to_rdev(dev);
8700e3e7c Moni Shoua   2016-06-16  58  	struct rxe_port *port;
6c58dc395 Zhu Yanjun   2018-03-17  59  	int rc;
8700e3e7c Moni Shoua   2016-06-16  60  
8700e3e7c Moni Shoua   2016-06-16  61  	if (unlikely(port_num != 1)) {
8700e3e7c Moni Shoua   2016-06-16  62  		pr_warn("invalid port_number %d\n", port_num);
d41861942 Yuval Shaia  2017-06-14  63  		goto out;
8700e3e7c Moni Shoua   2016-06-16  64  	}
8700e3e7c Moni Shoua   2016-06-16  65  
8700e3e7c Moni Shoua   2016-06-16  66  	port = &rxe->port;
8700e3e7c Moni Shoua   2016-06-16  67  
c4550c63b Or Gerlitz   2017-01-24  68  	/* *attr being zeroed by the caller, avoid zeroing it here */
8700e3e7c Moni Shoua   2016-06-16  69  	*attr = port->attr;
8700e3e7c Moni Shoua   2016-06-16  70  
8700e3e7c Moni Shoua   2016-06-16  71  	mutex_lock(&rxe->usdev_lock);
d41861942 Yuval Shaia  2017-06-14  72  	rc = ib_get_eth_speed(dev, port_num, &attr->active_speed,
e404f945a Parav Pandit 2016-09-28  73  			      &attr->active_width);
8700e3e7c Moni Shoua   2016-06-16  74  	mutex_unlock(&rxe->usdev_lock);
8700e3e7c Moni Shoua   2016-06-16  75  
d41861942 Yuval Shaia  2017-06-14  76  out:
d41861942 Yuval Shaia  2017-06-14 @77  	return rc;
8700e3e7c Moni Shoua   2016-06-16  78  }
8700e3e7c Moni Shoua   2016-06-16  79  

:::::: The code at line 77 was first introduced by commit
:::::: d41861942fc55c14b6280d9568a0d0112037f065 IB/core: Add generic function to extract IB speed from netdev

:::::: TO: Yuval Shaia <yuval.shaia@oracle.com>
:::::: CC: Doug Ledford <dledford@redhat.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Yuval Shaia March 18, 2018, 8:22 p.m. UTC | #2
On Sat, Mar 17, 2018 at 10:21:31PM -0400, Zhu Yanjun wrote:
> The variable rc is assigned beforce it is used. So it is not
> necessary to initialize it.
> 
> CC: Srinivas Eeda <srinivas.eeda@oracle.com>
> CC: Junxiao Bi <junxiao.bi@oracle.com>
> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index f4bab2c..316be50 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -56,7 +56,7 @@ static int rxe_query_port(struct ib_device *dev,
>  {
>  	struct rxe_dev *rxe = to_rdev(dev);
>  	struct rxe_port *port;
> -	int rc = -EINVAL;
> +	int rc;
>  
>  	if (unlikely(port_num != 1)) {
>  		pr_warn("invalid port_number %d\n", port_num);

But then we will goto out with uninitialized rc.

> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhu Yanjun March 19, 2018, 12:55 a.m. UTC | #3
On 2018/3/19 4:22, Yuval Shaia wrote:
> On Sat, Mar 17, 2018 at 10:21:31PM -0400, Zhu Yanjun wrote:
>> The variable rc is assigned beforce it is used. So it is not
>> necessary to initialize it.
>>
>> CC: Srinivas Eeda <srinivas.eeda@oracle.com>
>> CC: Junxiao Bi <junxiao.bi@oracle.com>
>> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
>> ---
>>   drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
>> index f4bab2c..316be50 100644
>> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
>> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
>> @@ -56,7 +56,7 @@ static int rxe_query_port(struct ib_device *dev,
>>   {
>>   	struct rxe_dev *rxe = to_rdev(dev);
>>   	struct rxe_port *port;
>> -	int rc = -EINVAL;
>> +	int rc;
>>   
>>   	if (unlikely(port_num != 1)) {
>>   		pr_warn("invalid port_number %d\n", port_num);
> But then we will goto out with uninitialized rc.
Hi, all

Sure. My bad. Please ignore this patch.

Zhu Yanjun
>
>> -- 
>> 2.7.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index f4bab2c..316be50 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -56,7 +56,7 @@  static int rxe_query_port(struct ib_device *dev,
 {
 	struct rxe_dev *rxe = to_rdev(dev);
 	struct rxe_port *port;
-	int rc = -EINVAL;
+	int rc;
 
 	if (unlikely(port_num != 1)) {
 		pr_warn("invalid port_number %d\n", port_num);