Skip to contentSkip to conversation

loader/efi/chainloader: Enhance error message of chainloader command

PATCH In review khaalid cali 2 participants 2 messages May 12, 2025 – May 16, 2025

lore
Share & tools
lore
#0 lore raw

v3 cover loader/efi/chainloader: Enhance error message of chainloader command

From: khaalid <[email protected]>

Well, i think the hex option is simpler in terms of code. Or maybe we need to have centralized function for all UEFI error messages, however this will complicate things a little bit as it requires modifications.

Just thought maybe we can extract high bit and treat like integer, thus align close as the way spec documented.

---
 grub-core/loader/efi/chainloader.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
grub-core/loader/efi/chainloader.c +2 -6
index 869307bf3..ecdce2393 100644
@@ -91,7 +91,7 @@ grub_chainloader_boot (void *context)
 	    }
 	}
       else
-	grub_error (GRUB_ERR_BAD_OS, "unknown error");
+	grub_error (GRUB_ERR_BAD_OS, "cannot start image 0x%lx", status);
     }
 
   if (exit_data)
@@ -344,11 +344,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
 			  &image_handle);
   if (status != GRUB_EFI_SUCCESS)
     {
-      if (status == GRUB_EFI_OUT_OF_RESOURCES)
-	grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources");
-      else
-	grub_error (GRUB_ERR_BAD_OS, "cannot load image");
-
+      grub_error (GRUB_ERR_BAD_OS, "cannot load image 0x%lx",status);
       goto fail;
     }
 
Signature · 7 lines
2.49.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw
Quoted 10 lines · khaalid cali

From: khaalid <[email protected]>

Well, i think the hex option is simpler in terms of code. Or maybe we need to have centralized function for all UEFI error messages, however this will complicate things a little bit as it requires modifications.

Just thought maybe we can extract high bit and treat like integer, thus align close as the way spec documented.

Missing space before "<".

Quoted 9 lines
---
 grub-core/loader/efi/chainloader.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
grub-core/loader/efi/chainloader.c +0 -0
index 869307bf3..ecdce2393 100644

grub-core/loader/efi/chainloader.c grub_chainloader_boot (void *context) · line 94

Quoted 5 lines
grub-core/loader/efi/chainloader.c +1 -1
@@ -91,7 +91,7 @@ grub_chainloader_boot (void *context)
 	    }
 	}
       else
-	grub_error (GRUB_ERR_BAD_OS, "unknown error");
+	grub_error (GRUB_ERR_BAD_OS, "cannot start image 0x%lx", status);

This is not portable. Please use relevant PRI* macros from include/grub/efi/api.h.

grub-core/loader/efi/chainloader.c grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), · line 347

Quoted 13 lines
grub-core/loader/efi/chainloader.c +1 -5
     }
 
   if (exit_data)
@@ -344,11 +344,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
 			  &image_handle);
   if (status != GRUB_EFI_SUCCESS)
     {
-      if (status == GRUB_EFI_OUT_OF_RESOURCES)
-	grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources");
-      else
-	grub_error (GRUB_ERR_BAD_OS, "cannot load image");
-
+      grub_error (GRUB_ERR_BAD_OS, "cannot load image 0x%lx",status);

Ditto. Same for other patches...

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel