qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ariadne Conill <ariadne@dereferenced.org>
To: qemu-devel@nongnu.org
Cc: Ariadne Conill <ariadne@dereferenced.org>
Subject: [PATCH-for-5.2 1/2] virtio host input: use safe 64-bit time accessors for input_event
Date: Wed, 22 Jul 2020 02:52:25 -0600	[thread overview]
Message-ID: <20200722085226.11984-1-ariadne@dereferenced.org> (raw)

On 32-bit systems with 64-bit time_t, input_event.time is not
directly accessible.  Instead, we must use input_event_sec and
input_event_usec accessors to set the time values.

Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
---
 hw/input/virtio-input-host.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/input/virtio-input-host.c b/hw/input/virtio-input-host.c
index 85daf73f1a..7b81bf09f5 100644
--- a/hw/input/virtio-input-host.c
+++ b/hw/input/virtio-input-host.c
@@ -193,13 +193,16 @@ static void virtio_input_host_handle_status(VirtIOInput *vinput,
 {
     VirtIOInputHost *vih = VIRTIO_INPUT_HOST(vinput);
     struct input_event evdev;
+    struct timeval tv;
     int rc;
 
-    if (gettimeofday(&evdev.time, NULL)) {
+    if (gettimeofday(&tv, NULL)) {
         perror("virtio_input_host_handle_status: gettimeofday");
         return;
     }
 
+    evdev.input_event_sec = tv.tv_sec;
+    evdev.input_event_usec = tv.tv_usec;
     evdev.type = le16_to_cpu(event->type);
     evdev.code = le16_to_cpu(event->code);
     evdev.value = le32_to_cpu(event->value);
-- 
2.27.0



             reply	other threads:[~2020-07-22  8:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22  8:52 Ariadne Conill [this message]
2020-07-22  8:52 ` [PATCH-for-5.2 2/2] virtio user input: use safe 64-bit time accessors for input_event Ariadne Conill

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=20200722085226.11984-1-ariadne@dereferenced.org \
    --to=ariadne@dereferenced.org \
    --cc=qemu-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).