* [Qemu-devel] [PATCH] input-linux: fix Coverity warning
@ 2016-03-16 11:50 Gerd Hoffmann
2016-03-16 12:03 ` Stefan Weil
0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2016-03-16 11:50 UTC (permalink / raw
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
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;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] input-linux: fix Coverity warning
2016-03-16 11:50 [Qemu-devel] [PATCH] input-linux: fix Coverity warning Gerd Hoffmann
@ 2016-03-16 12:03 ` Stefan Weil
2016-03-16 12:35 ` Gerd Hoffmann
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2016-03-16 12:03 UTC (permalink / raw
To: Gerd Hoffmann, qemu-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Am 16.03.2016 um 12:50 schrieb Gerd Hoffmann:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> ---
> 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);
Regards,
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJW6UupAAoJEOCMIdVndFCtxc4QAJC9lsHMvJD2+o3k8F4MdqOx
IG2YY3EOPH1EClTWQ2JX1QM+YD3nxXXHFLAOl9xYo9tQwoD1/JGTjRMdIBZgTN7u
b5dLBBbAU+T/wEiEEVgBL2fACCoRFJtFTy9ZfbNe14jqsjbmArgXTpfnlQYJPbIa
KpVwj1fFgc11nwgn9VkxYmXK4/wlXfIiV86rzcXOfRZ+nGtsdwJbFkbNkEqc3mxk
q9155uo2u3Exqw+3NQNO+wqdmkEhuw1C2yrWGzCPUFHgiaHwatt2sTCW2S9uGvdH
PYlcsnErlFApQS3EE9nRJ4Jpqh1+jdbN/NvvAiL+Fh/EEReqzVbcD+Ga24uZB0eF
J/NgAEa6puPPjBnZ4CfnNGwd7sVfNhERULvso6EKTyn+eUqI6P3kl7VaiVAG7wpE
rYDwCWSEHzhUK5cuLbxpF2lF1+1Z9VkYRw/8EUjxZSp32VMjODQHw2jrwBQCMtWn
3MTXc0nAVfPowzVxjhk9mqlRzXauzbPL1Y0b6d74CADmEAzpxsrsD+oTV1ljG6rA
0E8sJVHB1k7I5lWM98K4Jc/uJ/gcynE8hDI2lnLqtmvCp0V/yP02v0cblAZb3Ldn
gDvEnQFoFgRGzm5ChXxAcMl9+CRScn9e94HzOTTJt3EEjQf9ifty4jEm7IxrNrd/
5eWjDuoctw4ZexgMir5H
=EIex
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] input-linux: fix Coverity warning
2016-03-16 12:03 ` Stefan Weil
@ 2016-03-16 12:35 ` Gerd Hoffmann
0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2016-03-16 12:35 UTC (permalink / raw
To: Stefan Weil; +Cc: qemu-devel
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 <kraxel@redhat.com> ---
> > 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-16 12:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-16 11:50 [Qemu-devel] [PATCH] input-linux: fix Coverity warning Gerd Hoffmann
2016-03-16 12:03 ` Stefan Weil
2016-03-16 12:35 ` Gerd Hoffmann
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.