[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] input-linux: fix Coverity warning
From: |
Gerd Hoffmann |
Subject: |
Re: [Qemu-devel] [PATCH] input-linux: fix Coverity warning |
Date: |
Wed, 16 Mar 2016 13:35:49 +0100 |
On Mi, 2016-03-16 at 13:03 +0100, Stefan Weil wrote:
> Am 16.03.2016 um 12:50 schrieb Gerd Hoffmann:
> > Signed-off-by: Gerd Hoffmann <address@hidden> ---
> > ui/input-linux.c | 7 +++++++ 1 file changed, 7 insertions(+)
> >
> > diff --git a/ui/input-linux.c b/ui/input-linux.c index
> > 76a2abb..f884c00 100644 --- a/ui/input-linux.c +++
> > b/ui/input-linux.c @@ -257,6 +257,13 @@ static void
> > input_linux_event_keyboard(void *opaque) */ continue; } +
> > if (event.code >= KEY_CNT) { + /* +
> > * Should not happen. But better safe than sorry, +
> > * and we make Coverity happy too. + */ +
> > continue; + } /* keep track of key state */ if
> > (!il->keydown[event.code] && event.value) { il->keydown[event.code]
> > = true;
> >
>
> As it should not happen, I'd prefer this variant:
>
> g_assert(event.code < KEY_CNT);
Well, it is highly unlikely but not impossible. KEY_CNT changed from
0x200 to 0x300 in kernel 2.6.28. If (a) this happens again and (b) a
new key > 0x300 is pressed and (c) we didn't sync the linux headers yet
so qemu still has the old KEY_CNT value we could hit this.
cheers,
Gerd