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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 28, 2025 at 11:13 AM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>
> 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
>   ...
>
> Signed-off-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
> ---
>  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..7d13b9234d2c 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(errno));

errno is fragile, -err would be more robust, IMO

>                 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(errno));
>                 return -EINVAL;
>         }
>
> --
> 2.48.1
>





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux