linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: tc358743: initialize variable
@ 2020-08-30 16:30 trix
  2020-08-31 17:31 ` Nick Desaulniers
  0 siblings, 1 reply; 4+ messages in thread
From: trix @ 2020-08-30 16:30 UTC (permalink / raw)
  To: matrandg, mchehab, natechancellor, ndesaulniers, p.zabel, hans.verkuil
  Cc: linux-media, linux-kernel, Tom Rix

From: Tom Rix <trix@redhat.com>

clang static analysis flags this error

tc358743.c:1468:9: warning: Branch condition evaluates
  to a garbage value
        return handled ? IRQ_HANDLED : IRQ_NONE;
               ^~~~~~~
handled should be initialized to false.

Fixes: d747b806abf4 ("[media] tc358743: add direct interrupt handling")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/media/i2c/tc358743.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index a03dcab5ce61..c724bd1591de 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -1461,7 +1461,7 @@ static int tc358743_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
 static irqreturn_t tc358743_irq_handler(int irq, void *dev_id)
 {
 	struct tc358743_state *state = dev_id;
-	bool handled;
+	bool handled = false;
 
 	tc358743_isr(&state->sd, 0, &handled);
 
-- 
2.18.1


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

* Re: [PATCH] media: tc358743: initialize variable
  2020-08-30 16:30 [PATCH] media: tc358743: initialize variable trix
@ 2020-08-31 17:31 ` Nick Desaulniers
  2020-08-31 18:11   ` Tom Rix
  2020-09-02 13:54   ` Tom Rix
  0 siblings, 2 replies; 4+ messages in thread
From: Nick Desaulniers @ 2020-08-31 17:31 UTC (permalink / raw)
  To: trix
  Cc: matrandg, Mauro Carvalho Chehab, Nathan Chancellor, p.zabel,
	Hans Verkuil, linux-media, LKML

On Sun, Aug 30, 2020 at 9:30 AM <trix@redhat.com> wrote:
>
> From: Tom Rix <trix@redhat.com>
>
> clang static analysis flags this error
>
> tc358743.c:1468:9: warning: Branch condition evaluates
>   to a garbage value
>         return handled ? IRQ_HANDLED : IRQ_NONE;
>                ^~~~~~~
> handled should be initialized to false.
>
> Fixes: d747b806abf4 ("[media] tc358743: add direct interrupt handling")
> Signed-off-by: Tom Rix <trix@redhat.com>

I'm guessing there was more to the report that says that `handled`
isn't necessarily initialized along any of the paths within
tc358743_isr()?  But you should fix this for all callers of
tc358743_isr(), such as tc358743_work_i2c_poll(), not just
tc358743_irq_handler().

