On Thu, Sep 18, 2014 at 06:24:46PM -0700, Jason Gerecke wrote:
> On Thu, Sep 18, 2014 at 6:15 PM, Peter Hutterer
> <peter.hutte...@who-t.net> wrote:
> > On Thu, Sep 18, 2014 at 06:10:49PM -0700, Jason Gerecke wrote:
> >> On Thu, Sep 18, 2014 at 5:50 PM, Peter Hutterer
> >> <peter.hutte...@who-t.net> wrote:
> >> > On Thu, Sep 18, 2014 at 05:30:55PM -0700, Jason Gerecke wrote:
> >> > [...]
> >> >> >> diff --git a/tools/isdv4-serial-debugger.c 
> >> >> >> b/tools/isdv4-serial-debugger.c
> >> >> >> index 6629cb6..03abd26 100644
> >> >> >> --- a/tools/isdv4-serial-debugger.c
> >> >> >> +++ b/tools/isdv4-serial-debugger.c
> >> >> >> @@ -40,6 +40,7 @@
> >> >> >>
> >> >> >>  #include "tools-shared.h"
> >> >> >>
> >> >> >> +extern int verbose;
> >> >> >>  int verbose = 0;
> >> >> >>
> >> >> >>  static void usage(void)
> >> >> >> diff --git a/tools/isdv4-serial-inputattach.c 
> >> >> >> b/tools/isdv4-serial-inputattach.c
> >> >> >> index fedfce4..6003d30 100644
> >> >> >> --- a/tools/isdv4-serial-inputattach.c
> >> >> >> +++ b/tools/isdv4-serial-inputattach.c
> >> >> >> @@ -37,7 +37,8 @@
> >> >> >>
> >> >> >>  #include "tools-shared.h"
> >> >> >>
> >> >> >> -int verbose;
> >> >> >> +extern int verbose;
> >> >> >> +int verbose = 0;
> >> >> >
> >> >> > that doesn't look right.
> >> >> >
> >> >> > Acked-by: Peter Hutterer <peter.hutte...@who-t.net>
> >> >> > for the series otherwise
> >> >> >
> >> >> >
> >> >> > Cheers,
> >> >> >    Peter
> >> >> >
> >> >>
> >> >> Can you go into a bit more detail? From what I understand, the
> >> >> language already guarantees that a file-scope variable is visible
> >> >> extern and initialized to zero. The code relies on that behavior as
> >> >> well, as its referenced by tools-shared.c and is expected to be zero
> >> >> by default. Really, this and the similar hunk for isdv4-serial-debug.c
> >> >> are just to shut up to checker (which I'm aware isn't always a sane
> >> >> idea, but seemed fine in this instance).
> >> >
> >> > I was mostly referring to declaring it as extern just before 
> >> > initializing it
> >> > right there. Dropping the extern line should work, or does that cause 
> >> > some
> >> > other warning?
> >> >
> >> > Cheers,
> >> >    Peter
> >> >
> >>
> >> Pops up another warning in both clang ("warning: 'extern' variable has
> >> an initializer") and gcc ("warning: ‘verbose’ initialized and declared
> >> ‘extern’). Neither seem to have an issue with declaring and defining
> >> separately.
> >
> > that's with just having
> > int verbose = 0;
> >
> > in this file and the extern line in the other file? or does it then complain
> > about verbose not being declared? if it does that, ack for this one anyway.
> >
> > Cheers,
> >    Peter
> 
> That's with "extern int verbose = 0".
> 
> Removing "extern int verbose" from this file and leaving it only in
> tools-shared.c isn't a problem for gcc but makes clang sad ("warning:
> no previous extern declaration for non-static variable 'verbose'
> [-Wmissing-variable-declarations]").
> 
> Having an "extern int verbose" in both files shuts up both compilers.
> It isn't exactly idiomatic C though, so if you'd prefer leaving it out
> of this file, I'm okay with that. Clang is definitely a bit...
> overzealous... about its warnings.

meh, ok. put it in with a comment about clang and ACK from me.

Cheers,
   Peter

------------------------------------------------------------------------------
Slashdot TV.  Video for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to