public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] API PathRemoveLastItem not handle root paths properly
@ 2016-11-17  6:32 Hao Wu
  2016-11-17  6:32 ` [PATCH v2] MdePkg BaseLib: " Hao Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Hao Wu @ 2016-11-17  6:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni, Liming Gao

Changes made comparing V1:
The checks added in V1 patch will lead to PathRemoveLastItem() API
behavior change. V2 of the patch will only focus on correcting the API
behavior on input paths like 'fs0:\'.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>

Hao Wu (1):
  MdePkg BaseLib: API PathRemoveLastItem not handle root paths properly

 MdePkg/Include/Library/BaseLib.h   | 3 +--
 MdePkg/Library/BaseLib/FilePaths.c | 9 +++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

-- 
1.9.5.msysgit.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] MdePkg BaseLib: API PathRemoveLastItem not handle root paths properly
  2016-11-17  6:32 [PATCH v2] API PathRemoveLastItem not handle root paths properly Hao Wu
@ 2016-11-17  6:32 ` Hao Wu
  2016-11-17  7:40   ` Ni, Ruiyu
  0 siblings, 1 reply; 3+ messages in thread
From: Hao Wu @ 2016-11-17  6:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni, Liming Gao

https://bugzilla.tianocore.org/show_bug.cgi?id=239

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 file removed in the above case.

This commit adds additional check to resolve this issue and modifies the
API's description to make it more straightforward.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdePkg/Include/Library/BaseLib.h   | 3 +--
 MdePkg/Library/BaseLib/FilePaths.c | 9 +++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

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 (
 //
 
 /**
-  Removes the last directory or file entry in a path by changing the last
-  L'\' to a CHAR_NULL.
+  Removes the last directory or file entry in a path.
 
   @param[in, out] Path    The pointer to the path to modify.
 
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  <Library/BaseLib.h>
 
 /**
-  Removes the last directory or file entry in a path by changing the last
-  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:".
 
   @param[in,out] Path     A pointer to the path to modify.
 
@@ -38,7 +37,9 @@ PathRemoveLastItem(
       ; Walker != NULL && *Walker != CHAR_NULL
       ; Walker++
      ){
-    if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != CHAR_NULL) {
+    if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {
+      LastSlash = Walker+1;
+    } else if (*Walker == L':' && *(Walker + 1) != L'\\' && *(Walker + 1) != CHAR_NULL) {
       LastSlash = Walker+1;
     }
   }
-- 
1.9.5.msysgit.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] MdePkg BaseLib: API PathRemoveLastItem not handle root paths properly
  2016-11-17  6:32 ` [PATCH v2] MdePkg BaseLib: " Hao Wu
@ 2016-11-17  7:40   ` Ni, Ruiyu
  0 siblings, 0 replies; 3+ messages in thread
From: Ni, Ruiyu @ 2016-11-17  7:40 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

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 <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Gao,
> Liming <liming.gao@intel.com>
> Subject: [PATCH v2] MdePkg BaseLib: API PathRemoveLastItem not handle
> root paths properly
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=239
> 
> 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 file
> removed in the above case.
> 
> This commit adds additional check to resolve this issue and modifies the API's
> description to make it more straightforward.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
>  MdePkg/Include/Library/BaseLib.h   | 3 +--
>  MdePkg/Library/BaseLib/FilePaths.c | 9 +++++----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> 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 (
>  //
> 
>  /**
> -  Removes the last directory or file entry in a path by changing the last
> -  L'\' to a CHAR_NULL.
> +  Removes the last directory or file entry in a path.
> 
>    @param[in, out] Path    The pointer to the path to modify.
> 
> 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  <Library/BaseLib.h>
> 
>  /**
> -  Removes the last directory or file entry in a path by changing the last
> -  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:".
> 
>    @param[in,out] Path     A pointer to the path to modify.
> 
> @@ -38,7 +37,9 @@ PathRemoveLastItem(
>        ; Walker != NULL && *Walker != CHAR_NULL
>        ; Walker++
>       ){
> -    if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != CHAR_NULL) {
> +    if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {
> +      LastSlash = Walker+1;
> +    } else if (*Walker == L':' && *(Walker + 1) != L'\\' && *(Walker +
> + 1) != CHAR_NULL) {
>        LastSlash = Walker+1;
>      }
>    }
> --
> 1.9.5.msysgit.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-17  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-17  6:32 [PATCH v2] API PathRemoveLastItem not handle root paths properly Hao Wu
2016-11-17  6:32 ` [PATCH v2] MdePkg BaseLib: " Hao Wu
2016-11-17  7:40   ` Ni, Ruiyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox