summary refs log tree commit diff stats
path: root/hw/tpm
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.vnet.ibm.com>2017-10-11 08:52:43 -0400
committerStefan Berger <stefanb@linux.vnet.ibm.com>2017-10-13 07:34:32 -0400
commit98979cdca44ba0e21055ee7736694aa5ebb54347 (patch)
treeb0cb1aac20a748b64ead5f8ac4b7ff993c094ec4 /hw/tpm
parentf90ea7ba7c5ae7010ee0ce062207ae42530f57d6 (diff)
downloadfocaccia-qemu-98979cdca44ba0e21055ee7736694aa5ebb54347.tar.gz
focaccia-qemu-98979cdca44ba0e21055ee7736694aa5ebb54347.zip
tpm: Use EMSGSIZE instead of EBADMSG to compile on OpenBSD
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>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'hw/tpm')
-rw-r--r--hw/tpm/tpm_util.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c
index 7b35429725..44842075b9 100644
--- a/hw/tpm/tpm_util.c
+++ b/hw/tpm/tpm_util.c
@@ -43,10 +43,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);
@@ -55,18 +55,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);