From nobody Sat Apr 27 02:07:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150775138251550.825426135948646; Wed, 11 Oct 2017 12:49:42 -0700 (PDT) Received: from localhost ([::1]:42433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2N0M-0000x3-M7 for importer@patchew.org; Wed, 11 Oct 2017 15:49:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2Mym-00007x-CU for qemu-devel@nongnu.org; Wed, 11 Oct 2017 15:47:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2Myj-00039T-A9 for qemu-devel@nongnu.org; Wed, 11 Oct 2017 15:47:44 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49924 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2Myj-000392-3n for qemu-devel@nongnu.org; Wed, 11 Oct 2017 15:47:41 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9BJiIeS086438 for ; Wed, 11 Oct 2017 15:47:37 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dhnt8367m-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 11 Oct 2017 15:47:37 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Oct 2017 15:47:36 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 11 Oct 2017 15:47:33 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9BJlW9A48627874; Wed, 11 Oct 2017 19:47:32 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C76A12804A; Wed, 11 Oct 2017 15:47:25 -0400 (EDT) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id BA87728046; Wed, 11 Oct 2017 15:47:25 -0400 (EDT) From: Stefan Berger To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 15:47:29 -0400 X-Mailer: git-send-email 2.5.5 X-TM-AS-GCONF: 00 x-cbid: 17101119-0024-0000-0000-000002E128EF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007879; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000236; SDB=6.00929725; UDB=6.00467962; IPR=6.00709996; BA=6.00005634; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017494; XFM=3.00000015; UTC=2017-10-11 19:47:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101119-0025-0000-0000-000045B2B83F Message-Id: <1507751249-3035-1-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-11_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710110267 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v3] tpm: Use EMSGSIZE instead of EBADMSG to compile on OpenBSD X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, amarnath.valluri@intel.com, marcandre.lureau@gmail.com, Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Marc-Andr=C3=A9 Lureau --- 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, =20 n =3D write(fd, request, requestlen); if (n < 0) { - return errno; + return -errno; } if (n !=3D requestlen) { - return EFAULT; + return -EFAULT; } =20 FD_ZERO(&readfds); @@ -80,18 +80,18 @@ static int tpm_util_test(int fd, /* wait for a second */ n =3D select(fd + 1, &readfds, NULL, NULL, &tv); if (n !=3D 1) { - return errno; + return -errno; } =20 n =3D read(fd, &buf, sizeof(buf)); if (n < sizeof(struct tpm_resp_hdr)) { - return EFAULT; + return -EFAULT; } =20 resp =3D (struct tpm_resp_hdr *)buf; /* check the header */ if (be32_to_cpu(resp->len) !=3D n) { - return EBADMSG; + return -EMSGSIZE; } =20 *return_tag =3D be16_to_cpu(resp->tag); --=20 2.5.5