All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fpga: fpga-mgr: remove unnecessary code in __fpga_mgr_get
@ 2017-10-26 23:02 Gustavo A. R. Silva
  2017-10-27 18:30 ` Alan Tull
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-26 23:02 UTC (permalink / raw)
  To: Alan Tull, Moritz Fischer; +Cc: linux-fpga, linux-kernel, Gustavo A. R. Silva

Notice that mgr = to_fpga_manager(dev); expands to:

mgr = container_of(dev, struct fpga_manager, dev);

and container_of is never null, so this null check is
unnecessary.

Addresses-Coverity-ID: 1397916
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/fpga/fpga-mgr.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 188ffef..33063ca 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -367,8 +367,6 @@ static struct fpga_manager *__fpga_mgr_get(struct device *dev)
 	int ret = -ENODEV;
 
 	mgr = to_fpga_manager(dev);
-	if (!mgr)
-		goto err_dev;
 
 	/* Get exclusive use of fpga manager */
 	if (!mutex_trylock(&mgr->ref_mutex)) {
-- 
2.7.4

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

* Re: [PATCH] fpga: fpga-mgr: remove unnecessary code in __fpga_mgr_get
  2017-10-26 23:02 [PATCH] fpga: fpga-mgr: remove unnecessary code in __fpga_mgr_get Gustavo A. R. Silva
@ 2017-10-27 18:30 ` Alan Tull
  2017-10-27 19:09   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Tull @ 2017-10-27 18:30 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Moritz Fischer, linux-fpga, linux-kernel

On Thu, Oct 26, 2017 at 6:02 PM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:

Hi Gustavo,

Thanks for pointing that out.  There's also a similar thing in
fpga-bridge.c that I need to fix.

Alan

