From ea1d6905ba9aede0a09740a809ad7a1b89a08e98 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 27 Sep 2017 13:25:31 -0400 Subject: [PATCH] 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 --- fallback.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fallback.c b/fallback.c index 9db9353..e7771db 100644 --- a/fallback.c +++ b/fallback.c @@ -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); /* 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 - * in *any* case. */ + * the EFI_BUFFER_TOO_SMALL we're expecting, or the second GetInfo + * call in *any* case. */ if (EFI_ERROR(rc)) { Print(L"Could not get info for \"%s\": %d\n", dirname, rc); if (buffer) @@ -731,7 +731,8 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname) bs = 0; rc = uefi_call_wrapper(fh->Read, 3, fh, &bs, NULL); 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) FreePool(buffer); 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); 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); return rc; } @@ -776,11 +778,14 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname) rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2, bootarchcsv, EFI_FILE_READ_ONLY, 0); 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); } else { rc = try_boot_csv(fh2, dirname, bootarchcsv); 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) { @@ -788,11 +793,14 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname) rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2, bootcsv, EFI_FILE_READ_ONLY, 0); 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); } else { rc = try_boot_csv(fh2, dirname, bootcsv); 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;