[PATCH] FIT: improve error message when uncompressing non-compressed files

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Oct 9 06:05:46 PDT 2024


If due to user error, an uncompressed kernel is added into a FIT image,
but compression = "gzip" is specified, a quite cryptic message results:

  ERROR: FIT: cannot handle filetype ARM aarch64 Linux image
  ERROR: FIT: data couldn't be decompressed
  ERROR: Loading dtb image failed with: Function not implemented

Adapt the error messages a bit, so it says instead:

  ERROR: FIT: unsupported compression filetype "aarch64 Linux image"
  ERROR: FIT: gzip data couldn't be decompressed
  ERROR: Loading FIT image failed with: Function not implemented

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/bootm.c     | 10 ++++++++--
 common/image-fit.c |  2 +-
 lib/uncompress.c   |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 2de68a0b5e1a..b6ab358426f6 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -761,8 +761,14 @@ int bootm_boot(struct bootm_data *bootm_data)
 	}
 
 	if (ret) {
-		pr_err("Loading %s image failed with: %pe\n",
-		       file_type_to_short_string(os_type), ERR_PTR(ret));
+		const char *os_type_str;
+
+		if (os_type == filetype_oftree)
+			os_type_str = "FIT";
+		else
+			os_type_str = file_type_to_short_string(os_type);
+
+		pr_err("Loading %s image failed with: %pe\n", os_type_str, ERR_PTR(ret));
 		goto err_out;
 	}
 
diff --git a/common/image-fit.c b/common/image-fit.c
index c5d2196bda34..9e3dbe9ae054 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -598,7 +598,7 @@ static int fit_handle_decompression(struct device_node *image,
 	ret = uncompress_buf_to_buf(*data, *data_len, &uc_data,
 				    fit_uncompress_error_fn);
 	if (ret < 0) {
-		pr_err("data couldn't be decompressed\n");
+		pr_err("%s data couldn't be decompressed\n", compression);
 		return ret;
 	}
 
diff --git a/lib/uncompress.c b/lib/uncompress.c
index 11f55c8f9fd1..0aaeb066b674 100644
--- a/lib/uncompress.c
+++ b/lib/uncompress.c
@@ -131,7 +131,7 @@ int uncompress(unsigned char *inbuf, long len,
 		break;
 #endif
 	default:
-		err = basprintf("cannot handle filetype %s",
+		err = basprintf("unsupported compression filetype \"%s\"",
 				  file_type_to_string(ft));
 		error_fn(err);
 		free(err);
-- 
2.39.5




More information about the barebox mailing list