Skip to contentSkip to conversation

eal/unix: enhance error reporting for firmware

PATCH In review David Marchand 1 participant 2 messages Sep 22, 2023 – Sep 27, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal/unix: enhance error reporting for firmware

Put more details if a libarchive context initialisation fails.

---
 lib/eal/unix/eal_firmware.c | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)
lib/eal/unix/eal_firmware.c +30 -7
index d1616b0bd9..80aaadacf1 100644
@@ -25,19 +25,42 @@ static int
 firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t blocksize)
 {
 	struct archive_entry *e;
+	int err;
 
 	ctx->a = archive_read_new();
 	if (ctx->a == NULL)
 		return -1;
-	if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK ||
-			archive_read_support_filter_xz(ctx->a) != ARCHIVE_OK ||
-			archive_read_open_filename(ctx->a, name, blocksize) != ARCHIVE_OK ||
-			archive_read_next_header(ctx->a, &e) != ARCHIVE_OK) {
-		archive_read_free(ctx->a);
-		ctx->a = NULL;
-		return -1;
+	err = archive_read_support_format_raw(ctx->a);
+	if (err != ARCHIVE_OK) {
+		RTE_LOG(ERR, EAL, "archive_read_support_format_raw() failed with %d: %s\n",
+			err, archive_error_string(ctx->a));
+		goto err;
+	}
+	err = archive_read_support_filter_xz(ctx->a);
+	if (err != ARCHIVE_OK) {
+		RTE_LOG(ERR, EAL, "archive_read_support_filter_xz() failed with %d: %s\n",
+			err, archive_error_string(ctx->a));
+		goto err;
+	}
+	err = archive_read_open_filename(ctx->a, name, blocksize);
+	if (err != ARCHIVE_OK) {
+		RTE_LOG(ERR, EAL, "archive_read_open_filename() failed with %d: %s\n",
+			err, archive_error_string(ctx->a));
+		goto err;
+	}
+	err = archive_read_next_header(ctx->a, &e);
+	if (err != ARCHIVE_OK) {
+		RTE_LOG(ERR, EAL, "archive_read_next_header() failed with %d: %s\n",
+			err, archive_error_string(ctx->a));
+		goto err;
 	}
+
 	return 0;
+
+err:
+	archive_read_free(ctx->a);
+	ctx->a = NULL;
+	return -1;
 }
 
 static ssize_t
Signature · 1 line
2.41.0
#1 lore raw
Quoted 4 lines · David Marchand

Put more details if a libarchive context initialisation fails.

Now that the original reported issue has been understood, I don't think we need this patch.
I'll discard it in patchwork.

Signature · 1 line
David Marchand