[PATCH 5/8] kselftest/arm64: mte: fix printf type warning about mask

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <andre.przywara@xxxxxxx>
---
 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





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux