public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Michael Zimmermann <sigmaepsilon92@gmail.com>
To: edk2-devel-01 <edk2-devel@lists.01.org>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	 Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH] ArmPkg: remove usages of deprecated API's
Date: Mon, 8 Aug 2016 07:44:34 +0200	[thread overview]
Message-ID: <CAN9vWDJ-Yd3RdwV0GvVaH921BOtU6BkuaEUSVbXBY3gFmZXb-g@mail.gmail.com> (raw)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
---
 ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c | 21
+++++++++++----------
 .../Library/ArmDisassemblerLib/ThumbDisassembler.c  | 19
++++++++++---------
 .../Arm/DefaultExceptionHandler.c                   |  9 ++++++---
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
index 29a8d44..410078f 100644
--- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
+++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
@@ -80,7 +80,8 @@ CHAR8 *gLdmStack[] = {
 #define BYTE(_B)  ((_B) ? "B":"")
 #define USER(_B)  ((_B) ? "^" : "")

-CHAR8 mMregListStr[4*15 + 1];
+#define REGLISTSTR_SIZE (4*15 + 1)
+CHAR8 mMregListStr[REGLISTSTR_SIZE];

 CHAR8 *
 MRegList (
@@ -93,7 +94,7 @@ MRegList (

   Str = mMregListStr;
   *Str = '\0';
-  AsciiStrCat  (Str, "{");
+  AsciiStrCatS  (Str, REGLISTSTR_SIZE, "{");
   for (Index = 0, First = TRUE; Index <= 15; Index++) {
     if ((OpCode & (1 << Index)) != 0) {
       Start = End = Index;
@@ -102,25 +103,25 @@ MRegList (
       }

       if (!First) {
-        AsciiStrCat  (Str, ",");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, ",");
       } else {
         First = FALSE;
       }

       if (Start == End) {
-        AsciiStrCat  (Str, gReg[Start]);
-        AsciiStrCat  (Str, ", ");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[Start]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, ", ");
       } else {
-        AsciiStrCat  (Str, gReg[Start]);
-        AsciiStrCat  (Str, "-");
-        AsciiStrCat  (Str, gReg[End]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[Start]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, "-");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[End]);
       }
     }
   }
   if (First) {
-    AsciiStrCat  (Str, "ERROR");
+    AsciiStrCatS  (Str, REGLISTSTR_SIZE, "ERROR");
   }
-  AsciiStrCat  (Str, "}");
+  AsciiStrCatS  (Str, REGLISTSTR_SIZE, "}");

   // BugBug: Make caller pass in buffer it is cleaner
   return mMregListStr;
diff --git a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
index 5bad3af..4f3af9a 100644
--- a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
+++ b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
@@ -389,7 +389,8 @@ CHAR8 *gShiftType[] = {
   "ROR"
 };

-CHAR8 mThumbMregListStr[4*15 + 1];
+#define REGLISTSTR_SIZE (4*15 + 1)
+CHAR8 mThumbMregListStr[REGLISTSTR_SIZE];

 CHAR8 *
 ThumbMRegList (
@@ -402,7 +403,7 @@ ThumbMRegList (

   Str = mThumbMregListStr;
   *Str = '\0';
-  AsciiStrCat  (Str, "{");
+  AsciiStrCatS  (Str, REGLISTSTR_SIZE, "{");

   for (Index = 0, First = TRUE; Index <= 15; Index++) {
     if ((RegBitMask & (1 << Index)) != 0) {
@@ -412,24 +413,24 @@ ThumbMRegList (
       }

       if (!First) {
-        AsciiStrCat  (Str, ",");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, ",");
       } else {
         First = FALSE;
       }

       if (Start == End) {
-        AsciiStrCat  (Str, gReg[Start]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[Start]);
       } else {
-        AsciiStrCat  (Str, gReg[Start]);
-        AsciiStrCat  (Str, "-");
-        AsciiStrCat  (Str, gReg[End]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[Start]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, "-");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[End]);
       }
     }
   }
   if (First) {
-    AsciiStrCat  (Str, "ERROR");
+    AsciiStrCatS  (Str, REGLISTSTR_SIZE, "ERROR");
   }
-  AsciiStrCat  (Str, "}");
+  AsciiStrCatS  (Str, REGLISTSTR_SIZE, "}");

   // BugBug: Make caller pass in buffer it is cleaner
   return mThumbMregListStr;
diff --git
a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
index aece263..fe4abb6 100644
---
a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
+++
b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
@@ -47,12 +47,14 @@ GetImageName (

   @param  Cpsr         ARM CPSR register value
   @param  ReturnStr    32 byte string that contains string version of CPSR
+  @param  ReturnSize   The size of ReturnSize including the terminating
null char.

 **/
 VOID
 CpsrString (
   IN  UINT32  Cpsr,
-  OUT CHAR8   *ReturnStr
+  OUT CHAR8   *ReturnStr,
+  IN  UINTN   ReturnSize
   )
 {
   UINTN     Index;
@@ -84,6 +86,7 @@ CpsrString (

   *Str++ = '_';
   *Str = '\0';
+  ReturnSize--;

   switch (Cpsr & 0x1f) {
   case 0x10:
@@ -116,7 +119,7 @@ CpsrString (
     break;
   }

-  AsciiStrCat (Str, ModeStr);
+  AsciiStrCatS (Str, ReturnSize, ModeStr);
   return;
 }

@@ -197,7 +200,7 @@ DefaultExceptionHandler (
     UINT8   *DisAsm;
     UINT32  ItBlock;

-    CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
+    CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr,
sizeof(CpsrStr));
     DEBUG ((EFI_D_ERROR, "%a\n", CpsrStr));

     Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase,
&PeCoffSizeOfHeader);
-- 
2.9.2


                 reply	other threads:[~2016-08-08  5:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAN9vWDJ-Yd3RdwV0GvVaH921BOtU6BkuaEUSVbXBY3gFmZXb-g@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox