[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzYtr6Tki8viGt0KBAwH5FF0don+j3Td86m0Kg95kUEAhw@mail.gmail.com>
Date: Thu, 3 Sep 2020 11:50:46 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Hao Luo <haoluo@...gle.com>
Cc: Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>, Shuah Khan <shuah@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andriin@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
Toke Høiland-Jørgensen <toke@...hat.com>,
KP Singh <kpsingh@...omium.org>
Subject: Re: [PATCH] selftests/bpf: Fix check in global_data_init.
On Thu, Sep 3, 2020 at 11:02 AM Hao Luo <haoluo@...gle.com> wrote:
>
> The returned value of bpf_object__open_file() should be checked with
> IS_ERR() rather than NULL. This fix makes test_progs not crash when
> test_global_data.o is not present.
>
> Signed-off-by: Hao Luo <haoluo@...gle.com>
> ---
> tools/testing/selftests/bpf/prog_tests/global_data_init.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/global_data_init.c b/tools/testing/selftests/bpf/prog_tests/global_data_init.c
> index 3bdaa5a40744..1ece86d5c519 100644
> --- a/tools/testing/selftests/bpf/prog_tests/global_data_init.c
> +++ b/tools/testing/selftests/bpf/prog_tests/global_data_init.c
> @@ -12,7 +12,7 @@ void test_global_data_init(void)
> size_t sz;
>
> obj = bpf_object__open_file(file, NULL);
> - if (CHECK_FAIL(!obj))
> + if (CHECK_FAIL(IS_ERR(obj)))
Can you please use libbpf_get_error(obj) instead to set a good example
or not relying on kernel internal macros?
> return;
>
> map = bpf_object__find_map_by_name(obj, "test_glo.rodata");
> --
> 2.28.0.402.g5ffc5be6b7-goog
>
Powered by blists - more mailing lists