Rewrite directory traversal allocation path so coverity can grok it.

The things we do for our tools.  In this case, make the AllocatePool()
happen outside of a conditional, even though that conditional will
always bee satisfied.  This way coverity won't think we're setting fi
to NULL and passing it to StrCaseCmp.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2013-11-15 09:38:41 -05:00
parent 4dbef508ab
commit 3a7feeff6c

View File

@ -445,12 +445,19 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
return EFI_SUCCESS; return EFI_SUCCESS;
} }
FreePool(buffer); FreePool(buffer);
buffer = NULL;
bs = 0; bs = 0;
do { do {
bs = 0; bs = 0;
rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, NULL); rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, NULL);
if (rc == EFI_BUFFER_TOO_SMALL) { if (EFI_ERROR(rc) && rc != EFI_BUFFER_TOO_SMALL) {
Print(L"Could not read \\EFI\\%s\\: %d\n", dirname, rc);
if (buffer)
FreePool(buffer);
return rc;
}
buffer = AllocateZeroPool(bs); buffer = AllocateZeroPool(bs);
if (!buffer) { if (!buffer) {
Print(L"Could not allocate memory\n"); Print(L"Could not allocate memory\n");
@ -458,12 +465,12 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
} }
rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, buffer); rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, buffer);
}
if (EFI_ERROR(rc)) { if (EFI_ERROR(rc)) {
Print(L"Could not read \\EFI\\%s\\: %d\n", dirname, rc); Print(L"Could not read \\EFI\\%s\\: %d\n", dirname, rc);
FreePool(buffer); FreePool(buffer);
return rc; return rc;
} }
if (bs == 0) if (bs == 0)
break; break;