diff options
author | Jake Garver <jake@nvidia.com> | 2024-07-08 05:00:11 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2025-03-12 09:38:58 +0000 |
commit | dfe43d74bc1640881d613a43250f3426b216673a (patch) | |
tree | 0558a248bc13f5940074d76c37dea28df61124a9 | |
parent | 81031a51a0148a5ff7904f02cc405c8f3b910c55 (diff) | |
download | edk2-dfe43d74bc1640881d613a43250f3426b216673a.zip edk2-dfe43d74bc1640881d613a43250f3426b216673a.tar.gz edk2-dfe43d74bc1640881d613a43250f3426b216673a.tar.bz2 |
DynamicTablesPkg: Resolve cppcheck findings in macros
The CREATE_CM_OBJECT_ID() and CREATE_TABLE_GEN_ID() macros shift an enum
by 31 bits. As enums are signed integers, this generates a portability
finding from cppcheck. To resolve the finding, we'll cast the enum values
to the type expected as output from the macro.
Signed-off-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Girish Mahadevan <gmahadevan@nvidia.com>
-rw-r--r-- | DynamicTablesPkg/Include/ConfigurationManagerObject.h | 4 | ||||
-rw-r--r-- | DynamicTablesPkg/Include/TableGenerator.h | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h b/DynamicTablesPkg/Include/ConfigurationManagerObject.h index 2660522..bf45af0 100644 --- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h +++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h @@ -140,8 +140,8 @@ typedef struct CmObjDescriptor { @retval Returns the Configuration Manager Object ID.
**/
#define CREATE_CM_OBJECT_ID(NameSpaceId, ObjectId) \
- ((((NameSpaceId) & NAMESPACE_ID_MASK) << NAMESPACE_ID_BIT_SHIFT) | \
- ((ObjectId) & OBJECT_ID_MASK))
+ (((((CM_OBJECT_ID)NameSpaceId) & NAMESPACE_ID_MASK) << NAMESPACE_ID_BIT_SHIFT) | \
+ (((CM_OBJECT_ID)ObjectId) & OBJECT_ID_MASK))
/** This macro returns a Configuration Manager Object ID
in the Standard Object Namespace.
diff --git a/DynamicTablesPkg/Include/TableGenerator.h b/DynamicTablesPkg/Include/TableGenerator.h index 0d9ff9a..f28204d 100644 --- a/DynamicTablesPkg/Include/TableGenerator.h +++ b/DynamicTablesPkg/Include/TableGenerator.h @@ -194,9 +194,9 @@ typedef enum TableGeneratorNameSpace { @return a TableGeneratorId calculated from the inputs.
**/
#define CREATE_TABLE_GEN_ID(TableType, TableNameSpaceId, TableId) \
- ((((TableType) << TABLE_TYPE_BIT_SHIFT) & TABLE_TYPE_MASK) | \
- (((TableNameSpaceId) << TABLE_NAMESPACE_ID_BIT_SHIFT) & \
- TABLE_NAMESPACEID_MASK) | ((TableId) & TABLE_ID_MASK))
+ (((((TABLE_GENERATOR_ID)TableType) << TABLE_TYPE_BIT_SHIFT) & TABLE_TYPE_MASK) | \
+ ((((TABLE_GENERATOR_ID)TableNameSpaceId) << TABLE_NAMESPACE_ID_BIT_SHIFT) & \
+ TABLE_NAMESPACEID_MASK) | (((TABLE_GENERATOR_ID)TableId) & TABLE_ID_MASK))
/** Starting bit position for MAJOR revision
*/
|