binfmt_flag_supported() returns 0 when the flag is supported and -1 when it is not, so every caller reads backwards: if (binfmt_flag_supported('T')) SKIP(return, "kernel without the 'T' flag"); Make it return a bool and flip the callers. errno from a failed probe is still set for callers that check it. Signed-off-by: Christian Brauner (Amutable) --- tools/testing/selftests/exec/binfmt_misc_bpf.c | 2 +- tools/testing/selftests/exec/binfmt_misc_common.h | 6 +++--- tools/testing/selftests/exec/binfmt_misc_transparent.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/exec/binfmt_misc_bpf.c b/tools/testing/selftests/exec/binfmt_misc_bpf.c index 069768a66ba0..c6f5e8f34985 100644 --- a/tools/testing/selftests/exec/binfmt_misc_bpf.c +++ b/tools/testing/selftests/exec/binfmt_misc_bpf.c @@ -258,7 +258,7 @@ TEST_F(bpf_handler, transparent_dispatch) char src[PATH_MAX], cmd[PATH_MAX + 16]; /* Probe for transparent-mode support via its static counterpart. */ - if (binfmt_flag_supported('T')) + if (!binfmt_flag_supported('T')) SKIP(return, "kernel without transparent mode"); ASSERT_EQ(artifact_path(src, sizeof(src), "binfmt_transparent_interp"), 0); diff --git a/tools/testing/selftests/exec/binfmt_misc_common.h b/tools/testing/selftests/exec/binfmt_misc_common.h index c6900ded019f..e8d67908dbc4 100644 --- a/tools/testing/selftests/exec/binfmt_misc_common.h +++ b/tools/testing/selftests/exec/binfmt_misc_common.h @@ -117,16 +117,16 @@ static inline int artifact_path(char *out, size_t sz, const char *name) } /* Probe kernel support for a registration flag with a throwaway entry. */ -static inline int binfmt_flag_supported(char flag) +static inline bool binfmt_flag_supported(char flag) { char rule[64]; snprintf(rule, sizeof(rule), ":bm_flag_probe:E::bmprobe::/bin/true:%c", flag); if (write_reg(rule)) - return -1; + return false; unregister("bm_flag_probe"); - return 0; + return true; } /* diff --git a/tools/testing/selftests/exec/binfmt_misc_transparent.c b/tools/testing/selftests/exec/binfmt_misc_transparent.c index d0cb845df1d3..2ebf73de8018 100644 --- a/tools/testing/selftests/exec/binfmt_misc_transparent.c +++ b/tools/testing/selftests/exec/binfmt_misc_transparent.c @@ -56,7 +56,7 @@ FIXTURE_SETUP(transparent) ASSERT_EQ(create_target(), 0); /* Skip the whole suite on a kernel that does not know 'T'. */ - if (binfmt_flag_supported('T')) { + if (!binfmt_flag_supported('T')) { ASSERT_EQ(errno, EINVAL); SKIP(return, "kernel without the 'T' flag"); } -- 2.53.0