]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: align ERROR/WARNING/RETURN macros with MdePkg versions
authorLeif Lindholm <leif.lindholm@linaro.org>
Tue, 5 Dec 2017 16:10:15 +0000 (16:10 +0000)
committerLeif Lindholm <leif.lindholm@linaro.org>
Fri, 8 Dec 2017 09:54:05 +0000 (09:54 +0000)
BaseTools' BaseTypes.h defined the ENCODE_ERROR macro as
 #define ENCODE_ERROR(a)              ((RETURN_STATUS)(MAX_BIT | (a)))
whereas MdePkg defines it as
 #define ENCODE_ERROR(StatusCode)     ((RETURN_STATUS)(MAX_BIT | (StatusCode)))

When building with GCC 6.3 (at least) the former triggers
"error: overflow in implicit constant conversion [-Werror=overflow]"
Resolve this by aligning it with the latter one.

This also requires aligning the BaseTools typedef of RETURN_STATUS with
the MdePkg one: INTN -> UINTN.

While at it, update adjacent ENCODE_WARNING and RETURN_ERROR as well.

Add an explicit initialization of *Alignment to 0 in GenFfs.c
GetAlignmentFromFile to get rid of a warning occuring with GCC after
this change (-Werror=maybe-uninitialized).

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/C/GenFfs/GenFfs.c
BaseTools/Source/C/Include/Common/BaseTypes.h

index e2fb3e0d1e942b8db9ed782f86060bd2afd7f53b..3b4a9b776164c7533b86b514d844f0b599b06eda 100644 (file)
@@ -529,6 +529,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
 \r
   InFileHandle        = NULL;\r
   PeFileBuffer        = NULL;\r
+  *Alignment          = 0;\r
 \r
   memset (&ImageContext, 0, sizeof (ImageContext));\r
 \r
index 198647ab9595c979a4a7de3ee877e7b2fb8c4bc1..08b60bae11849008bb88446ae26a7b86dbcf8a0a 100644 (file)
 // EFI Error Codes common to all execution phases\r
 //\r
 \r
-typedef INTN RETURN_STATUS;\r
+typedef UINTN RETURN_STATUS;\r
 \r
 ///\r
 /// Set the upper bit to indicate EFI Error.\r
 ///\r
-#define ENCODE_ERROR(a)              (MAX_BIT | (a))\r
+#define ENCODE_ERROR(a)              ((RETURN_STATUS)(MAX_BIT | (a)))\r
 \r
-#define ENCODE_WARNING(a)            (a)\r
-#define RETURN_ERROR(a)              ((a) < 0)\r
+#define ENCODE_WARNING(a)            ((RETURN_STATUS)(a))\r
+#define RETURN_ERROR(a)              (((INTN)(RETURN_STATUS)(a)) < 0)\r
 \r
 #define RETURN_SUCCESS               0\r
 #define RETURN_LOAD_ERROR            ENCODE_ERROR (1)\r