diff mbox

[edk2,03/19] OvmfPkg/XenBusDxe: eliminate AsciiStrCat() calls

Message ID 20161021212737.15974-4-lersek@redhat.com
State Accepted
Commit 2462bd3d85a77132e317ef90f66ef9d4ae4f54ac
Headers show

Commit Message

Laszlo Ersek Oct. 21, 2016, 9:27 p.m. UTC
AsciiStrCat() is deprecated / disabled under the
DISABLE_NEW_DEPRECATED_INTERFACES feature test macro.

Replace AsciiStrCat() with AsciiSPrint(). Spell out the (already existent)
PrintLib dependency in the INF file. Add an explicit ASSERT() to document
that XenStoreJoin() assumes that the pool allocation always succeeds.

Cc: Anthony PERARD <anthony.perard@citrix.com>
Cc: Gary Lin <glin@suse.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=166
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

---

Notes:
    not used in my setup, testing would be appreciated

 OvmfPkg/XenBusDxe/XenBusDxe.inf |  1 +
 OvmfPkg/XenBusDxe/XenStore.c    | 15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

-- 
2.9.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Gary Lin Oct. 24, 2016, 4:44 a.m. UTC | #1
On Fri, Oct 21, 2016 at 11:27:21PM +0200, Laszlo Ersek wrote:
> AsciiStrCat() is deprecated / disabled under the

> DISABLE_NEW_DEPRECATED_INTERFACES feature test macro.

> 

> Replace AsciiStrCat() with AsciiSPrint(). Spell out the (already existent)

> PrintLib dependency in the INF file. Add an explicit ASSERT() to document

> that XenStoreJoin() assumes that the pool allocation always succeeds.

> 


Reviewed-by: Gary Lin <glin@suse.com> and Tested-by: Gary Lin <glin@suse.com>


> Cc: Anthony PERARD <anthony.perard@citrix.com>

> Cc: Gary Lin <glin@suse.com>

> Cc: Jordan Justen <jordan.l.justen@intel.com>

> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=166

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

> ---

> 

> Notes:

>     not used in my setup, testing would be appreciated

> 

>  OvmfPkg/XenBusDxe/XenBusDxe.inf |  1 +

>  OvmfPkg/XenBusDxe/XenStore.c    | 15 +++++++++------

>  2 files changed, 10 insertions(+), 6 deletions(-)

> 

> diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf

> index f0c5db98b1f4..5ff1cd04840c 100644

> --- a/OvmfPkg/XenBusDxe/XenBusDxe.inf

> +++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf

> @@ -56,6 +56,7 @@ [LibraryClasses]

>    DebugLib

>    XenHypercallLib

>    SynchronizationLib

> +  PrintLib

>  

>  [Protocols]

>    gEfiDriverBindingProtocolGuid

> diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c

> index aa3ff7d3017b..b7ae1d04863d 100644

> --- a/OvmfPkg/XenBusDxe/XenStore.c

> +++ b/OvmfPkg/XenBusDxe/XenStore.c

> @@ -303,14 +303,17 @@ XenStoreJoin (

>    )

>  {

>    CHAR8 *Buf;

> +  UINTN BufSize;

>  

>    /* +1 for '/' and +1 for '\0' */

> -  Buf = AllocateZeroPool (

> -          AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2);

> -  AsciiStrCat (Buf, DirectoryPath);

> -  if (Node[0] != '\0') {

> -    AsciiStrCat (Buf, "/");

> -    AsciiStrCat (Buf, Node);

> +  BufSize = AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2;

> +  Buf = AllocatePool (BufSize);

> +  ASSERT (Buf != NULL);

> +

> +  if (Node[0] == '\0') {

> +    AsciiSPrint (Buf, BufSize, "%a", DirectoryPath);

> +  } else {

> +    AsciiSPrint (Buf, BufSize, "%a/%a", DirectoryPath, Node);

>    }

>  

>    return Buf;

> -- 

> 2.9.2

> 

> 

> 

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf
index f0c5db98b1f4..5ff1cd04840c 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.inf
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf
@@ -56,6 +56,7 @@  [LibraryClasses]
   DebugLib
   XenHypercallLib
   SynchronizationLib
+  PrintLib
 
 [Protocols]
   gEfiDriverBindingProtocolGuid
diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c
index aa3ff7d3017b..b7ae1d04863d 100644
--- a/OvmfPkg/XenBusDxe/XenStore.c
+++ b/OvmfPkg/XenBusDxe/XenStore.c
@@ -303,14 +303,17 @@  XenStoreJoin (
   )
 {
   CHAR8 *Buf;
+  UINTN BufSize;
 
   /* +1 for '/' and +1 for '\0' */
-  Buf = AllocateZeroPool (
-          AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2);
-  AsciiStrCat (Buf, DirectoryPath);
-  if (Node[0] != '\0') {
-    AsciiStrCat (Buf, "/");
-    AsciiStrCat (Buf, Node);
+  BufSize = AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2;
+  Buf = AllocatePool (BufSize);
+  ASSERT (Buf != NULL);
+
+  if (Node[0] == '\0') {
+    AsciiSPrint (Buf, BufSize, "%a", DirectoryPath);
+  } else {
+    AsciiSPrint (Buf, BufSize, "%a/%a", DirectoryPath, Node);
   }
 
   return Buf;