> ---
>  drivers/media/i2c/tc358743.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> index a03dcab5ce61..c724bd1591de 100644
> --- a/drivers/media/i2c/tc358743.c
> +++ b/drivers/media/i2c/tc358743.c
> @@ -1461,7 +1461,7 @@ static int tc358743_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
>  static irqreturn_t tc358743_irq_handler(int irq, void *dev_id)
>  {
>         struct tc358743_state *state = dev_id;
> -       bool handled;
> +       bool handled = false;
>
>         tc358743_isr(&state->sd, 0, &handled);
>
> --
> 2.18.1
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] media: tc358743: initialize variable
  2020-08-31 17:31 ` Nick Desaulniers
@ 2020-08-31 18:11   ` Tom Rix
  2020-09-02 13:54   ` Tom Rix
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rix @ 2020-08-31 18:11 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: matrandg, Mauro Carvalho Chehab, Nathan Chancellor, p.zabel,
	Hans Verkuil, linux-media, LKML


On 8/31/20 10:31 AM, Nick Desaulniers wrote:
> On Sun, Aug 30, 2020 at 9:30 AM <trix@redhat.com> wrote:
>> From: Tom Rix <trix@redhat.com>
>>
>> clang static analysis flags this error
>>
>> tc358743.c:1468:9: warning: Branch condition evaluates
>>   to a garbage value
>>         return handled ? IRQ_HANDLED : IRQ_NONE;
>>                ^~~~~~~
>> handled should be initialized to false.
>>
>> Fixes: d747b806abf4 ("[media] tc358743: add direct interrupt handling")
>> Signed-off-by: Tom Rix <trix@redhat.com>
> I'm guessing there was more to the report that says that `handled`
> isn't necessarily initialized along any of the paths within
> tc358743_isr()?  But you should fix this for all callers of
> tc358743_isr(), such as tc358743_work_i2c_poll(), not just
> tc358743_irq_handler().

Interesting. The static analyzer did not catch this.

I will take another.

Thanks

Tom

>> ---
>>  drivers/media/i2c/tc358743.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
>> index a03dcab5ce61..c724bd1591de 100644
>> --- a/drivers/media/i2c/tc358743.c
>> +++ b/drivers/media/i2c/tc358743.c
>> @@ -1461,7 +1461,7 @@ static int tc358743_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
>>  static irqreturn_t tc358743_irq_handler(int irq, void *dev_id)
>>  {
>>         struct tc358743_state *state = dev_id;
>> -       bool handled;
>> +       bool handled = false;
>>
>>         tc358743_isr(&state->sd, 0, &handled);
>>
>> --
>> 2.18.1
>>
>


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

* Re: [PATCH] media: tc358743: initialize variable
  2020-08-31 17:31 ` Nick Desaulniers
  2020-08-31 18:11   ` Tom Rix
@ 2020-09-02 13:54   ` Tom Rix
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rix @ 2020-09-02 13:54 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: matrandg, Mauro Carvalho Chehab, Nathan Chancellor, p.zabel,
	Hans Verkuil, linux-media, LKML


On 8/31/20 10:31 AM, Nick Desaulniers wrote:
> On Sun, Aug 30, 2020 at 9:30 AM <trix@redhat.com> wrote:
>> From: Tom Rix <trix@redhat.com>
>>
>> clang static analysis flags this error
>>
>> tc358743.c:1468:9: warning: Branch condition evaluates
>>   to a garbage value
>>         return handled ? IRQ_HANDLED : IRQ_NONE;
>>                ^~~~~~~
>> handled should be initialized to false.
>>
>> Fixes: d747b806abf4 ("[media] tc358743: add direct interrupt handling")
>> Signed-off-by: Tom Rix <trix@redhat.com>
> I'm guessing there was more to the report that says that `handled`
> isn't necessarily initialized along any of the paths within
> tc358743_isr()?  But you should fix this for all callers of
> tc358743_isr(), such as tc358743_work_i2c_poll(), not just
> tc358743_irq_handler().

tc358743_work_i2c_poll does not use handled, so in theory it could pass a null, however at least one of the subhandler, tc358743_cec_isr, does not check if null is passed in.

so i think that covers the callers.

i think initializing handler in tc358743_work_i2c_poll is a not needed since it is unused.  but the null check in tc358743_cec_isr needs to be done. i'll post that as a separate patch once this one settles.

Tom

>> ---
>>  drivers/media/i2c/tc358743.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
>> index a03dcab5ce61..c724bd1591de 100644
>> --- a/drivers/media/i2c/tc358743.c
>> +++ b/drivers/media/i2c/tc358743.c
>> @@ -1461,7 +1461,7 @@ static int tc358743_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
>>  static irqreturn_t tc358743_irq_handler(int irq, void *dev_id)
>>  {
>>         struct tc358743_state *state = dev_id;
>> -       bool handled;
>> +       bool handled = false;
>>
>>         tc358743_isr(&state->sd, 0, &handled);
>>
>> --
>> 2.18.1
>>
>


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

end of thread, other threads:[~2020-09-02 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-30 16:30 [PATCH] media: tc358743: initialize variable trix
2020-08-31 17:31 ` Nick Desaulniers
2020-08-31 18:11   ` Tom Rix
2020-09-02 13:54   ` Tom Rix

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