From: Stefan Weil <sw@weilnetz.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
qemu-devel <qemu-devel@nongnu.org>,
Anthony Liguori <aliguori@amazon.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] gtk: Fix compiler warnings with -Werror=sign-compare
Date: Mon, 04 Nov 2013 21:23:57 +0100 [thread overview]
Message-ID: <5278025D.1000201@weilnetz.de> (raw)
In-Reply-To: <CAFEAcA9-YvQPprbt1+KCG0ov44-gbvaPx-gtX4yyd5fzfcX3UA@mail.gmail.com>
Am 04.11.2013 21:07, schrieb Peter Maydell:
> On 4 November 2013 19:51, Stefan Weil <sw@weilnetz.de> wrote:
>> With -Werror=sign-compare (not enabled by default), gcc shows these errors:
>>
>> ui/gtk.c: In function ‘gtk_release_modifiers’:
>> ui/gtk.c:288:19: error:
>> comparison between signed and unsigned integer expressions [-Werror=sign-compare]
>> ui/gtk.c: In function ‘gd_key_event’:
>> ui/gtk.c:746:19: error:
>> comparison between signed and unsigned integer expressions [-Werror=sign-compare]
> If this warning is going to complain about entirely
> safe and idiomatic code like
>
> int i;
> static const int some_array[] = {
> 0x2a, 0x36, 0x1d, 0x9d, 0x38, 0xb8, 0xdb, 0xdd,
> };
>
> for (i = 0; i < ARRAY_SIZE(some_array); i++) {
> ...
> }
>
> then I think it is more trouble than it is worth and we
> should leave it disabled.
>
> thanks
> -- PMM
Yes, we should leave it disabled for simple practical reasons: there are
too many warnings of this kind, so I don't expect they will be fixed in
the near future (I have no plan to send patches to fix them all - this
one was just in my way).
And yes, we should fix code which can be improved as easily as in the
above example. ARRAY_SIZE happens to be an unsigned size_t, so comparing
it to an unsigned value is better IMHO (I'm aware that there were
already discussions about using signed or unsigned integers).
-Wsign-compare is like other compiler warnings: it can detect some
really unwanted code, but a human reviewer won't always agree on the
results.It might be a good idea to support it somewhere in the far future.
Stefan
WARNING: multiple messages have this Message-ID (diff)
From: Stefan Weil <sw@weilnetz.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
qemu-devel <qemu-devel@nongnu.org>,
Anthony Liguori <aliguori@amazon.com>
Subject: Re: [Qemu-devel] [PATCH] gtk: Fix compiler warnings with -Werror=sign-compare
Date: Mon, 04 Nov 2013 21:23:57 +0100 [thread overview]
Message-ID: <5278025D.1000201@weilnetz.de> (raw)
In-Reply-To: <CAFEAcA9-YvQPprbt1+KCG0ov44-gbvaPx-gtX4yyd5fzfcX3UA@mail.gmail.com>
Am 04.11.2013 21:07, schrieb Peter Maydell:
> On 4 November 2013 19:51, Stefan Weil <sw@weilnetz.de> wrote:
>> With -Werror=sign-compare (not enabled by default), gcc shows these errors:
>>
>> ui/gtk.c: In function ‘gtk_release_modifiers’:
>> ui/gtk.c:288:19: error:
>> comparison between signed and unsigned integer expressions [-Werror=sign-compare]
>> ui/gtk.c: In function ‘gd_key_event’:
>> ui/gtk.c:746:19: error:
>> comparison between signed and unsigned integer expressions [-Werror=sign-compare]
> If this warning is going to complain about entirely
> safe and idiomatic code like
>
> int i;
> static const int some_array[] = {
> 0x2a, 0x36, 0x1d, 0x9d, 0x38, 0xb8, 0xdb, 0xdd,
> };
>
> for (i = 0; i < ARRAY_SIZE(some_array); i++) {
> ...
> }
>
> then I think it is more trouble than it is worth and we
> should leave it disabled.
>
> thanks
> -- PMM
Yes, we should leave it disabled for simple practical reasons: there are
too many warnings of this kind, so I don't expect they will be fixed in
the near future (I have no plan to send patches to fix them all - this
one was just in my way).
And yes, we should fix code which can be improved as easily as in the
above example. ARRAY_SIZE happens to be an unsigned size_t, so comparing
it to an unsigned value is better IMHO (I'm aware that there were
already discussions about using signed or unsigned integers).
-Wsign-compare is like other compiler warnings: it can detect some
really unwanted code, but a human reviewer won't always agree on the
results.It might be a good idea to support it somewhere in the far future.
Stefan
next prev parent reply other threads:[~2013-11-04 20:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-04 19:51 [Qemu-trivial] [PATCH] gtk: Fix compiler warnings with -Werror=sign-compare Stefan Weil
2013-11-04 19:51 ` [Qemu-devel] " Stefan Weil
2013-11-04 20:07 ` [Qemu-trivial] " Peter Maydell
2013-11-04 20:07 ` Peter Maydell
2013-11-04 20:23 ` Stefan Weil [this message]
2013-11-04 20:23 ` Stefan Weil
2013-11-04 20:38 ` [Qemu-trivial] " Laszlo Ersek
2013-11-04 20:38 ` Laszlo Ersek
2013-11-04 21:00 ` [Qemu-trivial] " Peter Maydell
2013-11-04 21:00 ` Peter Maydell
2013-11-06 8:51 ` [Qemu-trivial] C99 loop vars? [was: gtk: Fix compiler warnings with -Werror=sign-compare] Michael Tokarev
2013-11-06 8:51 ` [Qemu-devel] " Michael Tokarev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5278025D.1000201@weilnetz.de \
--to=sw@weilnetz.de \
--cc=aliguori@amazon.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.