When the only point of use of a variable is a DEBUG() or ASSERT() expression, most compilers will issue a warning when targeting RELEASE. Cast the parameters to VOID to silence these warnings.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Marvin Haeuser <marvin.haeu...@outlook.com> --- MdePkg/Include/Library/DebugLib.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index 93b6f8df34ae..25c8ebb95740 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -270,7 +270,7 @@ DebugPrintLevelEnabled ( } while (FALSE) #define _DEBUG(Expression) _DEBUG_PRINT Expression #else -#define _DEBUG(Expression) DebugPrint Expression + #define _DEBUG(Expression) DebugPrint Expression #endif /** @@ -288,6 +288,8 @@ DebugPrintLevelEnabled ( #if !defined(MDEPKG_NDEBUG) #define ASSERT(Expression) \ do { \ + (VOID)(Expression); \ + \ if (DebugAssertEnabled ()) { \ if (!(Expression)) { \ _ASSERT (Expression); \ @@ -295,7 +297,7 @@ DebugPrintLevelEnabled ( } \ } while (FALSE) #else - #define ASSERT(Expression) + #define ASSERT(Expression) (VOID)(Expression) #endif /** @@ -312,13 +314,15 @@ DebugPrintLevelEnabled ( **/ #if !defined(MDEPKG_NDEBUG) #define DEBUG(Expression) \ + (VOID)(Expression); \ + \ do { \ if (DebugPrintEnabled ()) { \ _DEBUG (Expression); \ } \ } while (FALSE) #else - #define DEBUG(Expression) + #define DEBUG(Expression) (VOID)(Expression) #endif /** @@ -336,6 +340,8 @@ DebugPrintLevelEnabled ( #if !defined(MDEPKG_NDEBUG) #define ASSERT_EFI_ERROR(StatusParameter) \ do { \ + (VOID)(StatusParameter); \ + \ if (DebugAssertEnabled ()) { \ if (EFI_ERROR (StatusParameter)) { \ DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter)); \ @@ -344,7 +350,7 @@ DebugPrintLevelEnabled ( } \ } while (FALSE) #else - #define ASSERT_EFI_ERROR(StatusParameter) + #define ASSERT_EFI_ERROR(StatusParameter) (VOID)(StatusParameter) #endif /** @@ -372,6 +378,9 @@ DebugPrintLevelEnabled ( #if !defined(MDEPKG_NDEBUG) #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \ do { \ + (VOID)(Handle); \ + (VOID)(Guid); \ + \ if (DebugAssertEnabled ()) { \ VOID *Instance; \ ASSERT (Guid != NULL); \ @@ -387,7 +396,7 @@ DebugPrintLevelEnabled ( } \ } while (FALSE) #else - #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) + #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) (VOID)(Handle) #endif /** -- 2.7.4.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel