mirror of https://github.com/xemu-project/xemu.git
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>
This commit is contained in:
parent
f90ea7ba7c
commit
98979cdca4
|
@ -43,10 +43,10 @@ static int tpm_util_test(int fd,
|
||||||
|
|
||||||
n = write(fd, request, requestlen);
|
n = write(fd, request, requestlen);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
return errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
if (n != requestlen) {
|
if (n != requestlen) {
|
||||||
return EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
|
@ -55,18 +55,18 @@ static int tpm_util_test(int fd,
|
||||||
/* wait for a second */
|
/* wait for a second */
|
||||||
n = select(fd + 1, &readfds, NULL, NULL, &tv);
|
n = select(fd + 1, &readfds, NULL, NULL, &tv);
|
||||||
if (n != 1) {
|
if (n != 1) {
|
||||||
return errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = read(fd, &buf, sizeof(buf));
|
n = read(fd, &buf, sizeof(buf));
|
||||||
if (n < sizeof(struct tpm_resp_hdr)) {
|
if (n < sizeof(struct tpm_resp_hdr)) {
|
||||||
return EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
resp = (struct tpm_resp_hdr *)buf;
|
resp = (struct tpm_resp_hdr *)buf;
|
||||||
/* check the header */
|
/* check the header */
|
||||||
if (be32_to_cpu(resp->len) != n) {
|
if (be32_to_cpu(resp->len) != n) {
|
||||||
return EBADMSG;
|
return -EMSGSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*return_tag = be16_to_cpu(resp->tag);
|
*return_tag = be16_to_cpu(resp->tag);
|
||||||
|
|
Loading…
Reference in New Issue