arrfab / rpms / shim

Forked from rpms/shim 4 years ago
Clone

Blame SOURCES/0009-shim-improve-error-messages.patch

4210fa
From 2f09d0ab290d9b0d8aa14c3243f1d85a20bc34e6 Mon Sep 17 00:00:00 2001
4210fa
From: Andrew Boie <andrew.p.boie@intel.com>
4210fa
Date: Mon, 11 Nov 2013 17:29:06 -0800
4210fa
Subject: [PATCH 09/74] shim: improve error messages
4210fa
4210fa
%r when used in Print() will show a string representation of
4210fa
an EFI_STATUS code.
4210fa
4210fa
Change-Id: I6db47f5213454603bd66177aca378ad01e9f0bd4
4210fa
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
4210fa
---
4210fa
 shim.c | 38 +++++++++++++++++++-------------------
4210fa
 1 file changed, 19 insertions(+), 19 deletions(-)
4210fa
4210fa
diff --git a/shim.c b/shim.c
4210fa
index a043779..9ae1936 100644
4210fa
--- a/shim.c
4210fa
+++ b/shim.c
4210fa
@@ -914,7 +914,7 @@ static EFI_STATUS handle_image (void *data, unsigned int datasize,
4210fa
 	 */
4210fa
 	efi_status = read_header(data, datasize, &context);
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Failed to read header\n");
4210fa
+		Print(L"Failed to read header: %r\n", efi_status);
4210fa
 		return efi_status;
4210fa
 	}
4210fa
 
4210fa
@@ -981,7 +981,7 @@ static EFI_STATUS handle_image (void *data, unsigned int datasize,
4210fa
 	efi_status = relocate_coff(&context, buffer);
4210fa
 
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Relocation failed\n");
4210fa
+		Print(L"Relocation failed: %r\n", efi_status);
4210fa
 		FreePool(buffer);
4210fa
 		return efi_status;
4210fa
 	}
4210fa
@@ -1022,7 +1022,7 @@ should_use_fallback(EFI_HANDLE image_handle)
4210fa
 	rc = uefi_call_wrapper(BS->HandleProtocol, 3, image_handle,
4210fa
 				       &loaded_image_protocol, (void **)&li;;
4210fa
 	if (EFI_ERROR(rc)) {
4210fa
-		Print(L"Could not get image for bootx64.efi: %d\n", rc);
4210fa
+		Print(L"Could not get image for bootx64.efi: %r\n", rc);
4210fa
 		return 0;
4210fa
 	}
4210fa
 
4210fa
@@ -1044,13 +1044,13 @@ should_use_fallback(EFI_HANDLE image_handle)
4210fa
 	rc = uefi_call_wrapper(BS->HandleProtocol, 3, li->DeviceHandle,
4210fa
 			       &FileSystemProtocol, (void **)&fio;;
4210fa
 	if (EFI_ERROR(rc)) {
4210fa
-		Print(L"Could not get fio for li->DeviceHandle: %d\n", rc);
4210fa
+		Print(L"Could not get fio for li->DeviceHandle: %r\n", rc);
4210fa
 		return 0;
4210fa
 	}
4210fa
 	
4210fa
 	rc = uefi_call_wrapper(fio->OpenVolume, 2, fio, &vh;;
4210fa
 	if (EFI_ERROR(rc)) {
4210fa
-		Print(L"Could not open fio volume: %d\n", rc);
4210fa
+		Print(L"Could not open fio volume: %r\n", rc);
4210fa
 		return 0;
4210fa
 	}
4210fa
 
4210fa
@@ -1172,14 +1172,14 @@ static EFI_STATUS load_image (EFI_LOADED_IMAGE *li, void **data,
4210fa
 				       (void **)&drive);
4210fa
 
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Failed to find fs\n");
4210fa
+		Print(L"Failed to find fs: %r\n", efi_status);
4210fa
 		goto error;
4210fa
 	}
4210fa
 
4210fa
 	efi_status = uefi_call_wrapper(drive->OpenVolume, 2, drive, &root);
4210fa
 
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Failed to open fs\n");
4210fa
+		Print(L"Failed to open fs: %r\n", efi_status);
4210fa
 		goto error;
4210fa
 	}
4210fa
 
4210fa
@@ -1190,7 +1190,7 @@ static EFI_STATUS load_image (EFI_LOADED_IMAGE *li, void **data,
4210fa
 				       EFI_FILE_MODE_READ, 0);
4210fa
 
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Failed to open %s - %lx\n", PathName, efi_status);
4210fa
+		Print(L"Failed to open %s - %r\n", PathName, efi_status);
4210fa
 		goto error;
4210fa
 	}
4210fa
 
4210fa
@@ -1223,7 +1223,7 @@ static EFI_STATUS load_image (EFI_LOADED_IMAGE *li, void **data,
4210fa
 	}
4210fa
 
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Unable to get file info\n");
4210fa
+		Print(L"Unable to get file info: %r\n", efi_status);
4210fa
 		goto error;
