qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] tpm: Use EMSGSIZE instead of EBADMSG to compile on OpenBSD
@ 2017-10-11 19:47 Stefan Berger
  2017-10-13 11:09 ` Stefan Berger
  2017-10-13 11:14 ` Marc-André Lureau
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Berger @ 2017-10-11 19:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, amarnath.valluri, marcandre.lureau, Stefan Berger

EBADMSG was only added to OpenBSD very recently. To make QEMU compilable
on older OpenBSD versions use EMSGSIZE instead when a mismatch between
number of received bytes and message size indicated in the header was
found.

Return -EMSGSIZE and convert all other errnos in the same functions to
return the negative errno.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 hw/tpm/tpm_util.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c
index fb929f6..73d7796 100644
--- a/hw/tpm/tpm_util.c
+++ b/hw/tpm/tpm_util.c
@@ -68,10 +68,10 @@ static int tpm_util_test(int fd,
 
     n = write(fd, request, requestlen);
     if (n < 0) {
-        return errno;
+        return -errno;
     }
     if (n != requestlen) {
-        return EFAULT;
+        return -EFAULT;
     }
 
     FD_ZERO(&readfds);
@@ -80,18 +80,18 @@ static int tpm_util_test(int fd,
     /* wait for a second */
     n = select(fd + 1, &readfds, NULL, NULL, &tv);
     if (n != 1) {
-        return errno;
+        return -errno;
     }
 
     n = read(fd, &buf, sizeof(buf));
     if (n < sizeof(struct tpm_resp_hdr)) {
-        return EFAULT;
+        return -EFAULT;
     }
 
     resp = (struct tpm_resp_hdr *)buf;
     /* check the header */
     if (be32_to_cpu(resp->len) != n) {
-        return EBADMSG;
+        return -EMSGSIZE;
     }
 
     *return_tag = be16_to_cpu(resp->tag);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-15 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-11 19:47 [Qemu-devel] [PATCH v3] tpm: Use EMSGSIZE instead of EBADMSG to compile on OpenBSD Stefan Berger
2017-10-13 11:09 ` Stefan Berger
2017-10-13 11:14 ` Marc-André Lureau
2017-10-13 16:12   ` Peter Maydell
2017-10-13 16:36     ` Stefan Berger
2017-10-15 16:49       ` Peter Maydell

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).