mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
NetworkPkg: Ip4Dxe: Fix uninitialized variable warning
In Ip4FormExtractConfig(), the Status variable was assigned only within a conditional block but used outside of it, which could lead to an uninitialized variable warning. Fix this by moving the relevant code outside of the conditional block so that Status is always properly initialized before use. Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
This commit is contained in:
parent
56723842fd
commit
1cb1184b50
1 changed files with 56 additions and 58 deletions
|
|
@ -891,67 +891,65 @@ Ip4FormExtractConfig (
|
|||
//
|
||||
// Check Request data in <ConfigHdr>.
|
||||
//
|
||||
if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
|
||||
IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG2_IFR_NVDATA));
|
||||
if (IfrFormNvData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Ip4Config2ConvertConfigNvDataToIfrNvData (Ip4Config2Instance, IfrFormNvData);
|
||||
|
||||
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
|
||||
//
|
||||
// Request has no request element, construct full request string.
|
||||
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template
|
||||
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
|
||||
//
|
||||
ConfigRequestHdr = HiiConstructConfigHdr (&gIp4Config2NvDataGuid, mIp4Config2StorageName, Private->ChildHandle);
|
||||
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
||||
ConfigRequest = AllocateZeroPool (Size);
|
||||
if (ConfigRequest == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
AllocatedRequest = TRUE;
|
||||
|
||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||
FreePool (ConfigRequestHdr);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
|
||||
//
|
||||
Status = gHiiConfigRouting->BlockToConfig (
|
||||
gHiiConfigRouting,
|
||||
ConfigRequest,
|
||||
(UINT8 *)IfrFormNvData,
|
||||
BufferSize,
|
||||
&FormResult,
|
||||
Progress
|
||||
);
|
||||
|
||||
FreePool (IfrFormNvData);
|
||||
|
||||
//
|
||||
// Free the allocated config request string.
|
||||
//
|
||||
if (AllocatedRequest) {
|
||||
FreePool (ConfigRequest);
|
||||
ConfigRequest = NULL;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Failure;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
|
||||
*Results = FormResult;
|
||||
} else {
|
||||
if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG2_IFR_NVDATA));
|
||||
if (IfrFormNvData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Ip4Config2ConvertConfigNvDataToIfrNvData (Ip4Config2Instance, IfrFormNvData);
|
||||
|
||||
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
|
||||
//
|
||||
// Request has no request element, construct full request string.
|
||||
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template
|
||||
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
|
||||
//
|
||||
ConfigRequestHdr = HiiConstructConfigHdr (&gIp4Config2NvDataGuid, mIp4Config2StorageName, Private->ChildHandle);
|
||||
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
||||
ConfigRequest = AllocateZeroPool (Size);
|
||||
if (ConfigRequest == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
AllocatedRequest = TRUE;
|
||||
|
||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||
FreePool (ConfigRequestHdr);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
|
||||
//
|
||||
Status = gHiiConfigRouting->BlockToConfig (
|
||||
gHiiConfigRouting,
|
||||
ConfigRequest,
|
||||
(UINT8 *)IfrFormNvData,
|
||||
BufferSize,
|
||||
&FormResult,
|
||||
Progress
|
||||
);
|
||||
|
||||
FreePool (IfrFormNvData);
|
||||
|
||||
//
|
||||
// Free the allocated config request string.
|
||||
//
|
||||
if (AllocatedRequest) {
|
||||
FreePool (ConfigRequest);
|
||||
ConfigRequest = NULL;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
*Results = FormResult;
|
||||
|
||||
Failure:
|
||||
//
|
||||
// Set Progress string to the original request string.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue