All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
	Stefan Weil <sw@weilnetz.de>, 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:38:42 +0100	[thread overview]
Message-ID: <527805D2.3000107@redhat.com> (raw)
In-Reply-To: <CAFEAcA9-YvQPprbt1+KCG0ov44-gbvaPx-gtX4yyd5fzfcX3UA@mail.gmail.com>

On 11/04/13 21:07, Peter Maydell wrote:
> 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++) {
>        ...
>    }

(Entirely safe, and completely non-idiomatic: "i" should be size_t, as
that is the type of the sizeof operator's result.)

Laszlo
/me apologizes for the raging pedantry


WARNING: multiple messages have this Message-ID (diff)
From: Laszlo Ersek <lersek@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
	Stefan Weil <sw@weilnetz.de>, 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:38:42 +0100	[thread overview]
Message-ID: <527805D2.3000107@redhat.com> (raw)
In-Reply-To: <CAFEAcA9-YvQPprbt1+KCG0ov44-gbvaPx-gtX4yyd5fzfcX3UA@mail.gmail.com>

On 11/04/13 21:07, Peter Maydell wrote:
> 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++) {
>        ...
>    }

(Entirely safe, and completely non-idiomatic: "i" should be size_t, as
that is the type of the sizeof operator's result.)

Laszlo
/me apologizes for the raging pedantry

  parent reply	other threads:[~2013-11-04 20:36 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   ` [Qemu-trivial] " Stefan Weil
2013-11-04 20:23     ` Stefan Weil
2013-11-04 20:38   ` Laszlo Ersek [this message]
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=527805D2.3000107@redhat.com \
    --to=lersek@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=sw@weilnetz.de \
    /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.