From: Peter Maydell <peter.maydell@linaro.org>
To: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: "QEMU Developers" <qemu-devel@nongnu.org>,
amarnath.valluri@intel.com,
"Marc-André Lureau" <marcandre.lureau@gmail.com>
Subject: Re: [Qemu-devel] [PATCH v2] tpm: Use EMSGSIZE instead of EBADMSG to compile on OpenBSD
Date: Wed, 11 Oct 2017 16:01:03 +0100 [thread overview]
Message-ID: <CAFEAcA-TRT0TbkfVF7TFdGJQRWSdTaTgmyhvebfix+SSsP+a+A@mail.gmail.com> (raw)
In-Reply-To: <1507732945-23555-1-git-send-email-stefanb@linux.vnet.ibm.com>
On 11 October 2017 at 15:42, Stefan Berger <stefanb@linux.vnet.ibm.com> wrote:
> 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 | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c
> index fb929f6..a83c6f4 100644
> --- a/hw/tpm/tpm_util.c
> +++ b/hw/tpm/tpm_util.c
> @@ -71,7 +71,7 @@ static int tpm_util_test(int fd,
> return errno;
> }
> if (n != requestlen) {
> - return EFAULT;
> + return -EFAULT;
> }
>
> FD_ZERO(&readfds);
> @@ -85,13 +85,13 @@ static int tpm_util_test(int fd,
>
> 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);
You also need to change the "return errno;" lines. "errno"
contains positive errno values, so for a "return 0-or-negative-errno"
convention you want "return -errno;".
thanks
-- PMM
prev parent reply other threads:[~2017-10-11 15:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 14:42 [Qemu-devel] [PATCH v2] tpm: Use EMSGSIZE instead of EBADMSG to compile on OpenBSD Stefan Berger
2017-10-11 15:01 ` Peter Maydell [this message]
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=CAFEAcA-TRT0TbkfVF7TFdGJQRWSdTaTgmyhvebfix+SSsP+a+A@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=amarnath.valluri@intel.com \
--cc=marcandre.lureau@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.vnet.ibm.com \
/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).