* [PATCH] rtc: pcf8563: fix uninitialized use warning
@ 2014-09-07 20:42 Arnd Bergmann
2014-09-08 11:02 ` Sergei Shtylyov
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2014-09-07 20:42 UTC (permalink / raw)
To: linux-arm-kernel
gcc-4.9 found a potential condition under which the 'pending'
variable may be used uninitialized:
drivers/rtc/rtc-pcf8563.c: In function 'pcf8563_irq':
drivers/rtc/rtc-pcf8563.c:173:5: warning: 'pending' may be used uninitialized in this function [-Wmaybe-uninitialized]
This is because in the pcf8563_get_alarm_mode() function, we
check any nonzero return of pcf8563_read_block_data, but
in the irq function we only check for negative values, so
a possible positive value does not get detected if the compiler
chooses not to inline the entire call chain.
Checking for any non-zero value in the interrupt handler as well
is just as correct and lets the compiler know what we are doing,
without needing a bogus initialization.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 5a197d9dc7e7..3a6f994c4da8 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -167,7 +167,7 @@ static irqreturn_t pcf8563_irq(int irq, void *dev_id)
char pending;
err = pcf8563_get_alarm_mode(pcf8563->client, NULL, &pending);
- if (err < 0)
+ if (err)
return err;
if (pending) {
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] rtc: pcf8563: fix uninitialized use warning
2014-09-07 20:42 [PATCH] rtc: pcf8563: fix uninitialized use warning Arnd Bergmann
@ 2014-09-08 11:02 ` Sergei Shtylyov
2014-09-08 15:22 ` Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2014-09-08 11:02 UTC (permalink / raw)
To: linux-arm-kernel
Hello.
On 9/8/2014 12:42 AM, Arnd Bergmann wrote:
> gcc-4.9 found a potential condition under which the 'pending'
> variable may be used uninitialized:
> drivers/rtc/rtc-pcf8563.c: In function 'pcf8563_irq':
> drivers/rtc/rtc-pcf8563.c:173:5: warning: 'pending' may be used uninitialized in this function [-Wmaybe-uninitialized]
> This is because in the pcf8563_get_alarm_mode() function, we
> check any nonzero return of pcf8563_read_block_data, but
> in the irq function we only check for negative values, so
> a possible positive value does not get detected if the compiler
> chooses not to inline the entire call chain.
> Checking for any non-zero value in the interrupt handler as well
> is just as correct and lets the compiler know what we are doing,
> without needing a bogus initialization.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
> index 5a197d9dc7e7..3a6f994c4da8 100644
> --- a/drivers/rtc/rtc-pcf8563.c
> +++ b/drivers/rtc/rtc-pcf8563.c
> @@ -167,7 +167,7 @@ static irqreturn_t pcf8563_irq(int irq, void *dev_id)
> char pending;
>
> err = pcf8563_get_alarm_mode(pcf8563->client, NULL, &pending);
> - if (err < 0)
> + if (err)
> return err;
Returning negative values from the IRQ handler doesn't seem valid.
Arbitrary positive value aren't good either. Perhaps should return IRQ_NONE
instead?
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] rtc: pcf8563: fix uninitialized use warning
2014-09-08 11:02 ` Sergei Shtylyov
@ 2014-09-08 15:22 ` Arnd Bergmann
2014-09-08 15:40 ` Sergei Shtylyov
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2014-09-08 15:22 UTC (permalink / raw)
To: linux-arm-kernel
On Monday 08 September 2014 15:02:00 Sergei Shtylyov wrote:
> > diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
> > index 5a197d9dc7e7..3a6f994c4da8 100644
> > --- a/drivers/rtc/rtc-pcf8563.c
> > +++ b/drivers/rtc/rtc-pcf8563.c
> > @@ -167,7 +167,7 @@ static irqreturn_t pcf8563_irq(int irq, void *dev_id)
> > char pending;
> >
> > err = pcf8563_get_alarm_mode(pcf8563->client, NULL, &pending);
> > - if (err < 0)
> > + if (err)
> > return err;
>
> Returning negative values from the IRQ handler doesn't seem valid.
> Arbitrary positive value aren't good either. Perhaps should return IRQ_NONE
> instead?
Good point. This is unrelated to the problem I was trying to fix, but it
seems like a good idea to fix both.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] rtc: pcf8563: fix uninitialized use warning
2014-09-08 15:22 ` Arnd Bergmann
@ 2014-09-08 15:40 ` Sergei Shtylyov
0 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2014-09-08 15:40 UTC (permalink / raw)
To: linux-arm-kernel
On 9/8/2014 7:22 PM, Arnd Bergmann wrote:
>>> diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
>>> index 5a197d9dc7e7..3a6f994c4da8 100644
>>> --- a/drivers/rtc/rtc-pcf8563.c
>>> +++ b/drivers/rtc/rtc-pcf8563.c
>>> @@ -167,7 +167,7 @@ static irqreturn_t pcf8563_irq(int irq, void *dev_id)
>>> char pending;
>>>
>>> err = pcf8563_get_alarm_mode(pcf8563->client, NULL, &pending);
>>> - if (err < 0)
>>> + if (err)
>>> return err;
>> Returning negative values from the IRQ handler doesn't seem valid.
>> Arbitrary positive value aren't good either. Perhaps should return IRQ_NONE
>> instead?
> Good point. This is unrelated to the problem I was trying to fix, but it
> seems like a good idea to fix both.
Then it would be good if you fix this issue with a separate patch.
> Arnd
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-08 15:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-07 20:42 [PATCH] rtc: pcf8563: fix uninitialized use warning Arnd Bergmann
2014-09-08 11:02 ` Sergei Shtylyov
2014-09-08 15:22 ` Arnd Bergmann
2014-09-08 15:40 ` Sergei Shtylyov
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).