[PATCH libevdev] Shut up clang compiler warnings

Peter Hutterer peter.hutterer at who-t.net
Tue Jan 6 13:23:03 PST 2015


On Tue, Jan 06, 2015 at 02:11:48PM +0100, David Herrmann wrote:
> Hi
> 
> On Tue, Jan 6, 2015 at 12:12 AM, Peter Hutterer
> <peter.hutterer at who-t.net> wrote:
> > clang looks at GCC pragmas, but doesn't understand -Woverride-init. Instead,
> > it uses -Winitializer-overrides.
> >
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> >  libevdev/make-event-names.py | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/libevdev/make-event-names.py b/libevdev/make-event-names.py
> > index 980283f..835441e 100755
> > --- a/libevdev/make-event-names.py
> > +++ b/libevdev/make-event-names.py
> > @@ -82,8 +82,13 @@ def print_map(bits):
> >         print("};")
> >         print("")
> >
> > +       print("#if __clang__")
> > +       print("#pragma clang diagnostic push")
> > +       print("#pragma clang diagnostic ignored \"-Winitializer-overrides\"")
> > +       print("#else")
> >         print("#pragma GCC diagnostic push")
> >         print("#pragma GCC diagnostic ignored \"-Woverride-init\"")
> > +       print("#endif")
> 
> Are you sure the #if is needed? Why not:
> 
> print("#pragma clang diagnostic push")
> print("#pragma clang diagnostic ignored \"-Winitializer-overrides\"")
> print("#pragma GCC diagnostic push")
> print("#pragma GCC diagnostic ignored \"-Woverride-init\"")
> 
> I mean if clang doesn't understand a GCC pragma _value_, it should
> silently ignore it, right?

yes, it should and no, it doesn't :)

In file included from ../libevdev/libevdev.c:35:
./libevdev/event-names.h:716:32: warning: unknown warning group
'-Woverride-init', ignored [-Wunknown-pragmas]
#pragma GCC diagnostic ignored "-Woverride-init"

that's with -Wall, nothing fancy there.

> Anyway, in both cases:
> Reviewed-by: David Herrmann <dh.herrmann at gmail.com>

thanks

Cheers,
   Peter
 
> >         print("static const int ev_max[EV_MAX + 1] = {")
> >         print(" [0 ... EV_MAX] = -1,")
> >         for prefix in prefixes:
> > @@ -91,7 +96,11 @@ def print_map(bits):
> >                         continue
> >                 print(" [EV_%s] = %s_MAX," % (prefix[:-1], prefix[:-1]))
> >         print("};")
> > +       print("#if __clang__")
> > +       print("#pragma clang diagnostic pop /* \"-Winitializer-overrides\" */")
> > +       print("#else")
> >         print("#pragma GCC diagnostic pop /* \"-Woverride-init\" */")
> > +       print("#endif");
> >         print("")
> >
> >  def print_python_map(bits):
> > --
> > 2.1.0
> >
> > _______________________________________________
> > Input-tools mailing list
> > Input-tools at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/input-tools


More information about the Input-tools mailing list