linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remoteproc: silence an uninitialized variable warning
@ 2019-04-04  8:42 Dan Carpenter
  2019-04-04  9:17 ` Mukesh Ojha
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-04-04  8:42 UTC (permalink / raw)
  To: Andy Gross; +Cc: David Brown, linux-arm-msm, linux-kernel, kernel-janitors

Smatch complains that "ret" might be uninitialized.  I can see why it
generates the warning, but I don't know if it's actually possible.
Anyway initializing "ret" here is harmless.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/soc/qcom/mdt_loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
index 1c488024c698..fc58d660692f 100644
--- a/drivers/soc/qcom/mdt_loader.c
+++ b/drivers/soc/qcom/mdt_loader.c
@@ -188,7 +188,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
 
 	if (reloc_base)
 		*reloc_base = mem_reloc;
-
+	ret = 0;
 out:
 	kfree(fw_name);
 
-- 
2.17.1


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

* Re: [PATCH] remoteproc: silence an uninitialized variable warning
  2019-04-04  8:42 [PATCH] remoteproc: silence an uninitialized variable warning Dan Carpenter
@ 2019-04-04  9:17 ` Mukesh Ojha
  2019-04-04  9:36   ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Mukesh Ojha @ 2019-04-04  9:17 UTC (permalink / raw)
  To: Dan Carpenter, Andy Gross
  Cc: David Brown, linux-arm-msm, linux-kernel, kernel-janitors


On 4/4/2019 2:12 PM, Dan Carpenter wrote:
> Smatch complains that "ret" might be uninitialized.  I can see why it
> generates the warning, but I don't know if it's actually possible.
> Anyway initializing "ret" here is harmless.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>   drivers/soc/qcom/mdt_loader.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
> index 1c488024c698..fc58d660692f 100644
> --- a/drivers/soc/qcom/mdt_loader.c
> +++ b/drivers/soc/qcom/mdt_loader.c
> @@ -188,7 +188,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
>   
>   	if (reloc_base)
>   		*reloc_base = mem_reloc;
> -
> +	ret = 0;


You are overriding the value here, better keep it at the start.
Thanks,
Mukesh

>   out:
>   	kfree(fw_name);
>   

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

* Re: [PATCH] remoteproc: silence an uninitialized variable warning
  2019-04-04  9:17 ` Mukesh Ojha
@ 2019-04-04  9:36   ` Dan Carpenter
  2019-04-05  7:08     ` Mukesh Ojha
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-04-04  9:36 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Andy Gross, David Brown, linux-arm-msm, linux-kernel, kernel-janitors

On Thu, Apr 04, 2019 at 02:47:39PM +0530, Mukesh Ojha wrote:
> 
> On 4/4/2019 2:12 PM, Dan Carpenter wrote:
> > Smatch complains that "ret" might be uninitialized.  I can see why it
> > generates the warning, but I don't know if it's actually possible.
> > Anyway initializing "ret" here is harmless.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> >   drivers/soc/qcom/mdt_loader.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
> > index 1c488024c698..fc58d660692f 100644
> > --- a/drivers/soc/qcom/mdt_loader.c
> > +++ b/drivers/soc/qcom/mdt_loader.c
> > @@ -188,7 +188,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
> >   	if (reloc_base)
> >   		*reloc_base = mem_reloc;
> > -
> > +	ret = 0;
> 
> 
> You are overriding the value here, better keep it at the start.

I like how I wrote it.  It makes it clear that this is the success path.

regards,
dan carpenter


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

* Re: [PATCH] remoteproc: silence an uninitialized variable warning
  2019-04-04  9:36   ` Dan Carpenter
@ 2019-04-05  7:08     ` Mukesh Ojha
  2019-04-05  7:33       ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Mukesh Ojha @ 2019-04-05  7:08 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andy Gross, David Brown, linux-arm-msm, linux-kernel, kernel-janitors


On 4/4/2019 3:06 PM, Dan Carpenter wrote:
> On Thu, Apr 04, 2019 at 02:47:39PM +0530, Mukesh Ojha wrote:
>> On 4/4/2019 2:12 PM, Dan Carpenter wrote:
>>> Smatch complains that "ret" might be uninitialized.  I can see why it
>>> generates the warning, but I don't know if it's actually possible.
>>> Anyway initializing "ret" here is harmless.
>>>
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>> ---
>>>    drivers/soc/qcom/mdt_loader.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
>>> index 1c488024c698..fc58d660692f 100644
>>> --- a/drivers/soc/qcom/mdt_loader.c
>>> +++ b/drivers/soc/qcom/mdt_loader.c
>>> @@ -188,7 +188,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
>>>    	if (reloc_base)
>>>    		*reloc_base = mem_reloc;
>>> -
>>> +	ret = 0;
>>
>> You are overriding the value here, better keep it at the start.
> I like how I wrote it.  It makes it clear that this is the success path.


But think about a case when this request_firmware_into_buf fails or the 
snippet above that can set the ret with error value

right.. is not that possible?..and ret = 0 stops propagating the error 
properly.

Thanks
Mukesh

>
> regards,
> dan carpenter
>

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

* Re: [PATCH] remoteproc: silence an uninitialized variable warning
  2019-04-05  7:08     ` Mukesh Ojha
@ 2019-04-05  7:33       ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-04-05  7:33 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Andy Gross, David Brown, linux-arm-msm, linux-kernel, kernel-janitors

On Fri, Apr 05, 2019 at 12:38:19PM +0530, Mukesh Ojha wrote:
> 
> On 4/4/2019 3:06 PM, Dan Carpenter wrote:
> > On Thu, Apr 04, 2019 at 02:47:39PM +0530, Mukesh Ojha wrote:
> > > On 4/4/2019 2:12 PM, Dan Carpenter wrote:
> > > > Smatch complains that "ret" might be uninitialized.  I can see why it
> > > > generates the warning, but I don't know if it's actually possible.
> > > > Anyway initializing "ret" here is harmless.
> > > > 
> > > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > > ---
> > > >    drivers/soc/qcom/mdt_loader.c | 2 +-
> > > >    1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
> > > > index 1c488024c698..fc58d660692f 100644
> > > > --- a/drivers/soc/qcom/mdt_loader.c
> > > > +++ b/drivers/soc/qcom/mdt_loader.c
> > > > @@ -188,7 +188,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
> > > >    	if (reloc_base)
> > > >    		*reloc_base = mem_reloc;
> > > > -
> > > > +	ret = 0;
> > > 
> > > You are overriding the value here, better keep it at the start.
> > I like how I wrote it.  It makes it clear that this is the success path.
> 
> 
> But think about a case when this request_firmware_into_buf fails or the
> snippet above that can set the ret with error value
> 
> right.. is not that possible?..and ret = 0 stops propagating the error
> properly.
> 

Gar.  I read "goto out;" instead of "break;".  It probably should be
goto out though...  Anyway, I will resend.

Thanks!

regards,
dan carpenter


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

end of thread, other threads:[~2019-04-05  7:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04  8:42 [PATCH] remoteproc: silence an uninitialized variable warning Dan Carpenter
2019-04-04  9:17 ` Mukesh Ojha
2019-04-04  9:36   ` Dan Carpenter
2019-04-05  7:08     ` Mukesh Ojha
2019-04-05  7:33       ` 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).