From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on072d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe45::72d]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B5E381A1DF7 for ; Fri, 29 Jul 2016 15:26:44 -0700 (PDT) Received: from CS1PR84MB0151.NAMPRD84.PROD.OUTLOOK.COM (10.162.189.30) by CS1PR84MB0149.NAMPRD84.PROD.OUTLOOK.COM (10.162.189.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Fri, 29 Jul 2016 22:26:42 +0000 Received: from CS1PR84MB0151.NAMPRD84.PROD.OUTLOOK.COM ([10.162.189.30]) by CS1PR84MB0151.NAMPRD84.PROD.OUTLOOK.COM ([10.162.189.30]) with mapi id 15.01.0549.016; Fri, 29 Jul 2016 22:26:42 +0000 From: "Palmer, Thomas" To: Jiaxin Wu , "edk2-devel@lists.01.org" CC: Samer El-Haj-Mahmoud , Long Qin , Ye Ting Thread-Topic: [staging/HTTPS-TLS][PATCH 1/2] CryptoPkg/Library/TlsLib: Refine the coding style Thread-Index: AQHR2zcXPMyunhKkWEuVpKrVaFttT6AwGe3Q Date: Fri, 29 Jul 2016 22:26:42 +0000 Message-ID: References: <1468215775-33448-1-git-send-email-jiaxin.wu@intel.com> <1468215775-33448-2-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1468215775-33448-2-git-send-email-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=thomas.palmer@hpe.com; x-originating-ip: [15.203.227.4] x-ms-office365-filtering-correlation-id: 47ea2d15-895e-4dcc-20fd-08d3b7ff6a9e x-microsoft-exchange-diagnostics: 1; CS1PR84MB0149; 6:TV91qKMMTMdCZyZDdaV7Z6Yhtn++J11edmZGliNdJpfkqFJtkMDQJBs7GSvS6cK96zJOwokJ+DcnfX+ypq2RYduMrhDgbbEetp5KWm7dQEcxOqw8RIF6pK7Rvtye3WQ/vw3KKDDnqDk7XEvnSYNuYwPx+HJF7Lvp3o77/5cO+p1baVO9vMvF3Vt08gvx7dEzGvFYZZweQ9KDYOdMTihY6/C3jSYO+oD/RHxKVlEUnzAqmU8XyrQjSAa+0CIDGLMfT5rtosxSSXqQ0/9R99+/KdNmGrQggGOBxbp9xdBKasggohIrpd2hUO1DpZrzFNr/hyzb/0s6J2fQUumFG6wHaw==; 5:5zTqWt41mmp+Ft8ytGLdQcVnpcu7YnFIHuXZULMkKxBA2gwsw5R+E+34ebnZvOAaLwSP/7k8qWpMMoFh6Xu6ypPTYTvos/lrYNLfZ3GMMLhp+38Rov0Tlv9GLiQvH5JzI9Eyfg/poIFzlD9aff0ueQ==; 24:bSEdSyzLdt8SgYYneXVAGCrKk16a8pQv9Dr48XQHpABW9J7e3vZ0/Vb+M7HFhTkFHebS8qFnI4Kiufsuwh2EEYqWmAy8gd8Y9iKpzOh0U3Y=; 7:lCxlB2/ainTA1n7Yd082axuRqaiEbzbOwdQK0gnGhU/QYusMiluNybeLThwJJRh0sNg6QFOC15pc0Ll0lt/DfFOY5a30T2SENrHBrLxhBQBfjk+oh+p4TMot8EM6tuw9QdwAT4lMttvl/PBxBm7AuUJI3pocmhLIFcM4WlVW2WQQwAylGKr8V3Owv9WB22tfX21LjwLrxq8nxUFbO3rnXOJkkklYmrq6ireTIowiMsj9uCAqriImkAH7bNdlZE6P x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0149; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227479698468861)(3940261145250)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CS1PR84MB0149; BCL:0; PCL:0; RULEID:; SRVR:CS1PR84MB0149; x-forefront-prvs: 0018A2705B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(377454003)(189002)(199003)(13464003)(8676002)(2900100001)(3280700002)(106356001)(81156014)(74316002)(106116001)(33656002)(97736004)(2501003)(189998001)(11100500001)(77096005)(3660700001)(8936002)(5001770100001)(4326007)(86362001)(2906002)(81166006)(2950100001)(87936001)(305945005)(92566002)(7736002)(586003)(66066001)(122556002)(9686002)(19580395003)(68736007)(6116002)(19580405001)(10400500002)(102836003)(3846002)(5002640100001)(54356999)(105586002)(99286002)(101416001)(7696003)(76176999)(50986999)(7846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CS1PR84MB0149; H:CS1PR84MB0151.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jul 2016 22:26:42.1602 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0149 Subject: Re: [staging/HTTPS-TLS][PATCH 1/2] CryptoPkg/Library/TlsLib: Refine the coding style X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2016 22:26:45 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed by Thomas Palmer -----Original Message----- From: Jiaxin Wu [mailto:jiaxin.wu@intel.com]=20 Sent: Monday, July 11, 2016 12:43 AM To: edk2-devel@lists.01.org Cc: Palmer, Thomas ; Samer El-Haj-Mahmoud ; Long Qin ; Ye Ting Subject: [staging/HTTPS-TLS][PATCH 1/2] CryptoPkg/Library/TlsLib: Refine th= e coding style Cc: Palmer Thomas Cc: Samer El-Haj-Mahmoud Cc: Long Qin Cc: Ye Ting Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu --- CryptoPkg/Library/TlsLib/TlsLib.c | 52 +++++++++++++++++++++++------------= ---- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/CryptoPkg/Library/TlsLib/TlsLib.c b/CryptoPkg/Library/TlsLib/T= lsLib.c index 814c358..f007882 100644 --- a/CryptoPkg/Library/TlsLib/TlsLib.c +++ b/CryptoPkg/Library/TlsLib/TlsLib.c @@ -614,65 +614,75 @@ TlsDoHandshake ( IN OUT UINTN *BufferOutSize ) { TLS_CONNECTION *TlsConn; UINTN PendingBufferSize; - int ret; - unsigned long e; + INTN Ret; + unsigned long ErrorCode; =20 TlsConn =3D (TLS_CONNECTION *) Tls; PendingBufferSize =3D 0; + Ret =3D 1; =20 if (TlsConn =3D=3D NULL || \ TlsConn->Ssl =3D=3D NULL || TlsConn->InBio =3D=3D NULL || TlsConn->Out= Bio =3D=3D NULL || \ BufferOutSize =3D=3D NULL || \ (BufferIn =3D=3D NULL && BufferInSize !=3D 0) || \ (BufferIn !=3D NULL && BufferInSize =3D=3D 0) || \ (BufferOut =3D=3D NULL && *BufferOutSize !=3D 0)) { return EFI_INVALID_PARAMETER; } =20 - ret =3D 1; if(BufferIn =3D=3D NULL && BufferInSize =3D=3D 0) { // // If RequestBuffer is NULL and RequestSize is 0, and TLS session=20 // status is EfiTlsSessionNotStarted, the TLS session will be initiate= d=20 // and the response packet needs to be ClientHello. // PendingBufferSize =3D (UINTN) BIO_ctrl_pending (TlsConn->OutBio); if (PendingBufferSize =3D=3D 0) { SSL_set_connect_state (TlsConn->Ssl); - ret =3D SSL_do_handshake (TlsConn->Ssl); + Ret =3D SSL_do_handshake (TlsConn->Ssl); PendingBufferSize =3D (UINTN) BIO_ctrl_pending (TlsConn->OutBio); } } else { PendingBufferSize =3D (UINTN) BIO_ctrl_pending (TlsConn->OutBio); if (PendingBufferSize =3D=3D 0) { BIO_write (TlsConn->InBio, BufferIn, (UINT32) BufferInSize); - ret =3D SSL_do_handshake (TlsConn->Ssl); + Ret =3D SSL_do_handshake (TlsConn->Ssl); PendingBufferSize =3D (UINTN) BIO_ctrl_pending (TlsConn->OutBio); } } =20 - if (ret < 1) { - ret =3D SSL_get_error (TlsConn->Ssl, ret); - if (ret =3D=3D SSL_ERROR_SSL || - ret =3D=3D SSL_ERROR_SYSCALL || - ret =3D=3D SSL_ERROR_ZERO_RETURN) { - DEBUG ((DEBUG_ERROR, "%a SSL_HANDSHAKE_ERROR State=3D0x%x SSL_ERROR_= %a\n", __FUNCTION__, SSL_state (TlsConn->Ssl), - ret =3D=3D SSL_ERROR_SSL ? "SSL": - ret =3D=3D SSL_ERROR_SYSCALL ? "SYSCALL": - "ZERO_RETURN" - )); + if (Ret < 1) { + Ret =3D SSL_get_error (TlsConn->Ssl, Ret); + if (Ret =3D=3D SSL_ERROR_SSL || + Ret =3D=3D SSL_ERROR_SYSCALL || + Ret =3D=3D SSL_ERROR_ZERO_RETURN) { + DEBUG (( + DEBUG_ERROR,=20 + "%a SSL_HANDSHAKE_ERROR State=3D0x%x SSL_ERROR_%a\n", + __FUNCTION__,=20 + SSL_state (TlsConn->Ssl), + Ret =3D=3D SSL_ERROR_SSL ? "SSL" : Ret =3D=3D SSL_ERROR_SYSCALL ? = "SYSCALL" : "ZERO_RETURN" + )); DEBUG_CODE_BEGIN (); - while (1) { - e =3D ERR_get_error (); - if (e =3D=3D 0) { - break; + while (TRUE) { + ErrorCode =3D ERR_get_error (); + if (ErrorCode =3D=3D 0) { + break; + } + DEBUG (( + DEBUG_ERROR,=20 + "%a ERROR 0x%x=3DL%x:F%x:R%x\n", + __FUNCTION__,=20 + ErrorCode,=20 + ERR_GET_LIB (ErrorCode),=20 + ERR_GET_FUNC (ErrorCode),=20 + ERR_GET_REASON (ErrorCode) + )); } - DEBUG ((DEBUG_ERROR, "%a ERROR 0x%x=3DL%x:F%x:R%x\n", __FUNCTION__= , e, ERR_GET_LIB (e), ERR_GET_FUNC (e), ERR_GET_REASON (e))); - } DEBUG_CODE_END (); return EFI_PROTOCOL_ERROR; } } =20 --=20 1.9.5.msysgit.1