4210fa
 	}
4210fa
 
4210fa
@@ -1251,7 +1251,7 @@ static EFI_STATUS load_image (EFI_LOADED_IMAGE *li, void **data,
4210fa
 	}
4210fa
 
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Unexpected return from initial read: %x, buffersize %x\n", efi_status, buffersize);
4210fa
+		Print(L"Unexpected return from initial read: %r, buffersize %x\n", efi_status, buffersize);
4210fa
 		goto error;
4210fa
 	}
4210fa
 
4210fa
@@ -1328,20 +1328,20 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath)
4210fa
 	efi_status = generate_path(li, ImagePath, &path, &PathName);
4210fa
 
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Unable to generate path: %s\n", ImagePath);
4210fa
+		Print(L"Unable to generate path %s: %r\n", ImagePath, efi_status);
4210fa
 		goto done;
4210fa
 	}
4210fa
 
4210fa
 	if (findNetboot(image_handle)) {
4210fa
 		efi_status = parseNetbootinfo(image_handle);
4210fa
 		if (efi_status != EFI_SUCCESS) {
4210fa
-			Print(L"Netboot parsing failed: %d\n", efi_status);
4210fa
+			Print(L"Netboot parsing failed: %r\n", efi_status);
4210fa
 			return EFI_PROTOCOL_ERROR;
4210fa
 		}
4210fa
 		efi_status = FetchNetbootimage(image_handle, &sourcebuffer,
4210fa
 					       &sourcesize);
4210fa
 		if (efi_status != EFI_SUCCESS) {
4210fa
-			Print(L"Unable to fetch TFTP image\n");
4210fa
+			Print(L"Unable to fetch TFTP image: %r\n", efi_status);
4210fa
 			return efi_status;
4210fa
 		}
4210fa
 		data = sourcebuffer;
4210fa
@@ -1353,7 +1353,7 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath)
4210fa
 		efi_status = load_image(li, &data, &datasize, PathName);
4210fa
 
4210fa
 		if (efi_status != EFI_SUCCESS) {
4210fa
-			Print(L"Failed to load image\n");
4210fa
+			Print(L"Failed to load image %s: %r\n", PathName, efi_status);
4210fa
 			goto done;
4210fa
 		}
4210fa
 	}
4210fa
@@ -1370,7 +1370,7 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath)
4210fa
 	efi_status = handle_image(data, datasize, li);
4210fa
 
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Failed to load image\n");
4210fa
+		Print(L"Failed to load image: %r\n", efi_status);
4210fa
 		CopyMem(li, &li_bak, sizeof(li_bak));
4210fa
 		goto done;
4210fa
 	}
4210fa
@@ -1473,7 +1473,7 @@ EFI_STATUS mirror_mok_list()
4210fa
 				       | EFI_VARIABLE_RUNTIME_ACCESS,
4210fa
 				       FullDataSize, FullData);
4210fa
 	if (efi_status != EFI_SUCCESS) {
4210fa
-		Print(L"Failed to set MokListRT %d\n", efi_status);
4210fa
+		Print(L"Failed to set MokListRT: %r\n", efi_status);
4210fa
 	}
4210fa
 
4210fa
 	return efi_status;
4210fa
@@ -1514,7 +1514,7 @@ EFI_STATUS check_mok_request(EFI_HANDLE image_handle)
4210fa
 		efi_status = start_image(image_handle, MOK_MANAGER);
4210fa
 
4210fa
 		if (efi_status != EFI_SUCCESS) {
4210fa
-			Print(L"Failed to start MokManager\n");
4210fa
+			Print(L"Failed to start MokManager: %r\n", efi_status);
4210fa
 			return efi_status;
4210fa
 		}
4210fa
 	}
4210fa
@@ -1621,7 +1621,7 @@ static EFI_STATUS mok_ignore_db()
4210fa
 				| EFI_VARIABLE_RUNTIME_ACCESS,
4210fa
 				DataSize, (void *)&Data);
4210fa
 		if (efi_status != EFI_SUCCESS) {
4210fa
-			Print(L"Failed to set MokIgnoreDB %d\n", efi_status);
4210fa
+			Print(L"Failed to set MokIgnoreDB: %r\n", efi_status);
4210fa
 		}
4210fa
 	}
4210fa
 
4210fa
@@ -1648,7 +1648,7 @@ EFI_STATUS set_second_stage (EFI_HANDLE image_handle)
4210fa
 	status = uefi_call_wrapper(BS->HandleProtocol, 3, image_handle,
4210fa
 				   &LoadedImageProtocol, (void **) &li;;
4210fa
 	if (status != EFI_SUCCESS) {
4210fa
-		Print (L"Failed to get load options\n");
4210fa
+		Print (L"Failed to get load options: %r\n", status);
4210fa
 		return status;
4210fa
 	}
4210fa
 
4210fa
-- 
4210fa
1.9.3
4210fa