Skip to content

Commit 02c88f2

Browse files
mikebeatonmergify[bot]
authored andcommitted
DynamicTablesPkg: Fix used uninitialized warning from CLANG toolchains
The compiler is not spotting that the inverse of the same conditions has already been checked, therefore either the 'if' or the 'else if' has to happen. On the other hand, it is misleading coding to use 'else if' for something that has to happen given earlier checks. This fixes the misleading coding and the warning. We definitely want to keep the warning enabled, as it has caught several genuine cases of uninitialized use. Signed-off-by: Mike Beaton <[email protected]>
1 parent 4c8ba6a commit 02c88f2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/CmObjectTokenFixer.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,6 @@ FixupCmObjectSelfToken (
290290
}
291291

292292
// Only support Arm and RISC-V objects for now.
293-
if ((GET_CM_NAMESPACE_ID (CmObjDesc->ObjectId) != EObjNameSpaceArm) &&
294-
(GET_CM_NAMESPACE_ID (CmObjDesc->ObjectId) != EObjNameSpaceRiscV))
295-
{
296-
ASSERT (0);
297-
return EFI_UNSUPPORTED;
298-
}
299-
300293
if (GET_CM_NAMESPACE_ID (CmObjDesc->ObjectId) == EObjNameSpaceArm) {
301294
ArmNamespaceObjId = GET_CM_OBJECT_ID (CmObjDesc->ObjectId);
302295
if (ArmNamespaceObjId >= EArmObjMax) {
@@ -315,6 +308,12 @@ FixupCmObjectSelfToken (
315308

316309
// Fixup self-token if necessary.
317310
TokenFixerFunc = RiscVTokenFixer[RiscVNamespaceObjId];
311+
} else {
312+
ASSERT (
313+
(GET_CM_NAMESPACE_ID (CmObjDesc->ObjectId) == EObjNameSpaceArm) ||
314+
(GET_CM_NAMESPACE_ID (CmObjDesc->ObjectId) == EObjNameSpaceRiscV)
315+
);
316+
return EFI_UNSUPPORTED;
318317
}
319318

320319
if (TokenFixerFunc != NULL) {

0 commit comments

Comments
 (0)