Redefine CR macro to address Klocwork scanning issue

Klocwork has issue to handle the CR macro in SBL code and it reported
false positives such as unused variables, uninitialized variables, etc.
This patch added special handling to resolve the issues reported by
Klocwork scanning.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
This commit is contained in:
Maurice Ma
2019-10-31 12:47:57 +08:00
parent f6a5597397
commit d233c78427
+11 -7
View File
@@ -571,14 +571,18 @@ DebugPrintLevelEnabled (
@param TestSignature The 32-bit signature value to match.
**/
#if !defined(MDEPKG_NDEBUG)
#define CR(Record, TYPE, Field, TestSignature) \
(DebugAssertEnabled () && (BASE_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \
(TYPE *) (_ASSERT (CR has Bad Signature), Record) : \
BASE_CR (Record, TYPE, Field)
#ifdef __KLOCWORK__
#define CR(Record, TYPE, Field, TestSignature) BASE_CR(Record, TYPE, Field)
#else
#define CR(Record, TYPE, Field, TestSignature) \
BASE_CR (Record, TYPE, Field)
#if !defined(MDEPKG_NDEBUG)
#define CR(Record, TYPE, Field, TestSignature) \
(DebugAssertEnabled () && (BASE_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \
(TYPE *) (_ASSERT (CR has Bad Signature), Record) : \
BASE_CR(Record, TYPE, Field)
#else
#define CR(Record, TYPE, Field, TestSignature) \
BASE_CR(Record, TYPE, Field)
#endif
#endif
#endif