> Notice that mgr = to_fpga_manager(dev); expands to:
>
> mgr = container_of(dev, struct fpga_manager, dev);
>
> and container_of is never null, so this null check is
> unnecessary.
>
> Addresses-Coverity-ID: 1397916
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/fpga/fpga-mgr.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index 188ffef..33063ca 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -367,8 +367,6 @@ static struct fpga_manager *__fpga_mgr_get(struct device *dev)
>         int ret = -ENODEV;
>
>         mgr = to_fpga_manager(dev);
> -       if (!mgr)
> -               goto err_dev;
>
>         /* Get exclusive use of fpga manager */
>         if (!mutex_trylock(&mgr->ref_mutex)) {
> --
> 2.7.4
>

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

* Re: [PATCH] fpga: fpga-mgr: remove unnecessary code in __fpga_mgr_get
  2017-10-27 18:30 ` Alan Tull
@ 2017-10-27 19:09   ` Gustavo A. R. Silva
  2017-10-27 19:49     ` Alan Tull
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-27 19:09 UTC (permalink / raw)
  To: Alan Tull; +Cc: Moritz Fischer, linux-fpga, linux-kernel

Hi Alan,

Quoting Alan Tull <atull@kernel.org>:

> On Thu, Oct 26, 2017 at 6:02 PM, Gustavo A. R. Silva
> <garsilva@embeddedor.com> wrote:
>
> Hi Gustavo,
>
> Thanks for pointing that out.  There's also a similar thing in
> fpga-bridge.c that I need to fix.
>

Can you share with me what exactly are you trying to fix?

If the issue is similar I might be able to help.

Thanks
--
Gustavo A. R. Silva

> Alan
>
>> Notice that mgr = to_fpga_manager(dev); expands to:
>>
>> mgr = container_of(dev, struct fpga_manager, dev);
>>
>> and container_of is never null, so this null check is
>> unnecessary.
>>
>> Addresses-Coverity-ID: 1397916
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>> ---
>>  drivers/fpga/fpga-mgr.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
>> index 188ffef..33063ca 100644
>> --- a/drivers/fpga/fpga-mgr.c
>> +++ b/drivers/fpga/fpga-mgr.c
>> @@ -367,8 +367,6 @@ static struct fpga_manager  
>> *__fpga_mgr_get(struct device *dev)
>>         int ret = -ENODEV;
>>
>>         mgr = to_fpga_manager(dev);
>> -       if (!mgr)
>> -               goto err_dev;
>>
>>         /* Get exclusive use of fpga manager */
>>         if (!mutex_trylock(&mgr->ref_mutex)) {
>> --
>> 2.7.4
>>







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

* Re: [PATCH] fpga: fpga-mgr: remove unnecessary code in __fpga_mgr_get
  2017-10-27 19:09   ` Gustavo A. R. Silva
@ 2017-10-27 19:49     ` Alan Tull
  2017-10-27 19:55       ` Gustavo A. R. Silva
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Tull @ 2017-10-27 19:49 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Moritz Fischer, linux-fpga, linux-kernel

On Fri, Oct 27, 2017 at 2:09 PM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> Hi Alan,
>
> Quoting Alan Tull <atull@kernel.org>:
>
>> On Thu, Oct 26, 2017 at 6:02 PM, Gustavo A. R. Silva
>> <garsilva@embeddedor.com> wrote:
>>
>> Hi Gustavo,
>>
>> Thanks for pointing that out.  There's also a similar thing in
>> fpga-bridge.c that I need to fix.
>>
>
> Can you share with me what exactly are you trying to fix?
>
> If the issue is similar I might be able to help.

Same fix, but in of_fpga_bridge_get.  Checks the output of
to_fpga_bridge for NULL.

Thanks,
Alan

>
> Thanks
> --
> Gustavo A. R. Silva
>
>> Alan
>>
>>> Notice that mgr = to_fpga_manager(dev); expands to:
>>>
>>> mgr = container_of(dev, struct fpga_manager, dev);
>>>
>>> and container_of is never null, so this null check is
>>> unnecessary.
>>>
>>> Addresses-Coverity-ID: 1397916
>>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>>> ---
>>>  drivers/fpga/fpga-mgr.c | 2 --
>>>  1 file changed, 2 deletions(-)
>>>
>>> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
>>> index 188ffef..33063ca 100644
>>> --- a/drivers/fpga/fpga-mgr.c
>>> +++ b/drivers/fpga/fpga-mgr.c
>>> @@ -367,8 +367,6 @@ static struct fpga_manager *__fpga_mgr_get(struct
>>> device *dev)
>>>         int ret = -ENODEV;
>>>
>>>         mgr = to_fpga_manager(dev);
>>> -       if (!mgr)
>>> -               goto err_dev;
>>>
>>>         /* Get exclusive use of fpga manager */
>>>         if (!mutex_trylock(&mgr->ref_mutex)) {
>>> --
>>> 2.7.4

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

* Re: [PATCH] fpga: fpga-mgr: remove unnecessary code in __fpga_mgr_get
  2017-10-27 19:49     ` Alan Tull
@ 2017-10-27 19:55       ` Gustavo A. R. Silva
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-27 19:55 UTC (permalink / raw)
  To: Alan Tull; +Cc: Moritz Fischer, linux-fpga, linux-kernel


Quoting Alan Tull <atull@kernel.org>:

> On Fri, Oct 27, 2017 at 2:09 PM, Gustavo A. R. Silva
> <garsilva@embeddedor.com> wrote:
>> Hi Alan,
>>
>> Quoting Alan Tull <atull@kernel.org>:
>>
>>> On Thu, Oct 26, 2017 at 6:02 PM, Gustavo A. R. Silva
>>> <garsilva@embeddedor.com> wrote:
>>>
>>> Hi Gustavo,
>>>
>>> Thanks for pointing that out.  There's also a similar thing in
>>> fpga-bridge.c that I need to fix.
>>>
>>
>> Can you share with me what exactly are you trying to fix?
>>
>> If the issue is similar I might be able to help.
>
> Same fix, but in of_fpga_bridge_get.  Checks the output of
> to_fpga_bridge for NULL.
>

Oh I see now. I'll send a patch for this shortly.

Thanks!
--
Gustavo A. R. Silva






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

end of thread, other threads:[~2017-10-27 19:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-26 23:02 [PATCH] fpga: fpga-mgr: remove unnecessary code in __fpga_mgr_get Gustavo A. R. Silva
2017-10-27 18:30 ` Alan Tull
2017-10-27 19:09   ` Gustavo A. R. Silva
2017-10-27 19:49     ` Alan Tull
2017-10-27 19:55       ` Gustavo A. R. Silva

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.