fallback: find_boot_csv(): Print the error from try_boot_csv()

Covscan believes the following:

 782        if ((EFI_ERROR(rc) || !bootarchcsv) && bootcsv) {
 783                EFI_FILE_HANDLE fh2;
 784                rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
 785                                       bootcsv, EFI_FILE_READ_ONLY, 0);
 786                if (EFI_ERROR(rc) || fh2 == NULL) {
 787                        Print(L"Couldn't open \\EFI\\%s\\%s: %d\n",
 788                              dirname, bootcsv, rc);
 789                } else {
    CID 182829 (#1 of 1): Unused value (UNUSED_VALUE)returned_value:
    Assigning value from try_boot_csv(fh2, dirname, bootcsv) to rc here,
    but that stored value is overwritten before it can be used.
 790                        rc = try_boot_csv(fh2, dirname, bootcsv);
 791                        uefi_call_wrapper(fh2->Close, 1, fh2);
 792                }
 793        }
    value_overwrite: Overwriting previous write to rc with value 0UL.
 794        rc = EFI_SUCCESS;
 795
 796        return rc;
 797}

Which isn't untrue, we just don't happen to be using the return code for
anything, before we intentionally return success to our caller.

So that's annoying, but whatever.  Just print the error as well.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2017-09-27 13:25:31 -04:00 committed by Peter Jones
parent 809dc7a18b
commit ea1d6905ba

View File

@ -707,8 +707,8 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
rc = uefi_call_wrapper(fh->GetInfo, 4, fh, &EFI_FILE_INFO_GUID, &bs, buffer); rc = uefi_call_wrapper(fh->GetInfo, 4, fh, &EFI_FILE_INFO_GUID, &bs, buffer);
/* This checks *either* the error from the first GetInfo, if it isn't /* This checks *either* the error from the first GetInfo, if it isn't
* the EFI_BUFFER_TOO_SMALL we're expecting, or the second GetInfo call * the EFI_BUFFER_TOO_SMALL we're expecting, or the second GetInfo
* in *any* case. */ * call in *any* case. */
if (EFI_ERROR(rc)) { if (EFI_ERROR(rc)) {
Print(L"Could not get info for \"%s\": %d\n", dirname, rc); Print(L"Could not get info for \"%s\": %d\n", dirname, rc);
if (buffer) if (buffer)
@ -731,7 +731,8 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
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 (EFI_ERROR(rc) && 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); Print(L"Could not read \\EFI\\%s\\: %d\n", dirname,
rc);
if (buffer) if (buffer)
FreePool(buffer); FreePool(buffer);
return rc; return rc;
@ -749,7 +750,8 @@ 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;
} }
@ -776,11 +778,14 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2, rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
bootarchcsv, EFI_FILE_READ_ONLY, 0); bootarchcsv, EFI_FILE_READ_ONLY, 0);
if (EFI_ERROR(rc) || fh2 == NULL) { if (EFI_ERROR(rc) || fh2 == NULL) {
Print(L"Couldn't open \\EFI\\%s\\%s: %d\n", Print(L"Couldn't open \\EFI\\%s\\%s: %r\n",
dirname, bootarchcsv, rc); dirname, bootarchcsv, rc);
} else { } else {
rc = try_boot_csv(fh2, dirname, bootarchcsv); rc = try_boot_csv(fh2, dirname, bootarchcsv);
uefi_call_wrapper(fh2->Close, 1, fh2); uefi_call_wrapper(fh2->Close, 1, fh2);
if (EFI_ERROR(rc))
Print(L"Could not process \\EFI\\%s\\%s: %r\n",
dirname, bootarchcsv, rc);
} }
} }
if ((EFI_ERROR(rc) || !bootarchcsv) && bootcsv) { if ((EFI_ERROR(rc) || !bootarchcsv) && bootcsv) {
@ -788,11 +793,14 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2, rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
bootcsv, EFI_FILE_READ_ONLY, 0); bootcsv, EFI_FILE_READ_ONLY, 0);
if (EFI_ERROR(rc) || fh2 == NULL) { if (EFI_ERROR(rc) || fh2 == NULL) {
Print(L"Couldn't open \\EFI\\%s\\%s: %d\n", Print(L"Couldn't open \\EFI\\%s\\%s: %r\n",
dirname, bootcsv, rc); dirname, bootcsv, rc);
} else { } else {
rc = try_boot_csv(fh2, dirname, bootcsv); rc = try_boot_csv(fh2, dirname, bootcsv);
uefi_call_wrapper(fh2->Close, 1, fh2); uefi_call_wrapper(fh2->Close, 1, fh2);
if (EFI_ERROR(rc))
Print(L"Could not process \\EFI\\%s\\%s: %r\n",
dirname, bootarchcsv, rc);
} }
} }
rc = EFI_SUCCESS; rc = EFI_SUCCESS;