From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 CD9E481F26 for ; Wed, 16 Nov 2016 23:40:27 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP; 16 Nov 2016 23:40:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,504,1473145200"; d="scan'208";a="32391410" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 16 Nov 2016 23:40:32 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 16 Nov 2016 23:40:32 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 16 Nov 2016 23:40:32 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.142]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.239]) with mapi id 14.03.0248.002; Thu, 17 Nov 2016 15:40:30 +0800 From: "Ni, Ruiyu" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH v2] MdePkg BaseLib: API PathRemoveLastItem not handle root paths properly Thread-Index: AQHSQJxzDmcCLuYHT0C/DYelioHDu6Dcyi1w Date: Thu, 17 Nov 2016 07:40:29 +0000 Deferred-Delivery: Thu, 17 Nov 2016 07:40:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D58E7D66B@SHSMSX104.ccr.corp.intel.com> References: <1479364343-21736-1-git-send-email-hao.a.wu@intel.com> <1479364343-21736-2-git-send-email-hao.a.wu@intel.com> In-Reply-To: <1479364343-21736-2-git-send-email-hao.a.wu@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] MdePkg BaseLib: API PathRemoveLastItem not handle root paths properly 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: Thu, 17 Nov 2016 07:40:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni Thanks/Ray > -----Original Message----- > From: Wu, Hao A > Sent: Thursday, November 17, 2016 2:32 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Ni, Ruiyu ; Gao, > Liming > Subject: [PATCH v2] MdePkg BaseLib: API PathRemoveLastItem not handle > root paths properly >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D239 >=20 > When the input path for API PathRemoveLastItem() is a root path like 'fs0= :\', > the API will return TRUE (indicating a directory or file was removed from= the > path) and modifies the path to 'fs0:'. In fact, there's no directory or f= ile > removed in the above case. >=20 > This commit adds additional check to resolve this issue and modifies the = API's > description to make it more straightforward. >=20 > Cc: Ruiyu Ni > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu > --- > MdePkg/Include/Library/BaseLib.h | 3 +-- > MdePkg/Library/BaseLib/FilePaths.c | 9 +++++---- > 2 files changed, 6 insertions(+), 6 deletions(-) >=20 > diff --git a/MdePkg/Include/Library/BaseLib.h > b/MdePkg/Include/Library/BaseLib.h > index 6268e6f..b69c703 100644 > --- a/MdePkg/Include/Library/BaseLib.h > +++ b/MdePkg/Include/Library/BaseLib.h > @@ -1747,8 +1747,7 @@ BcdToDecimal8 ( > // >=20 > /** > - Removes the last directory or file entry in a path by changing the las= t > - L'\' to a CHAR_NULL. > + Removes the last directory or file entry in a path. >=20 > @param[in, out] Path The pointer to the path to modify. >=20 > diff --git a/MdePkg/Library/BaseLib/FilePaths.c > b/MdePkg/Library/BaseLib/FilePaths.c > index 183b323..29a84ea 100644 > --- a/MdePkg/Library/BaseLib/FilePaths.c > +++ b/MdePkg/Library/BaseLib/FilePaths.c > @@ -14,9 +14,8 @@ > #include >=20 > /** > - Removes the last directory or file entry in a path by changing the las= t > - L'\' to a CHAR_NULL. For a path which is like L"fs0:startup.nsh", > - it's converted to L"fs0:". > + Removes the last directory or file entry in a path. For a path which > + is like L"fs0:startup.nsh", it's converted to L"fs0:". >=20 > @param[in,out] Path A pointer to the path to modify. >=20 > @@ -38,7 +37,9 @@ PathRemoveLastItem( > ; Walker !=3D NULL && *Walker !=3D CHAR_NULL > ; Walker++ > ){ > - if ((*Walker =3D=3D L'\\' || *Walker =3D=3D L':') && *(Walker + 1) != =3D CHAR_NULL) { > + if (*Walker =3D=3D L'\\' && *(Walker + 1) !=3D CHAR_NULL) { > + LastSlash =3D Walker+1; > + } else if (*Walker =3D=3D L':' && *(Walker + 1) !=3D L'\\' && *(Walk= er + > + 1) !=3D CHAR_NULL) { > LastSlash =3D Walker+1; > } > } > -- > 1.9.5.msysgit.0