From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,457,1508828400"; d="scan'208";a="21327545" 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 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Wang Fan , Wu Jiaxin 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: [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: , X-List-Received-Date: Tue, 26 Dec 2017 01:29:07 -0000 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 message. NULL if any error occured. @param[out] RequestMsgSize Size of the RequestMsg (in bytes). - @return EFI_SUCCESS If HTTP request string was created successfully + @retval EFI_SUCCESS If HTTP request string was created successfully. @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. **/ EFI_STATUS EFIAPI HttpGenRequestMessage ( diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Library/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 = 0; Offset = 0; HexStr[2] = '\0'; while (Index < BufferLength) { if (Buffer[Index] == '%') { - if (Index + 1 >= BufferLength || Index + 2 >= BufferLength || !NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[Index+2])) { + if (Index + 1 >= BufferLength || Index + 2 >= BufferLength || + !NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[Index+2])) { return EFI_INVALID_PARAMETER; } HexStr[0] = Buffer[Index+1]; HexStr[1] = Buffer[Index+2]; ResultBuffer[Offset] = (CHAR8) AsciiStrHexToUintn (HexStr); @@ -506,11 +507,11 @@ HttpUrlGetHostName ( if (Url == NULL || UrlParser == NULL || HostName == NULL) { return EFI_INVALID_PARAMETER; } - Parser = (HTTP_URL_PARSER*) UrlParser; + Parser = (HTTP_URL_PARSER *) UrlParser; if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) { return EFI_NOT_FOUND; } @@ -566,11 +567,11 @@ HttpUrlGetIp4 ( if (Url == NULL || UrlParser == NULL || Ip4Address == NULL) { return EFI_INVALID_PARAMETER; } - Parser = (HTTP_URL_PARSER*) UrlParser; + Parser = (HTTP_URL_PARSER *) UrlParser; if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) { return EFI_NOT_FOUND; } @@ -629,11 +630,11 @@ HttpUrlGetIp6 ( if (Url == NULL || UrlParser == NULL || Ip6Address == NULL) { return EFI_INVALID_PARAMETER; } - Parser = (HTTP_URL_PARSER*) UrlParser; + Parser = (HTTP_URL_PARSER *) UrlParser; if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) { return EFI_NOT_FOUND; } @@ -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; if (Url == NULL || UrlParser == NULL || Port == NULL) { return EFI_INVALID_PARAMETER; } *Port = 0; Index = 0; - Parser = (HTTP_URL_PARSER*) UrlParser; + Parser = (HTTP_URL_PARSER *) UrlParser; if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) == 0) { return EFI_NOT_FOUND; } @@ -786,11 +787,11 @@ HttpUrlGetPath ( if (Url == NULL || UrlParser == NULL || Path == NULL) { return EFI_INVALID_PARAMETER; } - Parser = (HTTP_URL_PARSER*) UrlParser; + Parser = (HTTP_URL_PARSER *) UrlParser; if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PATH)) == 0) { return EFI_NOT_FOUND; } @@ -1156,21 +1157,21 @@ HttpParseMessageBody ( if (MsgParser == NULL) { return EFI_INVALID_PARAMETER; } - Parser = (HTTP_BODY_PARSER*) MsgParser; + Parser = (HTTP_BODY_PARSER *) MsgParser; if (Parser->IgnoreBody) { Parser->State = BodyParserComplete; if (Parser->Callback != NULL) { Status = 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 != NULL) { Status = Parser->Callback ( - BodyParseEventOnData, - Char, - MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength), - Parser->Context - ); + BodyParseEventOnData, + Char, + MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength), + Parser->Context + ); if (EFI_ERROR (Status)) { return Status; } } Char += MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength); Parser->ParsedBodyLength += MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength); if (Parser->ParsedBodyLength == Parser->ContentLength) { Parser->State = BodyParserComplete; if (Parser->Callback != NULL) { Status = 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 == '\n') { Parser->State = BodyParserComplete; Char++; if (Parser->Callback != NULL) { Status = 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 = BodyLength - (Char - Body); LengthForCallback = MIN (Parser->CurrentChunkSize - Parser->CurrentChunkParsedSize, RemainderLengthInThis); if (Parser->Callback != NULL) { Status = Parser->Callback ( - BodyParseEventOnData, - Char, - LengthForCallback, - Parser->Context - ); + BodyParseEventOnData, + Char, + LengthForCallback, + Parser->Context + ); if (EFI_ERROR (Status)) { return Status; } } Char += LengthForCallback; @@ -1401,11 +1402,11 @@ HttpIsMessageComplete ( if (MsgParser == NULL) { return FALSE; } - Parser = (HTTP_BODY_PARSER*) MsgParser; + Parser = (HTTP_BODY_PARSER *) MsgParser; if (Parser->State == BodyParserComplete) { return TRUE; } return FALSE; @@ -1435,11 +1436,11 @@ HttpGetEntityLength ( if (MsgParser == NULL || ContentLength == NULL) { return EFI_INVALID_PARAMETER; } - Parser = (HTTP_BODY_PARSER*) MsgParser; + Parser = (HTTP_BODY_PARSER *) MsgParser; if (!Parser->ContentLengthIsValid) { return EFI_NOT_READY; } @@ -1473,11 +1474,10 @@ HttpFreeMsgParser ( @return Pointer to the next string. @return NULL if not find or String is NULL. **/ CHAR8 * -EFIAPI AsciiStrGetNextToken ( IN CONST CHAR8 *String, IN CHAR8 Separator ) { @@ -1618,20 +1618,20 @@ HttpGetFieldNameAndValue ( while (TRUE) { if (*FieldValueStr == ' ' || *FieldValueStr == '\t') { // // Boundary condition check. // - if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 1) { + if ((UINTN) EndofHeader - (UINTN) FieldValueStr < 1) { return NULL; } FieldValueStr ++; } else if (*FieldValueStr == '\r') { // // Boundary condition check. // - if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 3) { + if ((UINTN) EndofHeader - (UINTN) FieldValueStr < 3) { return NULL; } if (*(FieldValueStr + 1) == '\n' && (*(FieldValueStr + 2) == ' ' || *(FieldValueStr + 2) == '\t')) { FieldValueStr = 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 message. NULL if any error occured. @param[out] RequestMsgSize Size of the RequestMsg (in bytes). - @return EFI_SUCCESS If HTTP request string was created successfully + @retval EFI_SUCCESS If HTTP request string was created successfully. @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. **/ EFI_STATUS EFIAPI HttpGenRequestMessage ( @@ -1767,11 +1767,11 @@ HttpGenRequestMessage ( // Locate the HTTP_UTILITIES protocol. // Status = gBS->LocateProtocol ( &gEfiHttpUtilitiesProtocolGuid, NULL, - (VOID **)&HttpUtilitiesProtocol + (VOID **) &HttpUtilitiesProtocol ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR,"Failed to locate Http Utilities protocol. Status = %r.\n", Status)); return Status; @@ -1791,24 +1791,22 @@ HttpGenRequestMessage ( // // Build raw HTTP Headers // Status = HttpUtilitiesProtocol->Build ( - HttpUtilitiesProtocol, - 0, - NULL, - 0, - NULL, - Message->HeaderCount, - AppendList, - &HttpHdrSize, - &HttpHdr - ); - - if (AppendList != NULL) { - FreePool (AppendList); - } + HttpUtilitiesProtocol, + 0, + NULL, + 0, + NULL, + Message->HeaderCount, + AppendList, + &HttpHdrSize, + &HttpHdr + ); + + FreePool (AppendList); if (EFI_ERROR (Status) || HttpHdr == NULL){ return Status; } } @@ -1834,11 +1832,11 @@ HttpGenRequestMessage ( MsgSize += Message->BodyLength; // // memory for the string that needs to be sent to TCP // - *RequestMsg = NULL; + *RequestMsg = NULL; *RequestMsg = AllocateZeroPool (MsgSize); if (*RequestMsg == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Exit; } -- 1.9.5.msysgit.1