Skip to content

Commit

Permalink
MdeModulePkg/HiiDatabaseDxe: Avoid struct assignment
Browse files Browse the repository at this point in the history
Struct assignments are not permitted in EDK2, as they may be converted
by the compiler into calls to the 'memcpy' intrinsic, which is not
guaranteed to be available in EDK2.

So replace the assignment with a call to CopyMem (), and -while at it-
replace the loop with a single CopyMem () call, as the loop operates on
items that are contiguous in memory.

Signed-off-by: Ard Biesheuvel <[email protected]>
  • Loading branch information
ardbiesheuvel authored and mergify[bot] committed Jun 4, 2024
1 parent 839bd17 commit de4cc40
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,6 @@ HiiDrawImage (
UINTN BufferLen;
UINT16 Width;
UINT16 Height;
UINTN Xpos;
UINTN Ypos;
UINTN OffsetY1;
UINTN OffsetY2;
Expand Down Expand Up @@ -1390,9 +1389,11 @@ HiiDrawImage (
for (Ypos = 0; Ypos < Height; Ypos++) {
OffsetY1 = Image->Width * Ypos;
OffsetY2 = Width * Ypos;
for (Xpos = 0; Xpos < Width; Xpos++) {
BltBuffer[OffsetY2 + Xpos] = Image->Bitmap[OffsetY1 + Xpos];
}
CopyMem (
&BltBuffer[OffsetY2],
&Image->Bitmap[OffsetY1],
Width * sizeof (*BltBuffer)
);
}
}

Expand Down

0 comments on commit de4cc40

Please sign in to comment.