From nobody Mon Dec 15 03:19:51 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1514252047625352.87808278742807; Mon, 25 Dec 2017 17:34:07 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7FA47222CB332; Mon, 25 Dec 2017 17:29:09 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E4551222F4E00 for ; Mon, 25 Dec 2017 17:29:06 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Dec 2017 17:34:00 -0800 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.165]) by orsmga002.jf.intel.com with ESMTP; 25 Dec 2017 17:33:59 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,457,1508828400"; d="scan'208";a="21327545" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 26 Dec 2017 09:33:49 +0800 Message-Id: <1514252029-12720-6-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1514252029-12720-1-git-send-email-jiaxin.wu@intel.com> References: <1514252029-12720-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 5/5] MdeModulePkg/DxeHttpLib: Refine some coding style. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Ye Ting Cc: Fu Siyuan Cc: Wang Fan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- MdeModulePkg/Include/Library/HttpLib.h | 4 +- MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 118 +++++++++++++----------= ---- 2 files changed, 60 insertions(+), 62 deletions(-) diff --git a/MdeModulePkg/Include/Library/HttpLib.h b/MdeModulePkg/Include/= Library/HttpLib.h index 285a831..9975aea 100644 --- a/MdeModulePkg/Include/Library/HttpLib.h +++ b/MdeModulePkg/Include/Library/HttpLib.h @@ -432,13 +432,13 @@ HttpFreeHeaderFields ( @param[in] Url The URL of a remote host. @param[out] RequestMsg Pointer to the created HTTP request mess= age. NULL if any error occured. @param[out] RequestMsgSize Size of the RequestMsg (in bytes). =20 - @return EFI_SUCCESS If HTTP request string was created succe= ssfully + @retval EFI_SUCCESS If HTTP request string was created succe= ssfully. @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. - @retval EFI_INVALID_PARAMETER The input arguments are invalid + @retval EFI_INVALID_PARAMETER The input arguments are invalid. =20 **/ EFI_STATUS EFIAPI HttpGenRequestMessage ( diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Li= brary/DxeHttpLib/DxeHttpLib.c index 327ca9e..4e5cf84 100644 --- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c +++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c @@ -53,11 +53,12 @@ UriPercentDecode ( Index =3D 0; Offset =3D 0; HexStr[2] =3D '\0'; while (Index < BufferLength) { if (Buffer[Index] =3D=3D '%') { - if (Index + 1 >=3D BufferLength || Index + 2 >=3D BufferLength || !N= ET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[Index+2])) { + if (Index + 1 >=3D BufferLength || Index + 2 >=3D BufferLength ||=20 + !NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[I= ndex+2])) { return EFI_INVALID_PARAMETER; } HexStr[0] =3D Buffer[Index+1]; HexStr[1] =3D Buffer[Index+2]; ResultBuffer[Offset] =3D (CHAR8) AsciiStrHexToUintn (HexStr); @@ -506,11 +507,11 @@ HttpUrlGetHostName ( =20 if (Url =3D=3D NULL || UrlParser =3D=3D NULL || HostName =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - Parser =3D (HTTP_URL_PARSER*) UrlParser; + Parser =3D (HTTP_URL_PARSER *) UrlParser; =20 if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) =3D=3D 0) { return EFI_NOT_FOUND; } =20 @@ -566,11 +567,11 @@ HttpUrlGetIp4 ( =20 if (Url =3D=3D NULL || UrlParser =3D=3D NULL || Ip4Address =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - Parser =3D (HTTP_URL_PARSER*) UrlParser; + Parser =3D (HTTP_URL_PARSER *) UrlParser; =20 if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) =3D=3D 0) { return EFI_NOT_FOUND; } =20 @@ -629,11 +630,11 @@ HttpUrlGetIp6 ( =20 if (Url =3D=3D NULL || UrlParser =3D=3D NULL || Ip6Address =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - Parser =3D (HTTP_URL_PARSER*) UrlParser; + Parser =3D (HTTP_URL_PARSER *) UrlParser; =20 if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) =3D=3D 0) { return EFI_NOT_FOUND; } =20 @@ -694,25 +695,25 @@ HttpUrlGetPort ( IN CHAR8 *Url, IN VOID *UrlParser, OUT UINT16 *Port ) { - CHAR8 *PortString; - EFI_STATUS Status; - UINTN Index; - UINTN Data; - UINT32 ResultLength; + CHAR8 *PortString; + EFI_STATUS Status; + UINTN Index; + UINTN Data; + UINT32 ResultLength; HTTP_URL_PARSER *Parser; =20 if (Url =3D=3D NULL || UrlParser =3D=3D NULL || Port =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 *Port =3D 0; Index =3D 0; =20 - Parser =3D (HTTP_URL_PARSER*) UrlParser; + Parser =3D (HTTP_URL_PARSER *) UrlParser; =20 if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) =3D=3D 0) { return EFI_NOT_FOUND; } =20 @@ -786,11 +787,11 @@ HttpUrlGetPath ( =20 if (Url =3D=3D NULL || UrlParser =3D=3D NULL || Path =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - Parser =3D (HTTP_URL_PARSER*) UrlParser; + Parser =3D (HTTP_URL_PARSER *) UrlParser; =20 if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PATH)) =3D=3D 0) { return EFI_NOT_FOUND; } =20 @@ -1156,21 +1157,21 @@ HttpParseMessageBody ( =20 if (MsgParser =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - Parser =3D (HTTP_BODY_PARSER*) MsgParser; + Parser =3D (HTTP_BODY_PARSER *) MsgParser; =20 if (Parser->IgnoreBody) { Parser->State =3D BodyParserComplete; if (Parser->Callback !=3D NULL) { Status =3D Parser->Callback ( - BodyParseEventOnComplete, - Body, - 0, - Parser->Context - ); + BodyParseEventOnComplete, + Body, + 0, + Parser->Context + ); if (EFI_ERROR (Status)) { return Status; } } return EFI_SUCCESS; @@ -1198,30 +1199,30 @@ HttpParseMessageBody ( // // Identity transfer-coding, just notify user to save the body data. // if (Parser->Callback !=3D NULL) { Status =3D Parser->Callback ( - BodyParseEventOnData, - Char, - MIN (BodyLength, Parser->ContentLength - Parser->Parsed= BodyLength), - Parser->Context - ); + BodyParseEventOnData, + Char, + MIN (BodyLength, Parser->ContentLength - Parser= ->ParsedBodyLength), + Parser->Context + ); if (EFI_ERROR (Status)) { return Status; } } Char +=3D MIN (BodyLength, Parser->ContentLength - Parser->ParsedBod= yLength); Parser->ParsedBodyLength +=3D MIN (BodyLength, Parser->ContentLength= - Parser->ParsedBodyLength); if (Parser->ParsedBodyLength =3D=3D Parser->ContentLength) { Parser->State =3D BodyParserComplete; if (Parser->Callback !=3D NULL) { Status =3D Parser->Callback ( - BodyParseEventOnComplete, - Char, - 0, - Parser->Context - ); + BodyParseEventOnComplete, + Char, + 0, + Parser->Context + ); if (EFI_ERROR (Status)) { return Status; } } } @@ -1302,15 +1303,15 @@ HttpParseMessageBody ( if (*Char =3D=3D '\n') { Parser->State =3D BodyParserComplete; Char++; if (Parser->Callback !=3D NULL) { Status =3D Parser->Callback ( - BodyParseEventOnComplete, - Char, - 0, - Parser->Context - ); + BodyParseEventOnComplete, + Char, + 0, + Parser->Context + ); if (EFI_ERROR (Status)) { return Status; } } break; @@ -1332,15 +1333,15 @@ HttpParseMessageBody ( // RemainderLengthInThis =3D BodyLength - (Char - Body); LengthForCallback =3D MIN (Parser->CurrentChunkSize - Parser->Curren= tChunkParsedSize, RemainderLengthInThis); if (Parser->Callback !=3D NULL) { Status =3D Parser->Callback ( - BodyParseEventOnData, - Char, - LengthForCallback, - Parser->Context - ); + BodyParseEventOnData, + Char, + LengthForCallback, + Parser->Context + ); if (EFI_ERROR (Status)) { return Status; } } Char +=3D LengthForCallback; @@ -1401,11 +1402,11 @@ HttpIsMessageComplete ( =20 if (MsgParser =3D=3D NULL) { return FALSE; } =20 - Parser =3D (HTTP_BODY_PARSER*) MsgParser; + Parser =3D (HTTP_BODY_PARSER *) MsgParser; =20 if (Parser->State =3D=3D BodyParserComplete) { return TRUE; } return FALSE; @@ -1435,11 +1436,11 @@ HttpGetEntityLength ( =20 if (MsgParser =3D=3D NULL || ContentLength =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - Parser =3D (HTTP_BODY_PARSER*) MsgParser; + Parser =3D (HTTP_BODY_PARSER *) MsgParser; =20 if (!Parser->ContentLengthIsValid) { return EFI_NOT_READY; } =20 @@ -1473,11 +1474,10 @@ HttpFreeMsgParser ( @return Pointer to the next string. @return NULL if not find or String is NULL. =20 **/ CHAR8 * -EFIAPI AsciiStrGetNextToken ( IN CONST CHAR8 *String, IN CHAR8 Separator ) { @@ -1618,20 +1618,20 @@ HttpGetFieldNameAndValue ( while (TRUE) { if (*FieldValueStr =3D=3D ' ' || *FieldValueStr =3D=3D '\t') { // // Boundary condition check.=20 // - if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 1) { + if ((UINTN) EndofHeader - (UINTN) FieldValueStr < 1) { return NULL; =20 } =20 FieldValueStr ++; } else if (*FieldValueStr =3D=3D '\r') { // // Boundary condition check.=20 // - if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 3) { + if ((UINTN) EndofHeader - (UINTN) FieldValueStr < 3) { return NULL; =20 } =20 if (*(FieldValueStr + 1) =3D=3D '\n' && (*(FieldValueStr + 2) =3D=3D= ' ' || *(FieldValueStr + 2) =3D=3D '\t')) { FieldValueStr =3D FieldValueStr + 3; @@ -1713,13 +1713,13 @@ HttpFreeHeaderFields ( @param[in] Url The URL of a remote host. @param[out] RequestMsg Pointer to the created HTTP request mess= age. NULL if any error occured. @param[out] RequestMsgSize Size of the RequestMsg (in bytes). =20 - @return EFI_SUCCESS If HTTP request string was created succe= ssfully + @retval EFI_SUCCESS If HTTP request string was created succe= ssfully. @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. - @retval EFI_INVALID_PARAMETER The input arguments are invalid + @retval EFI_INVALID_PARAMETER The input arguments are invalid. =20 **/ EFI_STATUS EFIAPI HttpGenRequestMessage ( @@ -1767,11 +1767,11 @@ HttpGenRequestMessage ( // Locate the HTTP_UTILITIES protocol. // Status =3D gBS->LocateProtocol ( &gEfiHttpUtilitiesProtocolGuid, NULL, - (VOID **)&HttpUtilitiesProtocol + (VOID **) &HttpUtilitiesProtocol ); =20 if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR,"Failed to locate Http Utilities protocol. Statu= s =3D %r.\n", Status)); return Status; @@ -1791,24 +1791,22 @@ HttpGenRequestMessage ( =20 // // Build raw HTTP Headers // Status =3D HttpUtilitiesProtocol->Build ( - HttpUtilitiesProtocol, - 0, - NULL, - 0, - NULL, - Message->HeaderCount, - AppendList, - &HttpHdrSize, - &HttpHdr - ); - - if (AppendList !=3D NULL) { - FreePool (AppendList); - } + HttpUtilitiesProtocol, + 0, + NULL, + 0, + NULL, + Message->HeaderCount, + AppendList, + &HttpHdrSize, + &HttpHdr + ); + + FreePool (AppendList); =20 if (EFI_ERROR (Status) || HttpHdr =3D=3D NULL){ return Status; } } @@ -1834,11 +1832,11 @@ HttpGenRequestMessage ( MsgSize +=3D Message->BodyLength; =20 // // memory for the string that needs to be sent to TCP // - *RequestMsg =3D NULL; + *RequestMsg =3D NULL; *RequestMsg =3D AllocateZeroPool (MsgSize); if (*RequestMsg =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; goto Exit; } --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel