Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/net: ipsec: fix constant out of range

Fix a small compiler warning.

nr_process must be a signed long: it is assigned a signed long by
strtol() and is compared against LONG_MIN and LONG_MAX.

ipsec.c:2280:65:
error: result of comparison of constant -9223372036854775808
with expression of type 'unsigned int' is always false
[-Werror,-Wtautological-constant-out-of-range-compare]

if ((errno == ERANGE && (nr_process == LONG_MAX || nr_process == LONG_MIN))

Fixes: bc2652b7ae1e ("selftest/net/xfrm: Add test for ipsec tunnel")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Link: https://lore.kernel.org/r/20231124171645.1011043-2-willemdebruijn.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Willem de Bruijn and committed by
Jakub Kicinski
08855981 ccf49ceb

+2 -2
+2 -2
tools/testing/selftests/net/ipsec.c
··· 2263 2263 2264 2264 int main(int argc, char **argv) 2265 2265 { 2266 - unsigned int nr_process = 1; 2266 + long nr_process = 1; 2267 2267 int route_sock = -1, ret = KSFT_SKIP; 2268 2268 int test_desc_fd[2]; 2269 2269 uint32_t route_seq; ··· 2284 2284 exit_usage(argv); 2285 2285 } 2286 2286 2287 - if (nr_process > MAX_PROCESSES || !nr_process) { 2287 + if (nr_process > MAX_PROCESSES || nr_process < 1) { 2288 2288 printk("nr_process should be between [1; %u]", 2289 2289 MAX_PROCESSES); 2290 2290 exit_usage(argv);