When masking the return value of a prctl, which is clearly an "int", we
use a uapi header provided mask, which is defined using an "UL" modifier,
so the whole expression is promoted to a long. This upsets the compiler's
printf type checker, because we use "%x" in the format string.

While we could simply upgrade this to a "%lx", it sounds wrong to
promote the "ret" variable, that is clearly an int.
Downcast the mask instead, to keep the type correct.

Fixes: e2d9642a5a51 ("kselftest/arm64: Add simple test for MTE prctl")
Signed-off-by: Andre Przywara <[email protected]>
---
 tools/testing/selftests/arm64/mte/check_prctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/arm64/mte/check_prctl.c 
b/tools/testing/selftests/arm64/mte/check_prctl.c
index f139a33a43ef4..a16d7005affdf 100644
--- a/tools/testing/selftests/arm64/mte/check_prctl.c
+++ b/tools/testing/selftests/arm64/mte/check_prctl.c
@@ -81,11 +81,11 @@ void set_mode_test(const char *name, int hwcap2, int mask)
                return;
        }
 
-       if ((ret & PR_MTE_TCF_MASK) == mask) {
+       if ((ret & (int)PR_MTE_TCF_MASK) == mask) {
                ksft_test_result_pass("%s\n", name);
        } else {
                ksft_print_msg("Got %x, expected %x\n",
-                              (ret & PR_MTE_TCF_MASK), mask);
+                              (ret & (int)PR_MTE_TCF_MASK), mask);
                ksft_test_result_fail("%s\n", name);
        }
 }
-- 
2.25.1


Reply via email to