Skip to content

Commit

Permalink
MdeModulePkg/HiiDatabase: Return default value for BIT VarStore as UN…
Browse files Browse the repository at this point in the history
…IT32

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4874

Question CheckBox, OneOf and Numeric can refer to Bit EFI VarStore.
CheckBox: data type is Boolean (1 byte),
Numeric/Oneof: data type is always UNIT32 for BIT VarStore,
When get default value for BIT VarStore, should return default value
with sizeof (UINT32) rather than the byte the bit width occupied.
Or incorrect default value will be used due to the size mismatch.

Signed-off-by: Dandan Bi <[email protected]>
  • Loading branch information
dandanbi authored and mergify[bot] committed Dec 2, 2024
1 parent 9a9bcac commit 9112fb0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ FindQuestionDefaultSetting (
if (BitFieldQuestion) {
CopyMem (&BufferValue, (UINT8 *)AuthVariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + AuthVariableHeader->NameSize + ByteOffset, Width);
BitFieldVal = BitFieldRead32 (BufferValue, StartBit, EndBit);
CopyMem (ValueBuffer, &BitFieldVal, Width);
CopyMem (ValueBuffer, &BitFieldVal, sizeof (UINT32));
} else {
CopyMem (ValueBuffer, (UINT8 *)AuthVariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + AuthVariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width);
}
Expand Down Expand Up @@ -862,7 +862,7 @@ FindQuestionDefaultSetting (
if (BitFieldQuestion) {
CopyMem (&BufferValue, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + ByteOffset, Width);
BitFieldVal = BitFieldRead32 (BufferValue, StartBit, EndBit);
CopyMem (ValueBuffer, &BitFieldVal, Width);
CopyMem (ValueBuffer, &BitFieldVal, sizeof (UINT32));
} else {
CopyMem (ValueBuffer, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width);
}
Expand Down

0 comments on commit 9112fb0

Please sign in to comment.