Skip to contentSkip to conversation

fs: error handling in do_load()

PATCH New Heinrich Schuchardt 3 participants 3 messages Jun 29, 2020 – Jul 17, 2020 VFS

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fs: error handling in do_load()

If a file cannot be loaded, show an error message. Set the EFI boot device only after successfully loading a file.

---
v2:
use if() instead of #ifdef

---
 fs/fs.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/fs.c +7 -5
index ad4caaeb1e..7268ec87aa 100644
@@ -715,15 +715,17 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
 	else
 		pos = 0;
 
-#ifdef CONFIG_CMD_BOOTEFI
-	efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
-			(argc > 4) ? argv[4] : "");
-#endif
 	time = get_timer(0);
 	ret = _fs_read(filename, addr, pos, bytes, 1, &len_read);
 	time = get_timer(time);
-	if (ret < 0)
+	if (ret < 0) {
+		printf("Failed to load '%s'\n", filename);
 		return 1;
+	}
+
+	if (IS_ENABLED(CONFIG_CMD_BOOTEFI))
+		efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
+				(argc > 4) ? argv[4] : "");
 
 	printf("%llu bytes read in %lu ms", len_read, time);
 	if (time > 0) {

--
2.27.0

#1 lore raw

PATCH v2 1/1 fs: error handling in do_load()

Quoted 4 lines · Heinrich Schuchardt

If a file cannot be loaded, show an error message. Set the EFI boot device only after successfully loading a file.

Quoted 8 lines

---
v2:
use if() instead of #ifdef

---
 fs/fs.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
#2 lore raw

PATCH v2 1/1 fs: error handling in do_load()

In reply to Heinrich Schuchardt
Quoted 5 lines · Heinrich Schuchardt

If a file cannot be loaded, show an error message. Set the EFI boot device only after successfully loading a file.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200717/f015acc5/attachment.sig>