selftests/bpf: fix incorrect users of create_and_get_cgroup
We have some tests that assume create_and_get_cgroup returns -1 on error which is incorrect (it returns 0 on error). Since fd might be zero in general case, change create_and_get_cgroup to return -1 on error and fix the users that assume 0 on error. Fixes:f269099a7e
("tools/bpf: add a selftest for bpf_get_current_cgroup_id() helper") Fixes:7d2c6cfc54
("bpf: use --cgroup in test_suite if supplied") v2: - instead of fixing the uses that assume -1 on error, convert the users that assume 0 on error (fd might be zero in general case) Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:

committed by
Alexei Starovoitov

parent
97274b6126
commit
a8911d6d58
@@ -458,7 +458,7 @@ int main(int argc, char **argv)
|
||||
goto err;
|
||||
|
||||
cgfd = create_and_get_cgroup(CG_PATH);
|
||||
if (!cgfd)
|
||||
if (cgfd < 0)
|
||||
goto err;
|
||||
|
||||
if (join_cgroup(CG_PATH))
|
||||
|
Reference in New Issue
Block a user