diff mbox series

[-next] IB/hfi1: Remove set but not used variable 'priv'

Message ID 20200528075946.123480-1-yuehaibing@huawei.com (mailing list archive)
State Changes Requested
Headers show
Series [-next] IB/hfi1: Remove set but not used variable 'priv' | expand

Commit Message

Yue Haibing May 28, 2020, 7:59 a.m. UTC
drivers/infiniband/hw/hfi1/netdev_rx.c: In function 'hfi1_netdev_free':
drivers/infiniband/hw/hfi1/netdev_rx.c:374:27: warning:
 variable 'priv' set but not used [-Wunused-but-set-variable]

It is never used, so can be removed, then null check before
kfree is unneeded.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/infiniband/hw/hfi1/netdev_rx.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Marciniszyn, Mike May 28, 2020, 11:25 a.m. UTC | #1
> From: YueHaibing <yuehaibing@huawei.com>
> Sent: Thursday, May 28, 2020 4:00 AM
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/infiniband/hw/hfi1/netdev_rx.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/netdev_rx.c
> b/drivers/infiniband/hw/hfi1/netdev_rx.c
> index 58af6a454761..bd6546b52159 100644
> --- a/drivers/infiniband/hw/hfi1/netdev_rx.c
> +++ b/drivers/infiniband/hw/hfi1/netdev_rx.c
> @@ -371,14 +371,9 @@ int hfi1_netdev_alloc(struct hfi1_devdata *dd)
> 
>  void hfi1_netdev_free(struct hfi1_devdata *dd)
>  {
> -	struct hfi1_netdev_priv *priv;
> -
> -	if (dd->dummy_netdev) {
> -		priv = hfi1_netdev_priv(dd->dummy_netdev);
> -		dd_dev_info(dd, "hfi1 netdev freed\n");
> -		kfree(dd->dummy_netdev);
> -		dd->dummy_netdev = NULL;
> -	}
> +	dd_dev_info(dd, "hfi1 netdev freed\n");
> +	kfree(dd->dummy_netdev);

Dan Carpenter has reported kfree() should be free_netdev()...

Mike
Dennis Dalessandro June 1, 2020, 1:45 p.m. UTC | #2
On 5/28/2020 7:25 AM, Marciniszyn, Mike wrote:
>> From: YueHaibing <yuehaibing@huawei.com>
>> Sent: Thursday, May 28, 2020 4:00 AM
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>>   drivers/infiniband/hw/hfi1/netdev_rx.c | 11 +++--------
>>   1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/infiniband/hw/hfi1/netdev_rx.c
>> b/drivers/infiniband/hw/hfi1/netdev_rx.c
>> index 58af6a454761..bd6546b52159 100644
>> --- a/drivers/infiniband/hw/hfi1/netdev_rx.c
>> +++ b/drivers/infiniband/hw/hfi1/netdev_rx.c
>> @@ -371,14 +371,9 @@ int hfi1_netdev_alloc(struct hfi1_devdata *dd)
>>
>>   void hfi1_netdev_free(struct hfi1_devdata *dd)
>>   {
>> -struct hfi1_netdev_priv *priv;
>> -
>> -if (dd->dummy_netdev) {
>> -priv = hfi1_netdev_priv(dd->dummy_netdev);
>> -dd_dev_info(dd, "hfi1 netdev freed\n");
>> -kfree(dd->dummy_netdev);
>> -dd->dummy_netdev = NULL;
>> -}
>> +dd_dev_info(dd, "hfi1 netdev freed\n");
>> +kfree(dd->dummy_netdev);
> 
> Dan Carpenter has reported kfree() should be free_netdev()...
> 
> Mike
> 

I'm OK with this patch going in and then adding a separate one to fix 
the kfree. Or this one can be touched up to include that as well.

-Denny
Jason Gunthorpe June 1, 2020, 1:56 p.m. UTC | #3
On Mon, Jun 01, 2020 at 09:45:52AM -0400, Dennis Dalessandro wrote:
> On 5/28/2020 7:25 AM, Marciniszyn, Mike wrote:
> > > From: YueHaibing <yuehaibing@huawei.com>
> > > Sent: Thursday, May 28, 2020 4:00 AM
> > > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > >   drivers/infiniband/hw/hfi1/netdev_rx.c | 11 +++--------
> > >   1 file changed, 3 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/drivers/infiniband/hw/hfi1/netdev_rx.c
> > > b/drivers/infiniband/hw/hfi1/netdev_rx.c
> > > index 58af6a454761..bd6546b52159 100644
> > > +++ b/drivers/infiniband/hw/hfi1/netdev_rx.c
> > > @@ -371,14 +371,9 @@ int hfi1_netdev_alloc(struct hfi1_devdata *dd)
> > > 
> > >   void hfi1_netdev_free(struct hfi1_devdata *dd)
> > >   {
> > > -struct hfi1_netdev_priv *priv;
> > > -
> > > -if (dd->dummy_netdev) {
> > > -priv = hfi1_netdev_priv(dd->dummy_netdev);
> > > -dd_dev_info(dd, "hfi1 netdev freed\n");
> > > -kfree(dd->dummy_netdev);
> > > -dd->dummy_netdev = NULL;
> > > -}
> > > +dd_dev_info(dd, "hfi1 netdev freed\n");
> > > +kfree(dd->dummy_netdev);
> > 
> > Dan Carpenter has reported kfree() should be free_netdev()...
> > 
> > Mike
> > 
> 
> I'm OK with this patch going in and then adding a separate one to fix the
> kfree. Or this one can be touched up to include that as well.

Please resend it with both things fixed

Jason
Yue Haibing June 2, 2020, 12:59 a.m. UTC | #4
On 2020/6/1 21:56, Jason Gunthorpe wrote:
> On Mon, Jun 01, 2020 at 09:45:52AM -0400, Dennis Dalessandro wrote:
>> On 5/28/2020 7:25 AM, Marciniszyn, Mike wrote:
>>>> From: YueHaibing <yuehaibing@huawei.com>
>>>> Sent: Thursday, May 28, 2020 4:00 AM
>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>>>   drivers/infiniband/hw/hfi1/netdev_rx.c | 11 +++--------
>>>>   1 file changed, 3 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/drivers/infiniband/hw/hfi1/netdev_rx.c
>>>> b/drivers/infiniband/hw/hfi1/netdev_rx.c
>>>> index 58af6a454761..bd6546b52159 100644
>>>> +++ b/drivers/infiniband/hw/hfi1/netdev_rx.c
>>>> @@ -371,14 +371,9 @@ int hfi1_netdev_alloc(struct hfi1_devdata *dd)
>>>>
>>>>   void hfi1_netdev_free(struct hfi1_devdata *dd)
>>>>   {
>>>> -struct hfi1_netdev_priv *priv;
>>>> -
>>>> -if (dd->dummy_netdev) {
>>>> -priv = hfi1_netdev_priv(dd->dummy_netdev);
>>>> -dd_dev_info(dd, "hfi1 netdev freed\n");
>>>> -kfree(dd->dummy_netdev);
>>>> -dd->dummy_netdev = NULL;
>>>> -}
>>>> +dd_dev_info(dd, "hfi1 netdev freed\n");
>>>> +kfree(dd->dummy_netdev);
>>>
>>> Dan Carpenter has reported kfree() should be free_netdev()...
>>>
>>> Mike
>>>
>>
>> I'm OK with this patch going in and then adding a separate one to fix the
>> kfree. Or this one can be touched up to include that as well.
> 
> Please resend it with both things fixed

Ok, will do that in v2.
> 
> Jason
> 
>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hfi1/netdev_rx.c b/drivers/infiniband/hw/hfi1/netdev_rx.c
index 58af6a454761..bd6546b52159 100644
--- a/drivers/infiniband/hw/hfi1/netdev_rx.c
+++ b/drivers/infiniband/hw/hfi1/netdev_rx.c
@@ -371,14 +371,9 @@  int hfi1_netdev_alloc(struct hfi1_devdata *dd)
 
 void hfi1_netdev_free(struct hfi1_devdata *dd)
 {
-	struct hfi1_netdev_priv *priv;
-
-	if (dd->dummy_netdev) {
-		priv = hfi1_netdev_priv(dd->dummy_netdev);
-		dd_dev_info(dd, "hfi1 netdev freed\n");
-		kfree(dd->dummy_netdev);
-		dd->dummy_netdev = NULL;
-	}
+	dd_dev_info(dd, "hfi1 netdev freed\n");
+	kfree(dd->dummy_netdev);
+	dd->dummy_netdev = NULL;
 }
 
 /**