public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-staging][PATCH 1/1] BaseTools/Fmmt: Fix GCC warnings
@ 2023-07-04 14:03 Albecki, Mateusz
  0 siblings, 0 replies; only message in thread
From: Albecki, Mateusz @ 2023-07-04 14:03 UTC (permalink / raw)
  To: devel; +Cc: Mateusz Albecki, Bob Feng, Liming Gao, Yuwei Chen

GCC is throwing a warning during BaseTools compilation which leads
to build errors when Wall is set. This commit removes all conditions
which are always true/false(Waddress warning) and wraps one snprintf
in compiler pragma to disable format-truncation warning.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
---
 BaseTools/Source/C/BfmLib/BfmLib.c            | 36 +++++++++----------
 BaseTools/Source/C/FCE/BinaryParse.c          |  3 ++
 BaseTools/Source/C/FCE/IfrParse.c             | 24 -------------
 .../Source/C/FMMT/FirmwareModuleManagement.c  |  8 ++---
 BaseTools/Source/C/FMMT/FmmtLib.c             | 20 +++++------
 5 files changed, 31 insertions(+), 60 deletions(-)

diff --git a/BaseTools/Source/C/BfmLib/BfmLib.c b/BaseTools/Source/C/BfmLib/BfmLib.c
index c247cc8e1d..14d29077c8 100644
--- a/BaseTools/Source/C/BfmLib/BfmLib.c
+++ b/BaseTools/Source/C/BfmLib/BfmLib.c
@@ -3738,18 +3738,16 @@ LibLocateFvViaFvId (
   FvIndex1 = (UINT8) atoi (FvId + 2);
 
   while (FvInFd != NULL) {
-    if (((*FvInFd)->FvName) != NULL) {
-      FvIndex2 = (UINT8) atoi ((*FvInFd)->FvName + 2);
+    FvIndex2 = (UINT8) atoi ((*FvInFd)->FvName + 2);
 
-      if ((FvIndex2 <= FvIndex1) && (((*FvInFd)->FvLevel + FvIndex2) -1 >= FvIndex1)) {
-        FvFoundFlag = TRUE;
-        break;
-      }
-      if ((*FvInFd)->FvNext == 0) {
-        break;
-      }
-      *FvInFd = (*FvInFd)->FvNext;
+    if ((FvIndex2 <= FvIndex1) && (((*FvInFd)->FvLevel + FvIndex2) -1 >= FvIndex1)) {
+      FvFoundFlag = TRUE;
+      break;
+    }
+    if ((*FvInFd)->FvNext == 0) {
+      break;
     }
+    *FvInFd = (*FvInFd)->FvNext;
   }
 
   //
@@ -4292,18 +4290,16 @@ LibLocateBfv(
   *FvInFd = FdData->Fv;
 
   while (FvInFd != NULL) {
-    if (((*FvInFd)->FvName) != NULL) {
-      FvIndex2 = (UINT8) atoi ((*FvInFd)->FvName + 2);
+    FvIndex2 = (UINT8) atoi ((*FvInFd)->FvName + 2);
 
-      if ((FvIndex2 <= FvIndex1) && (((*FvInFd)->FvLevel + FvIndex2) -1 >= FvIndex1)) {
-        FvFoundFlag = TRUE;
-        break;
-      }
-      if ((*FvInFd)->FvNext == 0) {
-        break;
-      }
-      *FvInFd = (*FvInFd)->FvNext;
+    if ((FvIndex2 <= FvIndex1) && (((*FvInFd)->FvLevel + FvIndex2) -1 >= FvIndex1)) {
+      FvFoundFlag = TRUE;
+      break;
+    }
+    if ((*FvInFd)->FvNext == 0) {
+      break;
     }
+    *FvInFd = (*FvInFd)->FvNext;
   }
 
   //
diff --git a/BaseTools/Source/C/FCE/BinaryParse.c b/BaseTools/Source/C/FCE/BinaryParse.c
index 6854d546ac..def8089ae4 100644
--- a/BaseTools/Source/C/FCE/BinaryParse.c
+++ b/BaseTools/Source/C/FCE/BinaryParse.c
@@ -1244,7 +1244,10 @@ Done:
         Status = EFI_ABORTED;
         goto Done;
       }
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-truncation"
       snprintf (FileNameArry, 300, "%s%c%s", FolderName, OS_SEP, pDirent->d_name);
+#pragma GCC diagnostic pop
       FfsFile = fopen (FileNameArry, "rb");
       Status = ReadFfsHeader (FfsFile, (UINT32 *)&FileSize);
       if (EFI_ERROR (Status)) {
diff --git a/BaseTools/Source/C/FCE/IfrParse.c b/BaseTools/Source/C/FCE/IfrParse.c
index ba7320f14c..e47afaef66 100644
--- a/BaseTools/Source/C/FCE/IfrParse.c
+++ b/BaseTools/Source/C/FCE/IfrParse.c
@@ -3936,11 +3936,6 @@ StringPrintormSetTitle (
     FormSet->Guid.Data4[5],FormSet->Guid.Data4[6],
     FormSet->Guid.Data4[7]);
   StringPrint("\n");
-
-  if (&(FormSet->EnUsStringList) == NULL && VarDefaultName != NULL && FormSet->FormSetTitle != 0) {
-    free (VarDefaultName);
-    VarDefaultName = NULL;
-  }
 }
 
 /**
@@ -4019,10 +4014,6 @@ PrintOneOfOptions (
 
     LogUnicodeString (VarDefaultName);
     StringPrint("\n");
-    if (&(FormSet->EnUsStringList) == NULL && VarDefaultName != NULL && Option->Text != 0) {
-      free (VarDefaultName);
-      VarDefaultName = NULL;
-    }
     Link = GetNextNode (&Question->OptionListHead, Link);
   }
   return Status;
@@ -4061,12 +4052,6 @@ StringPrintormTitle (
 
   LogUnicodeString (VarDefaultName);
   StringPrint("\n");
-
-  if (&(FormSet->EnUsStringList) == NULL && VarDefaultName != NULL && Form->FormTitle != 0) {
-    free (VarDefaultName);
-    VarDefaultName  = NULL;
-  }
-
 }
 
 /**
@@ -4513,11 +4498,6 @@ PrintQuestion (
     break;
   }
 
-  if (&(FormSet->EnUsStringList) == NULL &&VarDefaultName != NULL && Question->Prompt != 0) {
-    free (VarDefaultName);
-    VarDefaultName = NULL;
-  }
-
   if (PrintOrNot && Question->Storage) {
     StringPrint("// size = 0x%x", Question->StorageWidth);
     StringPrint("\n// offset = 0x%x", Question->VarStoreInfo.VarOffset);
@@ -4545,10 +4525,6 @@ PrintQuestion (
     assert (!EFI_ERROR (Status));
     LogUnicodeString (VarDefaultName);
     StringPrint("\n");
-    if (&(FormSet->EnUsStringList) == NULL &&VarDefaultName != NULL && Question->Help != 0) {
-      free (VarDefaultName);
-      VarDefaultName = NULL;
-    }
   }
 
 }
diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
index 38056153fb..ff4e555881 100644
--- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
+++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
@@ -928,11 +928,9 @@ FmmtImageView (
       // If the FV to be parsed error is the same with the input FV in add, replace and delete
       // operation, abort the program directly.
       //
-      if ((FvName != NULL) && ((CurrentFv->FvName) != NULL) && !strcmp(CurrentFv->FvName, FvName)) {
-        fclose (InputFile);
-        ErrorStatus = EFI_ABORTED;
-        goto Done;
-      }
+      fclose (InputFile);
+      ErrorStatus = EFI_ABORTED;
+      goto Done;
     }
 
 
diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/FmmtLib.c
index e1436112ca..83cc2d7c1f 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -5468,18 +5468,16 @@ LibLocateFvViaFvId (
   FvIndex1 = (UINT8) atoi (FvId + 2);
 
   while (FvInFd != NULL) {
-    if (((*FvInFd)->FvName) != NULL) {
-      FvIndex2 = (UINT8) atoi ((*FvInFd)->FvName + 2);
-      LocalEncapData = (*FvInFd)->EncapData;
-      LibFindFvInEncapData (LocalEncapData, &FvIndex2);
+    FvIndex2 = (UINT8) atoi ((*FvInFd)->FvName + 2);
+    LocalEncapData = (*FvInFd)->EncapData;
+    LibFindFvInEncapData (LocalEncapData, &FvIndex2);
 
-      if ((FvIndex2 - 1 >= FvIndex1)) {
-        FvFoundFlag = TRUE;
-        break;
-      }
-      if ((*FvInFd)->FvNext == 0) {
-        break;
-      }
+    if ((FvIndex2 - 1 >= FvIndex1)) {
+      FvFoundFlag = TRUE;
+      break;
+    }
+    if ((*FvInFd)->FvNext == 0) {
+      break;
     }
     *FvInFd = (*FvInFd)->FvNext;
   }
-- 
2.39.2

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-04 14:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-04 14:03 [edk2-staging][PATCH 1/1] BaseTools/Fmmt: Fix GCC warnings Albecki, Mateusz

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