Mass filing of clang warnings

Werner Koch wk at gnupg.org
Fri Mar 13 21:32:35 CET 2015


On Fri, 13 Mar 2015 15:48, hans at guardianproject.info said:

> That's the kind of stuff that I'm talking about.  The key point I'm talking
> about is not about whether the code that triggers the warning is correct or
> not.  It is about making it correct AND simple enough for cppcheck to
> understand.  That last point is what I'm discussing.

I know.  However it depends on the case.  A change like 

  -  char buffer[BUFFER_SIZE];
  +  char buffer[BUFFER_SIZE] = ""; // make cppcheck happy

this wrong.  BUFFER is not expected to be initialized.  A flow analysis
may later come and warn about a useless initialization of BUFFER.

Agreed, I do that sometimes for scalars or pointers which are for
example controlled by a flag variable.  I really hate to do that but I
need to shut up gcc in some cases.  The problem behind such dummy
initialization is that improved compilers won't be able to detect a
really non-initialized variable or complain about initialized but not
used variable.  It is always a tradeoff.  

Also recall that there are more compilers than gcc and Clang.  Some even
provided better warnings many years ago.

If there would only be an annotation format which keeps the actual
source readable (ie. in a separate automagically maintained file).


Salam-Shalom,

   Werner


-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.




More information about the Gnupg-devel mailing list