[PATCH libevdev] Ignore -Woverride-init in event-names.h

David Herrmann dh.herrmann at gmail.com
Thu Aug 22 02:45:39 PDT 2013


Hi

On Thu, Aug 22, 2013 at 8:12 AM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> Having the declarations in the form of [0...EV_MAX] = NULL together
> with the actual definitions causes warnings for every true definition if
> -Woverride-init is enabled.
>
> We can drop them for most as they're zero, but still need them for
> ev_max (which defaults to -1), not zero. So use the GCC pragma to
> disable the warnings for this file.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> This is on top of the python2/3 compatibility patch in
> <20130822045406.GA12609 at yabbi.bne.redhat.com>, not in functionality but
> in diff context.
>
>  libevdev/make-event-names.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libevdev/make-event-names.py b/libevdev/make-event-names.py
> index 62851e3..b4d397a 100755
> --- a/libevdev/make-event-names.py
> +++ b/libevdev/make-event-names.py
> @@ -44,7 +44,6 @@ def print_bits(bits, prefix):
>         if  not hasattr(bits, prefix):
>                 return
>         str = "static const char * const {}_map[{}_MAX + 1] = {{\n".format(prefix, prefix.upper())
> -       str += "        [0 ... {}_MAX] = NULL,\n".format(prefix.upper())
>         for val, name in getattr(bits, prefix).items():
>                 str += "        [{}] = \"{}\",\n".format(name, name)
>         str += "};\n"
> @@ -65,7 +64,6 @@ def print_python_bits(bits, prefix):
>
>  def print_map(bits):
>         str = "static const char * const * const event_type_map[EV_MAX + 1] = {\n"
> -       str += "        [0 ... EV_MAX] = NULL,\n"
>
>         for prefix in prefixes:
>                 if prefix == "BTN_" or prefix == "EV_" or prefix == "INPUT_PROP_":
> @@ -74,6 +72,7 @@ def print_map(bits):
>
>         str += "};\n"
>
> +       str += "#pragma GCC diagnostic ignored \"-Woverride-init\"\n"

Doesn't this have to be:

str += "#pragma GCC diagnostic push\n"
str += "#pragma GCC diagnostic ignored \"-Woverride-init\"\n"

>         str += "static const int ev_max[EV_MAX + 1] = {\n"
>         str += "        [0 ... EV_MAX] = -1,\n"
>         for prefix in prefixes:
> @@ -81,6 +80,7 @@ def print_map(bits):
>                         continue
>                 str += "        [EV_{}] = {}_MAX,\n".format(prefix[:-1], prefix[:-1])
>         str += "};\n"
> +       str += "#pragma GCC diagnostic pop \"-Woverride-init\"\n"

And here just "pop". It doesn't take an argument.

See also:
http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html

Regards
David

>         return str
>
>  def print_python_map(bits):
> --
> 1.8.2.1
>
> _______________________________________________
> 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