Re: [PATCH] drivers/video/pmag-ba-fb.c: Improve diagnostics

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Maciej W. Rozycki <macro@...>
Cc: Andrew Morton <akpm@...>, Antonino Daplas <adaplas@...>, <linux-fbdev-devel@...>, <linux-mips@...>, <linux-kernel@...>
Date: Thursday, September 20, 2007 - 9:43 am

Hi Maciej,


On Thu, 20 Sep 2007, Maciej W. Rozycki wrote:

Even so, initializing to zero isn't quite good. You could use the
uninitialized_var() (once you've confirmed that the warning is bogus).
However, some maintainers may still nack uninitialized_var() usage,
quite legitimately.



Firstly, "may be used uninitialized" can still be a bug.

Secondly, latest gcc is *horribly* buggy (and has been so for last several
releases including 4.1, 4.2 and 4.3 -- 3.x was good). See:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33327
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18501

We'd been hurling all sorts of abuses on gcc for quite long (when it fails
to detect these "false positive" cases), but now, it turns out it is quite
easy to write *genuinely* buggy code that still won't get any warnings,
neither the "is used" nor "may be used" one!

In short, there are three ways to fix these false positive warnings:

1. Do nothing, there are enough "uninitialized variable" warnings anyway,
   and hopefully, one day GCC would clean up its act.

2. Use uninitialized_var() to shut it up (only if it's genuinely bogus).

3. Do something like the following legendary patch [1]:

http://kegel.com/crosstool/crosstool-0.43/patches/linux-2.6.11.3/arch_alpha_kernel_src...

i.e., explicitly change the structure/logic of the function to make it
obvious enough to gcc that the variable will not be used uninitialized.


Satyam

[1] That was a funny case -- the alpha linux maintainer is also a gcc
    maintainer. Alpha even sets -Werror, so either he had to fix the
    kernel code that produced the warning, or go fix GCC to not warn
    about it -- he chose the former :-)
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] drivers/video/pmag-ba-fb.c: Improve diagnostics, Maciej W. Rozycki, (Mon Sep 17, 12:45 pm)
Re: [PATCH] drivers/video/pmag-ba-fb.c: Improve diagnostics, Maciej W. Rozycki, (Tue Sep 18, 8:18 am)
Re: [PATCH] drivers/video/pmag-ba-fb.c: Improve diagnostics, Maciej W. Rozycki, (Thu Sep 20, 8:52 am)
Re: [PATCH] drivers/video/pmag-ba-fb.c: Improve diagnostics, Satyam Sharma, (Thu Sep 20, 9:43 am)
Re: [PATCH] drivers/video/pmag-ba-fb.c: Improve diagnostics, Maciej W. Rozycki, (Thu Sep 20, 10:04 am)
Re: [PATCH] drivers/video/pmag-ba-fb.c: Improve diagnostics, Martin Michlmayr, (Thu Sep 20, 2:16 am)