From 56723842fd47bfdfd738c981b428ea625d0af35f Mon Sep 17 00:00:00 2001 From: Tuan Phan Date: Tue, 10 Feb 2026 15:20:45 -0800 Subject: [PATCH] NetworkPkg: HttpBootDxe: Fix uninitialized variable warnings In HttpBootGetBootFileCaller(), under the LoadBootFile case, the Status variable is only assigned within a for loop. If the loop is not executed, this results in an uninitialized variable warning when Status is later referenced. Resolve this issue by return Status directly inside the loop. Signed-off-by: Tuan Phan --- NetworkPkg/HttpBootDxe/HttpBootImpl.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe/HttpBootImpl.c index 00f1102eb6..a4f0b3c0f0 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c @@ -432,8 +432,7 @@ HttpBootGetBootFileCaller ( if (*BufferSize < Private->BootFileSize) { *BufferSize = Private->BootFileSize; *ImageType = Private->ImageType; - Status = EFI_BUFFER_TOO_SMALL; - return Status; + return EFI_BUFFER_TOO_SMALL; } // @@ -448,10 +447,14 @@ HttpBootGetBootFileCaller ( ImageType ); if (!EFI_ERROR (Status) || - ((Status != EFI_TIMEOUT) && (Status != EFI_DEVICE_ERROR)) || - (Retries >= PcdGet32 (PcdMaxHttpResumeRetries))) + ((Status != EFI_TIMEOUT) && (Status != EFI_DEVICE_ERROR))) { - break; + return Status; + } + + if (Retries == PcdGet32 (PcdMaxHttpResumeRetries)) { + DEBUG ((DEBUG_ERROR, "HttpBootGetBootFileCaller: Error downloading NBP file, even after trying to resume %d times.\n", Retries)); + return Status; } // @@ -463,23 +466,22 @@ HttpBootGetBootFileCaller ( HttpIoDestroyIo (&Private->HttpIo); Status = HttpBootCreateHttpIo (Private); if (EFI_ERROR (Status)) { - break; + return Status; } DEBUG ((DEBUG_WARN | DEBUG_INFO, "HttpBootGetBootFileCaller: NBP file download interrupted, will try to resume the operation.\n")); gBS->Stall (1000 * 1000 * PcdGet32 (PcdHttpDelayBetweenResumeRetries)); } - if (EFI_ERROR (Status) && (Retries >= PcdGet32 (PcdMaxHttpResumeRetries))) { - DEBUG ((DEBUG_ERROR, "HttpBootGetBootFileCaller: Error downloading NBP file, even after trying to resume %d times.\n", Retries)); - } - - return Status; + // + // Only reach here if the for loop above is not executed, which means PcdMaxHttpResumeRetries is 0. + // + return EFI_UNSUPPORTED; case GetBootFileError: default: AsciiPrint ("\n Error: Could not retrieve NBP file size from HTTP server.\n"); - return Status; + return EFI_UNSUPPORTED; } } }