Re: [PATCH v2 3/3] selftests/mm: fix ternary operator precedence in ksm_tests
From: "David Hildenbrand (Arm)" <david@kernel.org>
Date: 2026-06-30 10:33:59
Also in:
linux-kselftest, linux-mm, lkml
From: "David Hildenbrand (Arm)" <david@kernel.org>
Date: 2026-06-30 10:33:59
Also in:
linux-kselftest, linux-mm, lkml
On 6/30/26 11:32, Sayali Patil wrote:
The KSM selftest uses conditional expressions to skip accesses to
merge_across_nodes on systems without NUMA support. However, the
ternary operator is combined with logical OR without parentheses:
a || numa_available() ? 0 : b || c
Due to operator precedence rules, this is parsed as:
(a || numa_available()) ? 0 : (b || c)
instead of the intended:
a || (numa_available() ? 0 : b) || c
Add parentheses around the conditional expressions to ensure the
correct evaluation order.
Fixes: 9aa1af954db0 ("selftests: vm: check numa_available() before operating "merge_across_nodes" in ksm_tests")
Signed-off-by: Sayali Patil <redacted>
---LGTM, although the code is a bit ugly (already before your changes). Acked-by: David Hildenbrand (Arm) <david@kernel.org> -- Cheers, David