* [PATCH] misc: suppress build warning
@ 2014-12-04 14:38 Lad, Prabhakar
2014-12-04 14:59 ` Arnd Bergmann
0 siblings, 1 reply; 5+ messages in thread
From: Lad, Prabhakar @ 2014-12-04 14:38 UTC (permalink / raw)
To: Greg Kroah-Hartman, Arnd Bergmann; +Cc: linux-kernel, Lad, Prabhakar
this patch fixes following build warning:
drivers/misc/ioc4.c: In function ‘ioc4_probe’:
drivers/misc/ioc4.c:194:16: warning: ‘start’ may be used uninitialized in this function [-Wmaybe-uninitialized]
period = (end - start) /
^
drivers/misc/ioc4.c:148:11: note: ‘start’ was declared here
uint64_t start, end, period;
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
---
Note:- I have compile tested only, and this was noticed
on linux-next
drivers/misc/ioc4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 3336ddc..c1f1e6c 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -145,7 +145,7 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
union ioc4_int_out int_out;
union ioc4_gpcr gpcr;
unsigned int state, last_state = 1;
- uint64_t start, end, period;
+ uint64_t start = 0, end, period;
unsigned int count = 0;
/* Enable output */
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] misc: suppress build warning
2014-12-04 14:38 [PATCH] misc: suppress build warning Lad, Prabhakar
@ 2014-12-04 14:59 ` Arnd Bergmann
2014-12-04 15:13 ` Prabhakar Lad
0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2014-12-04 14:59 UTC (permalink / raw)
To: Lad, Prabhakar; +Cc: Greg Kroah-Hartman, linux-kernel
On Thursday 04 December 2014 14:38:30 Lad, Prabhakar wrote:
> this patch fixes following build warning:
>
> drivers/misc/ioc4.c: In function ‘ioc4_probe’:
> drivers/misc/ioc4.c:194:16: warning: ‘start’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> period = (end - start) /
> ^
> drivers/misc/ioc4.c:148:11: note: ‘start’ was declared here
> uint64_t start, end, period;
>
> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Please explain why the compiler thinks there is a bug, why you
are sure that there isn't, and why you picked '0' as the
initialization value.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] misc: suppress build warning
2014-12-04 14:59 ` Arnd Bergmann
@ 2014-12-04 15:13 ` Prabhakar Lad
2014-12-04 16:30 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ messages in thread
From: Prabhakar Lad @ 2014-12-04 15:13 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Greg Kroah-Hartman, LKML
On Thu, Dec 4, 2014 at 2:59 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thursday 04 December 2014 14:38:30 Lad, Prabhakar wrote:
>> this patch fixes following build warning:
>>
>> drivers/misc/ioc4.c: In function ‘ioc4_probe’:
>> drivers/misc/ioc4.c:194:16: warning: ‘start’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>> period = (end - start) /
>> ^
>> drivers/misc/ioc4.c:148:11: note: ‘start’ was declared here
>> uint64_t start, end, period;
>>
>> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
>
> Please explain why the compiler thinks there is a bug, why you
> are sure that there isn't, and why you picked '0' as the
> initialization value.
>
Its a false positive, to suppress the warning '0' was picked.
Thanks,
--Prabhakar Lad
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] misc: suppress build warning
2014-12-04 15:13 ` Prabhakar Lad
@ 2014-12-04 16:30 ` Greg Kroah-Hartman
2014-12-05 7:37 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2014-12-04 16:30 UTC (permalink / raw)
To: Prabhakar Lad; +Cc: Arnd Bergmann, LKML
On Thu, Dec 04, 2014 at 03:13:00PM +0000, Prabhakar Lad wrote:
> On Thu, Dec 4, 2014 at 2:59 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Thursday 04 December 2014 14:38:30 Lad, Prabhakar wrote:
> >> this patch fixes following build warning:
> >>
> >> drivers/misc/ioc4.c: In function ‘ioc4_probe’:
> >> drivers/misc/ioc4.c:194:16: warning: ‘start’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> >> period = (end - start) /
> >> ^
> >> drivers/misc/ioc4.c:148:11: note: ‘start’ was declared here
> >> uint64_t start, end, period;
> >>
> >> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> >
> > Please explain why the compiler thinks there is a bug, why you
> > are sure that there isn't, and why you picked '0' as the
> > initialization value.
> >
> Its a false positive, to suppress the warning '0' was picked.
Are you _sure_ it's a false positive? That odd do/while loop looks like
it might just not ever initialize the start variable, are you sure the
logic there is correct?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] misc: suppress build warning
2014-12-04 16:30 ` Greg Kroah-Hartman
@ 2014-12-05 7:37 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2014-12-05 7:37 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Prabhakar Lad, Arnd Bergmann, LKML
On Thu, 4 Dec 2014 08:30:32 -0800 Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> On Thu, Dec 04, 2014 at 03:13:00PM +0000, Prabhakar Lad wrote:
> > On Thu, Dec 4, 2014 at 2:59 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> > > On Thursday 04 December 2014 14:38:30 Lad, Prabhakar wrote:
> > >> this patch fixes following build warning:
> > >>
> > >> drivers/misc/ioc4.c: In function ___ioc4_probe___:
> > >> drivers/misc/ioc4.c:194:16: warning: ___start___ may be used uninitialized in this function [-Wmaybe-uninitialized]
> > >> period = (end - start) /
> > >> ^
> > >> drivers/misc/ioc4.c:148:11: note: ___start___ was declared here
> > >> uint64_t start, end, period;
> > >>
> > >> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> > >
> > > Please explain why the compiler thinks there is a bug, why you
> > > are sure that there isn't, and why you picked '0' as the
> > > initialization value.
> > >
> > Its a false positive, to suppress the warning '0' was picked.
>
> Are you _sure_ it's a false positive? That odd do/while loop looks like
> it might just not ever initialize the start variable, are you sure the
> logic there is correct?
>
As long as IOC4_CALIBRATE_END is greater than IOC4_CALIBRATE_DISCARD (it is),
`start' is written to.
It would be nice to simplify the code, but I'm not sure how.
And I really dislike this initialize-it-to-zero-to-stop-the-warning
thing which we do all over the place. The reader doesn't know *why*
it's initialized to zero and the initialization can conceal bugs if we
get a code path which should have written to it but forgot to. And it
adds unneeded code to vlinux.
I much prefer unintialized_var() which fixes the documentation issue
and doesn't add code. But Linus and Ingo had a dummy-spit over it.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-12-05 7:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-04 14:38 [PATCH] misc: suppress build warning Lad, Prabhakar
2014-12-04 14:59 ` Arnd Bergmann
2014-12-04 15:13 ` Prabhakar Lad
2014-12-04 16:30 ` Greg Kroah-Hartman
2014-12-05 7:37 ` Andrew Morton
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).