eal/unix: enhance error reporting for firmware

Message ID 20230922080606.905222-1-david.marchand@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: David Marchand
Headers
Series eal/unix: enhance error reporting for firmware |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

David Marchand Sept. 22, 2023, 8:06 a.m. UTC
  Put more details if a libarchive context initialisation fails.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/eal/unix/eal_firmware.c | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)
  

Comments

David Marchand Sept. 27, 2023, 9:19 a.m. UTC | #1
On Fri, Sep 22, 2023 at 10:06 AM David Marchand
<david.marchand@redhat.com> wrote:
>
> Put more details if a libarchive context initialisation fails.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>

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

Patch

diff --git a/lib/eal/unix/eal_firmware.c b/lib/eal/unix/eal_firmware.c
index d1616b0bd9..80aaadacf1 100644
--- a/lib/eal/unix/eal_firmware.c
+++ b/lib/eal/unix/eal_firmware.c
@@ -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