* [PATCH bpf] selftests/bpf: fix incorrect users of create_and_get_cgroup
@ 2019-01-03 18:57 Stanislav Fomichev
2019-01-04 6:44 ` Y Song
2019-01-05 4:34 ` Alexei Starovoitov
0 siblings, 2 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2019-01-03 18:57 UTC (permalink / raw)
To: netdev; +Cc: davem, ast, daniel, Stanislav Fomichev
create_and_get_cgroup returns 0 on error, fix the users that assume
negative value in case of an error.
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
tools/testing/selftests/bpf/get_cgroup_id_user.c | 2 +-
tools/testing/selftests/bpf/test_sockmap.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/get_cgroup_id_user.c b/tools/testing/selftests/bpf/get_cgroup_id_user.c
index e8da7b39158d..dfaa9b353ac3 100644
--- a/tools/testing/selftests/bpf/get_cgroup_id_user.c
+++ b/tools/testing/selftests/bpf/get_cgroup_id_user.c
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
return 1;
cgroup_fd = create_and_get_cgroup(TEST_CGROUP);
- if (CHECK(cgroup_fd < 0, "create_and_get_cgroup", "err %d errno %d\n",
+ if (CHECK(!cgroup_fd, "create_and_get_cgroup", "err %d errno %d\n",
cgroup_fd, errno))
goto cleanup_cgroup_env;
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index e85a771f607b..2384896e8112 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -1676,7 +1676,7 @@ static int __test_suite(int cg_fd, char *bpf_file)
}
cg_fd = create_and_get_cgroup(CG_PATH);
- if (cg_fd < 0) {
+ if (!cg_fd) {
fprintf(stderr,
"ERROR: (%i) open cg path failed: %s\n",
cg_fd, optarg);
--
2.20.1.415.g653613c723-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] selftests/bpf: fix incorrect users of create_and_get_cgroup
2019-01-03 18:57 [PATCH bpf] selftests/bpf: fix incorrect users of create_and_get_cgroup Stanislav Fomichev
@ 2019-01-04 6:44 ` Y Song
2019-01-05 4:34 ` Alexei Starovoitov
1 sibling, 0 replies; 4+ messages in thread
From: Y Song @ 2019-01-04 6:44 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: netdev, David Miller, Alexei Starovoitov, Daniel Borkmann
On Thu, Jan 3, 2019 at 12:02 PM Stanislav Fomichev <sdf@google.com> wrote:
>
> create_and_get_cgroup returns 0 on error, fix the users that assume
> negative value in case of an error.
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
Thanks for the fix!
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> tools/testing/selftests/bpf/get_cgroup_id_user.c | 2 +-
> tools/testing/selftests/bpf/test_sockmap.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] selftests/bpf: fix incorrect users of create_and_get_cgroup
2019-01-03 18:57 [PATCH bpf] selftests/bpf: fix incorrect users of create_and_get_cgroup Stanislav Fomichev
2019-01-04 6:44 ` Y Song
@ 2019-01-05 4:34 ` Alexei Starovoitov
2019-01-07 16:49 ` Stanislav Fomichev
1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2019-01-05 4:34 UTC (permalink / raw)
To: Stanislav Fomichev; +Cc: netdev, davem, ast, daniel
On Thu, Jan 03, 2019 at 10:57:17AM -0800, Stanislav Fomichev wrote:
> create_and_get_cgroup returns 0 on error, fix the users that assume
> negative value in case of an error.
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
> ---
> tools/testing/selftests/bpf/get_cgroup_id_user.c | 2 +-
> tools/testing/selftests/bpf/test_sockmap.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/get_cgroup_id_user.c b/tools/testing/selftests/bpf/get_cgroup_id_user.c
> index e8da7b39158d..dfaa9b353ac3 100644
> --- a/tools/testing/selftests/bpf/get_cgroup_id_user.c
> +++ b/tools/testing/selftests/bpf/get_cgroup_id_user.c
> @@ -64,7 +64,7 @@ int main(int argc, char **argv)
> return 1;
>
> cgroup_fd = create_and_get_cgroup(TEST_CGROUP);
> - if (CHECK(cgroup_fd < 0, "create_and_get_cgroup", "err %d errno %d\n",
> + if (CHECK(!cgroup_fd, "create_and_get_cgroup", "err %d errno %d\n",
fd can be zero.
Hence I prefer to fix it the other way to avoid this corner case.
Pls fix create_and_get_cgroup() to return -1 in case of error.
The diff will be much bigger, but overall it's imo cleaner.
Also pls add Fixes tag.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] selftests/bpf: fix incorrect users of create_and_get_cgroup
2019-01-05 4:34 ` Alexei Starovoitov
@ 2019-01-07 16:49 ` Stanislav Fomichev
0 siblings, 0 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2019-01-07 16:49 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: Stanislav Fomichev, netdev, davem, ast, daniel
On 01/04, Alexei Starovoitov wrote:
> On Thu, Jan 03, 2019 at 10:57:17AM -0800, Stanislav Fomichev wrote:
> > create_and_get_cgroup returns 0 on error, fix the users that assume
> > negative value in case of an error.
> >
> > Signed-off-by: Stanislav Fomichev <sdf@google.com>
> > ---
> > tools/testing/selftests/bpf/get_cgroup_id_user.c | 2 +-
> > tools/testing/selftests/bpf/test_sockmap.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/get_cgroup_id_user.c b/tools/testing/selftests/bpf/get_cgroup_id_user.c
> > index e8da7b39158d..dfaa9b353ac3 100644
> > --- a/tools/testing/selftests/bpf/get_cgroup_id_user.c
> > +++ b/tools/testing/selftests/bpf/get_cgroup_id_user.c
> > @@ -64,7 +64,7 @@ int main(int argc, char **argv)
> > return 1;
> >
> > cgroup_fd = create_and_get_cgroup(TEST_CGROUP);
> > - if (CHECK(cgroup_fd < 0, "create_and_get_cgroup", "err %d errno %d\n",
> > + if (CHECK(!cgroup_fd, "create_and_get_cgroup", "err %d errno %d\n",
>
> fd can be zero.
Assumed it was fine for the test where we never close stdin.
> Hence I prefer to fix it the other way to avoid this corner case.
> Pls fix create_and_get_cgroup() to return -1 in case of error.
> The diff will be much bigger, but overall it's imo cleaner.
Agree, will sent a v2 shortly.
> Also pls add Fixes tag.
>
> Thanks
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-07 16:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-03 18:57 [PATCH bpf] selftests/bpf: fix incorrect users of create_and_get_cgroup Stanislav Fomichev
2019-01-04 6:44 ` Y Song
2019-01-05 4:34 ` Alexei Starovoitov
2019-01-07 16:49 ` Stanislav Fomichev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.