]> Git Repo - qemu.git/commitdiff
tpm: Use EMSGSIZE instead of EBADMSG to compile on OpenBSD
authorStefan Berger <[email protected]>
Wed, 11 Oct 2017 12:52:43 +0000 (08:52 -0400)
committerStefan Berger <[email protected]>
Fri, 13 Oct 2017 11:34:32 +0000 (07:34 -0400)
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 <[email protected]>
Reviewed-by: Marc-AndrĂ© Lureau <[email protected]>
hw/tpm/tpm_util.c

index 7b35429725a742c243a703637ebf85fed08c1b68..44842075b994e359bd7ac609988107e58c0bee4f 100644 (file)
@@ -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);
This page took 0.024931 seconds and 4 git commands to generate.