* [PATCH 0/1] acpi: Fix warning: 'num_cpus' may be used uninitialized in this function @ 2010-09-11 6:22 Jean Sacren 2010-09-11 6:24 ` [PATCH 1/1] " Jean Sacren 0 siblings, 1 reply; 5+ messages in thread From: Jean Sacren @ 2010-09-11 6:22 UTC (permalink / raw) To: Linux ACPI Hi, Self-explanatory warning message. Jean Sacren (1): acpi: Fix warning: 'num_cpus' may be used uninitialized in this function drivers/acpi/acpi_pad.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) -- Jean Sacren Bring LAMP To People ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] acpi: Fix warning: 'num_cpus' may be used uninitialized in this function 2010-09-11 6:22 [PATCH 0/1] acpi: Fix warning: 'num_cpus' may be used uninitialized in this function Jean Sacren @ 2010-09-11 6:24 ` Jean Sacren 2010-09-11 16:40 ` Henrique de Moraes Holschuh 0 siblings, 1 reply; 5+ messages in thread From: Jean Sacren @ 2010-09-11 6:24 UTC (permalink / raw) To: Linux ACPI warning: 'num_cpus' may be used uninitialized in this function Initialize 'num_cpus' variable to zero so that gcc doesn't complain. Signed-off-by: Jean Sacren <sakiwit@gmail.com> --- drivers/acpi/acpi_pad.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index b76848c..6154f2b 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c @@ -429,7 +429,7 @@ static void acpi_pad_ost(acpi_handle handle, int stat, static void acpi_pad_handle_notify(acpi_handle handle) { - int num_cpus; + int num_cpus = 0; uint32_t idle_cpus; mutex_lock(&isolated_cpus_lock); -- 1.7.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] acpi: Fix warning: 'num_cpus' may be used uninitialized in this function 2010-09-11 6:24 ` [PATCH 1/1] " Jean Sacren @ 2010-09-11 16:40 ` Henrique de Moraes Holschuh 2010-09-13 0:39 ` Jean Sacren 0 siblings, 1 reply; 5+ messages in thread From: Henrique de Moraes Holschuh @ 2010-09-11 16:40 UTC (permalink / raw) To: Jean Sacren; +Cc: Linux ACPI On Sat, 11 Sep 2010, Jean Sacren wrote: > warning: 'num_cpus' may be used uninitialized in this function > > Initialize 'num_cpus' variable to zero so that gcc doesn't complain. acpi_pad_pur() is referenced only once, so it should end up inlined, at which point gcc really has no excuse to not determine with perfect confidence whether num_cpus is being used unitialized or not. Looking at the code, it realy does look like a false positive. Are you using a recent gcc? -- "One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] acpi: Fix warning: 'num_cpus' may be used uninitialized in this function 2010-09-11 16:40 ` Henrique de Moraes Holschuh @ 2010-09-13 0:39 ` Jean Sacren 2010-09-13 21:01 ` Henrique de Moraes Holschuh 0 siblings, 1 reply; 5+ messages in thread From: Jean Sacren @ 2010-09-13 0:39 UTC (permalink / raw) To: Linux ACPI On Sat, Sep 11, 2010 at 01:40:37PM -0300, Henrique de Moraes Holschuh wrote: > On Sat, 11 Sep 2010, Jean Sacren wrote: > > warning: 'num_cpus' may be used uninitialized in this function > > > > Initialize 'num_cpus' variable to zero so that gcc doesn't complain. > > acpi_pad_pur() is referenced only once, so it should end up inlined, at > which point gcc really has no excuse to not determine with perfect > confidence whether num_cpus is being used unitialized or not. > If acpi_pad_pur() is called and returns with non-zero value, acpi_pad_handle_notify() happily returns, but num_cpus is referenced by address without being initialized, so gcc gives the warning. > > Looking at the code, it realy does look like a false positive. > Unfortunately it is _not_ a false positive. Here gcc does what it's supposed to do. Therefore, the patch is correct. -- Jean Sacren Bring LAMP To People ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] acpi: Fix warning: 'num_cpus' may be used uninitialized in this function 2010-09-13 0:39 ` Jean Sacren @ 2010-09-13 21:01 ` Henrique de Moraes Holschuh 0 siblings, 0 replies; 5+ messages in thread From: Henrique de Moraes Holschuh @ 2010-09-13 21:01 UTC (permalink / raw) To: Jean Sacren; +Cc: Linux ACPI On Sun, 12 Sep 2010, Jean Sacren wrote: > On Sat, Sep 11, 2010 at 01:40:37PM -0300, Henrique de Moraes Holschuh wrote: > > On Sat, 11 Sep 2010, Jean Sacren wrote: > > > warning: 'num_cpus' may be used uninitialized in this function > > > > > > Initialize 'num_cpus' variable to zero so that gcc doesn't complain. > > > > acpi_pad_pur() is referenced only once, so it should end up inlined, at > > which point gcc really has no excuse to not determine with perfect > > confidence whether num_cpus is being used unitialized or not. > > > If acpi_pad_pur() is called and returns with non-zero value, > acpi_pad_handle_notify() happily returns, but num_cpus is referenced by > address without being initialized, so gcc gives the warning. > > > > Looking at the code, it realy does look like a false positive. > > > Unfortunately it is _not_ a false positive. Here gcc does what it's > supposed to do. Therefore, the patch is correct. It will be a false positive if the variable is NOT used unitialized. Passing a reference does not access the object, and acpi_pad_pur() is not a black box to the optimizer (all static, all in the same file, and it is being inlined even...) I don't think num_cpus is being used unitialized, so, as far as I can tell, it is a false positive. gcc should not have issued that warning. I don't object to the patch, btw. -- "One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-09-13 21:01 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-09-11 6:22 [PATCH 0/1] acpi: Fix warning: 'num_cpus' may be used uninitialized in this function Jean Sacren 2010-09-11 6:24 ` [PATCH 1/1] " Jean Sacren 2010-09-11 16:40 ` Henrique de Moraes Holschuh 2010-09-13 0:39 ` Jean Sacren 2010-09-13 21:01 ` Henrique de Moraes Holschuh
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.