diff options
author | Kornilios Kourtis <kornilios@isovalent.com> | 2022-03-16 14:23:54 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-03-17 12:20:38 -0300 |
commit | 31df013b70540072521943fad624e63a247228dd (patch) | |
tree | 04d61391e44df45c94b75fc02992b1789bfc708f | |
parent | f952a6f69f9508c8168e4b0b2aa5993a3256b07e (diff) | |
download | pahole-31df013b70540072521943fad624e63a247228dd.tar.gz |
dwarves: Set errno if load fails in cus__load_files()
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.
Committer notes:
We need to turn the returned negative error to positive when setting it
to 'errno', that way the error message will be:
$ ./pahole -J ./vmlinux-5.3.18-24.102-default.debug
pahole: ./vmlinux-5.3.18-24.102-default.debug: Invalid argument
$
Because:
$ grep -w 22 /usr/include/*/errno*
/usr/include/asm-generic/errno-base.h:#define EINVAL 22 /* Invalid argument */
$
Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Link: http://lore.kernel.org/lkml/20220316132354.3226908-1-kkourt@kkourt.io
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | dwarves.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; } |