From de4cc40b8c1d9044df82e077e72ef6e192ea12e2 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Mon, 3 Jun 2024 10:00:40 +0200 Subject: [PATCH] MdeModulePkg/HiiDatabaseDxe: Avoid struct assignment 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 --- MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c index b5b9625969..ab8f056914 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c @@ -1288,7 +1288,6 @@ HiiDrawImage ( UINTN BufferLen; UINT16 Width; UINT16 Height; - UINTN Xpos; UINTN Ypos; UINTN OffsetY1; UINTN OffsetY2; @@ -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) + ); } }