Re: [PATCH bpf-next v2 3/5] bpftool: fix error message when function can't register struct_ops

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

 



On Tue, Nov 8, 2022 at 11:45 PM Sahid Orentino Ferdjaoui
<sahid.ferdjaoui@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> It is expected that errno be passed to strerror().
>
> Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@xxxxxxxxxxxxxxxxxxxxxxxx>
> ---
>  tools/bpf/bpftool/struct_ops.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/bpf/bpftool/struct_ops.c b/tools/bpf/bpftool/struct_ops.c
> index 68281f9b7a0e..e0927dbb837b 100644
> --- a/tools/bpf/bpftool/struct_ops.c
> +++ b/tools/bpf/bpftool/struct_ops.c
> @@ -513,8 +513,7 @@ static int do_register(int argc, char **argv)
>                 link = bpf_map__attach_struct_ops(map);
>                 if (libbpf_get_error(link)) {
>                         p_err("can't register struct_ops %s: %s",
> -                             bpf_map__name(map),
> -                             strerror(-PTR_ERR(link)));
> +                             bpf_map__name(map), strerror(errno));

if you are relying on errno anyways, then just drop libbpf_get_error altogether:

if (!link) {
    p_err(...);
    ...
}

>                         nr_errs++;
>                         continue;
>                 }
> --
> 2.34.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