[PATCH bpf-next v2 2/3] veristat: strerror expects positive number (errno)

Eduard Zingerman
2025-03-01T00:02:16Z

Before:

./veristat -G @foobar iters.bpf.o
Failed to open presets in 'foobar': Unknown error -2
...

After:

./veristat -G @foobar iters.bpf.o
Failed to open presets in 'foobar': No such file or directory
...

Acked-by: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
---
tools/testing/selftests/bpf/veristat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c
index 8bc462299290..41dfcb6f5690 100644
--- a/tools/testing/selftests/bpf/veristat.c
+++ b/tools/testing/selftests/bpf/veristat.c
@@ -660,7 +660,7 @@ static int append_filter_file(const char *path)
f = fopen(path, "r");
if (!f) {
err = -errno;
- fprintf(stderr, "Failed to open filters in '%s': %s\n", path, strerror(err));
+ fprintf(stderr, "Failed to open filters in '%s': %s\n", path, strerror(-err));
return err;
}

@@ -1422,7 +1422,7 @@ static int append_var_preset_file(const char *filename)
f = fopen(filename, "rt");
if (!f) {
err = -errno;
- fprintf(stderr, "Failed to open presets in '%s': %s\n", filename, strerror(err));
+ fprintf(stderr, "Failed to open presets in '%s': %s\n", filename, strerror(-err));
return -EINVAL;
}

--
2.48.1