MdeModulePkg/VarCheckHiiLib: clean up VarCheckHiiLibReceiveHiiBinHandler

Building VarCheckHiiLib fails on my clang 19.1.6 setup with the error
 variable 'Status' is used uninitialized whenever 'if' condition is false
due to the DispatchHandle != NULL test.

Calling this function with a NULL handle makes no sense, so move the test
to the function entry and return failure if appropriate.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
This commit is contained in:
Leif Lindholm
2025-02-12 19:05:20 +00:00
committed by mergify[bot]
parent f6aba88ac8
commit 22919e560b

View File

@@ -57,7 +57,7 @@ VarCheckHiiLibReceiveHiiBinHandler (
//
// If input is invalid, stop processing this SMI
//
if ((CommBuffer == NULL) || (CommBufferSize == NULL)) {
if ((DispatchHandle == NULL) || (CommBuffer == NULL) || (CommBufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -75,16 +75,16 @@ VarCheckHiiLibReceiveHiiBinHandler (
}
CopyMem (mMmReceivedVarCheckHiiBin, CommBuffer, mMmReceivedVarCheckHiiBinSize);
if (DispatchHandle != NULL) {
Status = gMmst->MmiHandlerUnRegister (DispatchHandle);
}
Status = gMmst->MmiHandlerUnRegister (DispatchHandle);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Failed to unregister handler - %r!\n", __func__, Status));
} else {
DEBUG ((DEBUG_INFO, "%a: Handler unregistered successfully.\n", __func__));
return Status;
}
DEBUG ((DEBUG_INFO, "%a: Handler unregistered successfully.\n", __func__));
return EFI_SUCCESS;
}