From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: kkourt@kkourt.io
Cc: dwarves@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org,
Kornilios Kourtis <kornilios@isovalent.com>
Subject: Re: [PATCH 2/2] dwarves: cus__load_files: set errno if load fails
Date: Wed, 16 Mar 2022 17:51:03 -0300 [thread overview]
Message-ID: <YjJNt0GpA5fAm8PQ@kernel.org> (raw)
In-Reply-To: <20220316132354.3226908-1-kkourt@kkourt.io>
Em Wed, Mar 16, 2022 at 02:23:54PM +0100, kkourt@kkourt.io escreveu:
> From: Kornilios Kourtis <kornilios@isovalent.com>
>
> This patch improves the error seen by the user by setting errno in
> cus__load_files(). Otherwise, we get a "No such file or directory" error
> which might be confusing.
>
> Before the patch, using a bogus file:
> $ ./pahole -J ./vmlinux-5.3.18-24.102-default.debug
> pahole: ./vmlinux-5.3.18-24.102-default.debug: No such file or directory
> $ ls ./vmlinux-5.3.18-24.102-default.debug
> /home/kkourt/src/hubble-fgs/vmlinux-5.3.18-24.102-default.debug
>
> After the patch:
> $ ./pahole -J ./vmlinux-5.3.18-24.102-default.debug
> pahole: ./vmlinux-5.3.18-24.102-default.debug: Unknown error -22
>
> Which is not very helpful, but less confusing.
Humm, because you should've set errno to -err back in cus__load_files(),
with this on top of your two patches we should get the:
#define EINVAL 22 /* Invalid argument */
"Invalid argument" or so from getting.
diff --git a/dwarves.c b/dwarves.c
index 5d0b420f0110452e..89609e96c46747ce 100644
--- a/dwarves.c
+++ b/dwarves.c
@@ -2401,7 +2401,7 @@ int cus__load_files(struct cus *cus, struct conf_load *conf,
while (filenames[i] != NULL) {
int err = cus__load_file(cus, conf, filenames[i]);
if (err) {
- errno = err;
+ errno = -err;
return -++i;
}
++i;
Agreed? I'll fix it up here and apply if so.
- Arnaldo
> Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
> ---
> dwarves.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/dwarves.c b/dwarves.c
> index 89b58ef..5d0b420 100644
> --- a/dwarves.c
> +++ b/dwarves.c
> @@ -2399,8 +2399,11 @@ int cus__load_files(struct cus *cus, struct conf_load *conf,
> int i = 0;
>
> while (filenames[i] != NULL) {
> - if (cus__load_file(cus, conf, filenames[i]))
> + int err = cus__load_file(cus, conf, filenames[i]);
> + if (err) {
> + errno = err;
> return -++i;
> + }
> ++i;
> }
>
> --
> 2.25.1
--
- Arnaldo
next prev parent reply other threads:[~2022-03-16 20:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 11:38 [PATCH] pahole: avoid segfault when parsing a problematic file kkourt
2022-03-05 18:49 ` Arnaldo Carvalho de Melo
2022-03-16 13:16 ` Kornilios Kourtis
2022-03-16 13:23 ` [PATCH 1/2] pahole: avoid segfault when parsing bogus file kkourt
2022-03-17 4:59 ` John Fastabend
2022-03-16 13:23 ` [PATCH 2/2] dwarves: cus__load_files: set errno if load fails kkourt
2022-03-16 20:51 ` Arnaldo Carvalho de Melo [this message]
2022-03-16 20:55 ` Kornilios Kourtis
2022-03-17 5:00 ` John Fastabend
2022-03-17 15:19 ` Arnaldo Carvalho de Melo
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=YjJNt0GpA5fAm8PQ@kernel.org \
--to=acme@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=kkourt@kkourt.io \
--cc=kornilios@isovalent.com \
--cc=linux-kernel@vger.kernel.org \
/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).