From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by mx.groups.io with SMTP id smtpd.web12.55969.1606714483209461852 for ; Sun, 29 Nov 2020 21:34:43 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bsdio.com header.s=xmission header.b=DPFv7sNZ; spf=none, err=SPF record not found (domain: bsdio.com, ip: 166.70.13.231, mailfrom: rebecca@bsdio.com) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=bsdio.com; s=xmission; h=Subject:Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qaH+ncULJBQ3xwtYYhvRe5hUebE91XmuqdnsPlupXvo=; b=DPFv7sNZwI4XQmsdhVDVnXmgjI sMVh8L2O1LN2tu/ae3ziovjWMFEV5572s9ueEhWqW+Zw72RWlf4YiaLtMNRBnn2FCfeyoi6JLIYcu wE8KoMDZRucaiow4ukbzONGcJKLHcPlNdKHyElZdBbn4G3ekCAom2wRqDXOnvQKV558U=; Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kjbpi-003pfQ-Ea; Sun, 29 Nov 2020 22:34:42 -0700 Received: from mta5.zcs.xmission.com ([166.70.13.69]) by in02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kjbph-000oEX-1o; Sun, 29 Nov 2020 22:34:42 -0700 Received: from localhost (localhost [127.0.0.1]) by mta5.zcs.xmission.com (Postfix) with ESMTP id B8DDF12804B6; Sun, 29 Nov 2020 22:34:40 -0700 (MST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta5.zcs.xmission.com Received: from mta5.zcs.xmission.com ([127.0.0.1]) by localhost (mta5.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id SqkIOIlywQpt; Sun, 29 Nov 2020 22:34:40 -0700 (MST) Received: from localhost.localdomain (c-174-52-16-57.hsd1.ut.comcast.net [174.52.16.57]) by mta5.zcs.xmission.com (Postfix) with ESMTPSA id 8397D12807A0; Sun, 29 Nov 2020 22:34:40 -0700 (MST) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Rebecca Cran , Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Peter Grehan Date: Sun, 29 Nov 2020 22:34:09 -0700 Message-Id: <20201130053412.2-3-rebecca@bsdio.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20201130053412.2-1-rebecca@bsdio.com> References: <20201130053412.2-1-rebecca@bsdio.com> MIME-Version: 1.0 X-XM-SPF: eid=1kjbph-000oEX-1o;;;mid=<20201130053412.2-3-rebecca@bsdio.com>;;;hst=in02.mta.xmission.com;;;ip=166.70.13.69;;;frm=rebecca@bsdio.com;;;spf=none X-SA-Exim-Connect-IP: 166.70.13.69 X-SA-Exim-Mail-From: rebecca@bsdio.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa04.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMNoVowels,XMSubLong autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4910] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 1397; IP=ok Body=1 Fuz1=1] [Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa04 1397; IP=ok Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;devel@edk2.groups.io X-Spam-Relay-Country: X-Spam-Timing: total 959 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 13 (1.4%), b_tie_ro: 11 (1.2%), parse: 2.4 (0.3%), extract_message_metadata: 23 (2.4%), get_uri_detail_list: 5 (0.6%), tests_pri_-1000: 21 (2.2%), tests_pri_-950: 1.72 (0.2%), tests_pri_-900: 1.29 (0.1%), tests_pri_-90: 185 (19.3%), check_bayes: 183 (19.1%), b_tokenize: 18 (1.9%), b_tok_get_all: 10 (1.1%), b_comp_prob: 3.0 (0.3%), b_tok_touch_all: 146 (15.2%), b_finish: 1.42 (0.1%), tests_pri_0: 696 (72.6%), check_dkim_signature: 1.05 (0.1%), check_dkim_adsp: 2.9 (0.3%), poll_dns_idle: 0.44 (0.0%), tests_pri_10: 2.2 (0.2%), tests_pri_500: 8 (0.8%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 2/5] OvmfPkg: Improve code style/formatting in BhyveFwCtlLib.c X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Content-Transfer-Encoding: 8bit The code style in Library/BhyveFwCtlLib/BhyveFwCtlLib.c was very inconsistent. Fix it to pass the ECC tool checks by typedef'ing structs, and improve indentation. Signed-off-by: Rebecca Cran --- OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c | 136 +++++++++--------- 1 file changed, 69 insertions(+), 67 deletions(-) diff --git a/OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c b/OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c index 8804e1df0b3f..f1f7b2e0d240 100644 --- a/OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c +++ b/OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c @@ -12,27 +12,27 @@ #include "Uefi.h" #include #include +#include #include #include -#include #include #include -#define FW_PORT 0x510 -#define FW_IPORT 0x511 +#define FW_PORT 0x510 +#define FW_IPORT 0x511 /* Transport protocol basic operations */ -#define OP_NULL 1 -#define OP_ECHO 2 -#define OP_GET 3 -#define OP_GET_LEN 4 -#define OP_SET 5 +#define OP_NULL 1 +#define OP_ECHO 2 +#define OP_GET 3 +#define OP_GET_LEN 4 +#define OP_SET 5 /* Transport protocol error returns */ -#define T_ESUCCESS 0 +#define T_ESUCCESS 0 #define T_ENOENT 2 -#define T_E2BIG 7 -#define T_EMSGSIZE 40 +#define T_E2BIG 7 +#define T_EMSGSIZE 40 #define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y)) @@ -43,24 +43,24 @@ STATIC BOOLEAN mBhyveFwCtlSupported = FALSE; STATIC INT32 mBhyveFwCtlTxid = 0xa5; /* XXX Maybe a better inbuilt version of this ? */ -struct BIoVec { - VOID *Base; - UINT32 Len; -}; +typedef struct { + VOID *Base; + UINT32 Len; +} BIO_VEC; -struct MsgRxHdr { +typedef struct { UINT32 Sz; UINT32 Op; UINT32 TxId; UINT32 Err; -}; +} MSG_RX_HDR; STATIC RETURN_STATUS EFIAPI BhyveFwCtl_CvtErr ( - IN UINT32 errno - ) + IN UINT32 errno + ) { RETURN_STATUS Status; @@ -89,8 +89,8 @@ STATIC UINT32 EFIAPI BIov_WLen ( - IN struct BIoVec b[] - ) + IN BIO_VEC b[] + ) { UINT32 i; UINT32 tLen; @@ -112,9 +112,9 @@ BIov_WLen ( STATIC UINT32 BIov_Send_Rem ( - IN UINT32 *Data, - IN UINT32 Len - ) + IN UINT32 *Data, + IN UINT32 Len + ) { union { UINT8 c[4]; @@ -140,7 +140,7 @@ STATIC VOID BIov_Send ( IN char *Data, - IN UINT32 Len + IN UINT32 Len ) { UINT32 *LData; @@ -163,7 +163,7 @@ BIov_Send ( STATIC VOID BIov_SendAll ( - IN struct BIoVec b[] + IN BIO_VEC b[] ) { INT32 i; @@ -182,13 +182,13 @@ STATIC VOID EFIAPI BhyveFwCtl_MsgSend( - IN UINT32 OpCode, - IN struct BIoVec Data[] - ) + IN UINT32 OpCode, + IN BIO_VEC Data[] + ) { - struct BIoVec hIov[4]; - UINT32 Hdr[3]; - UINT32 i; + BIO_VEC hIov[4]; + UINT32 Hdr[3]; + UINT32 i; /* Set up header as an iovec */ for (i = 0; i < 3; i++) { @@ -215,18 +215,19 @@ STATIC RETURN_STATUS EFIAPI BhyveFwCtl_MsgRecv( - OUT struct MsgRxHdr *Rhdr, - OUT struct BIoVec Data[] - ) + OUT MSG_RX_HDR *Rhdr, + OUT BIO_VEC Data[] + ) { - RETURN_STATUS Status; + RETURN_STATUS Status; UINT32 *Dp; - UINT32 Rd; + UINT32 Rd; UINT32 remLen; - INT32 oLen, xLen; + INT32 oLen; + INT32 xLen; Rd = IoRead32 (FW_PORT); - if (Rd < sizeof(struct MsgRxHdr)) { + if (Rd < sizeof (MSG_RX_HDR)) { ; } @@ -237,9 +238,9 @@ BhyveFwCtl_MsgRecv( Rhdr->Err = IoRead32 (FW_PORT); /* Convert transport errno into UEFI error status */ - Status = BhyveFwCtl_CvtErr(Rhdr->Err); + Status = BhyveFwCtl_CvtErr (Rhdr->Err); - remLen = Rd - sizeof(struct MsgRxHdr); + remLen = Rd - sizeof (MSG_RX_HDR); xLen = 0; /* @@ -258,7 +259,7 @@ BhyveFwCtl_MsgRecv( } while (remLen > 0) { *Dp++ = IoRead32 (FW_PORT); - remLen -= sizeof(UINT32); + remLen -= sizeof (UINT32); } Data[0].Len = oLen; } else { @@ -272,7 +273,7 @@ BhyveFwCtl_MsgRecv( /* Drop additional data */ while (xLen > 0) { (void) IoRead32 (FW_PORT); - xLen -= sizeof(UINT32); + xLen -= sizeof (UINT32); } return Status; @@ -283,13 +284,13 @@ STATIC RETURN_STATUS EFIAPI BhyveFwCtl_Msg( - IN UINT32 OpCode, - IN struct BIoVec Sdata[], - OUT struct BIoVec Rdata[] + IN UINT32 OpCode, + IN BIO_VEC Sdata[], + OUT BIO_VEC Rdata[] ) { - struct MsgRxHdr Rh; - RETURN_STATUS Status; + MSG_RX_HDR Rh; + RETURN_STATUS Status; Status = RETURN_SUCCESS; @@ -305,19 +306,19 @@ STATIC RETURN_STATUS EFIAPI BhyveFwCtlGetLen ( - IN CONST CHAR8 *Name, - IN OUT UINT32 *Size + IN CONST CHAR8 *Name, + IN OUT UINT32 *Size ) { - struct BIoVec Req[2], Resp[2]; - RETURN_STATUS Status; + BIO_VEC Req[2], Resp[2]; + RETURN_STATUS Status; Req[0].Base = (VOID *)Name; Req[0].Len = (UINT32)AsciiStrLen (Name) + 1; Req[1].Base = NULL; Resp[0].Base = Size; - Resp[0].Len = sizeof(UINT32); + Resp[0].Len = sizeof (UINT32); Resp[1].Base = NULL; Status = BhyveFwCtl_Msg (OP_GET_LEN, Req, Resp); @@ -335,24 +336,25 @@ STATIC RETURN_STATUS EFIAPI BhyveFwCtlGetVal ( - IN CONST CHAR8 *Name, - OUT VOID *Item, - IN OUT UINT32 *Size + IN CONST CHAR8 *Name, + OUT VOID *Item, + IN OUT UINT32 *Size ) { - struct BIoVec Req[2], Resp[2]; - RETURN_STATUS Status; + BIO_VEC Req[2]; + BIO_VEC Resp[2]; + RETURN_STATUS Status; /* Make sure temp buffer is larger than passed-in size */ - if (*Size > sizeof(FwGetvalBuf.fData)) + if (*Size > sizeof (FwGetvalBuf.fData)) return RETURN_INVALID_PARAMETER; Req[0].Base = (VOID *)Name; - Req[0].Len = (UINT32)AsciiStrLen(Name) + 1; + Req[0].Len = (UINT32)AsciiStrLen (Name) + 1; Req[1].Base = NULL; Resp[0].Base = &FwGetvalBuf; - Resp[0].Len = sizeof(UINT64) + *Size; + Resp[0].Len = sizeof (UINT64) + *Size; Resp[1].Base = NULL; Status = BhyveFwCtl_Msg (OP_GET, Req, Resp); @@ -376,9 +378,9 @@ BhyveFwCtlGetVal ( RETURN_STATUS EFIAPI BhyveFwCtlGet ( - IN CONST CHAR8 *Name, + IN CONST CHAR8 *Name, OUT VOID *Item, - IN OUT UINTN *Size + IN OUT UINTN *Size ) { RETURN_STATUS Status; @@ -403,11 +405,11 @@ BhyveFwCtlGet ( RETURN_STATUS EFIAPI BhyveFwCtlInitialize ( - VOID - ) + VOID + ) { - UINT32 i; - UINT8 ch; + UINT32 i; + UINT8 ch; DEBUG ((DEBUG_INFO, "FwCtlInitialize\n")); -- 2.29.2.windows.2