From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: syalavarthi@marvell.com, jerinjacobk@gmail.com
Subject: [PATCH] eal/unix: enhance error reporting for firmware
Date: Fri, 22 Sep 2023 10:06:06 +0200 [thread overview]
Message-ID: <20230922080606.905222-1-david.marchand@redhat.com> (raw)
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(-)
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
--
2.41.0
next reply other threads:[~2023-09-22 8:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 8:06 David Marchand [this message]
2023-09-27 9:19 ` David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230922080606.905222-1-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=jerinjacobk@gmail.com \
--cc=syalavarthi@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).