Re: [PATCH v2 3/3] selftests/mm: fix ternary operator precedence in ksm_tests
From: David Hildenbrand (Arm)
Date: Tue Jun 30 2026 - 06:40:11 EST
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 <sayalip@xxxxxxxxxxxxx>
> ---
LGTM, although the code is a bit ugly (already before your changes).
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
--
Cheers,
David