All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] selftest/net/xfrm: Add test for ipsec tunnel
@ 2022-07-19 13:44 Dan Carpenter
  2022-07-19 19:42 ` Dmitry Safonov
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-07-19 13:44 UTC (permalink / raw)
  To: 0x7f454c46; +Cc: linux-kselftest

Hello Dmitry Safonov,

The patch bc2652b7ae1e: "selftest/net/xfrm: Add test for ipsec
tunnel" from Sep 21, 2020, leads to the following Smatch static
checker warning:

	tools/testing/selftests/net/ipsec.c:2294 main()
	warn: impossible condition '(nr_process == 9223372036854775807) => (0-4294967295 == s64max)'

tools/testing/selftests/net/ipsec.c
    2278 int main(int argc, char **argv)
    2279 {
    2280         unsigned int nr_process = 1;
    2281         int route_sock = -1, ret = KSFT_SKIP;
    2282         int test_desc_fd[2];
    2283         uint32_t route_seq;
    2284         unsigned int i;
    2285 
    2286         if (argc > 2)
    2287                 exit_usage(argv);
    2288 
    2289         if (argc > 1) {
    2290                 char *endptr;
    2291 
    2292                 errno = 0;
    2293                 nr_process = strtol(argv[1], &endptr, 10);
--> 2294                 if ((errno == ERANGE && (nr_process == LONG_MAX || nr_process == LONG_MIN))

nr_process is a u32 so it can't be LONG_MIN/MAX.  Do we even need to test
this or could we just fall through to the the > MAX_PROCESSES warning?

    2295                                 || (errno != 0 && nr_process == 0)
    2296                                 || (endptr == argv[1]) || (*endptr != '\0')) {
    2297                         printk("Failed to parse [nr_process]");
    2298                         exit_usage(argv);
    2299                 }
    2300 
    2301                 if (nr_process > MAX_PROCESSES || !nr_process) {
    2302                         printk("nr_process should be between [1; %u]",
    2303                                         MAX_PROCESSES);
    2304                         exit_usage(argv);
    2305                 }
    2306         }
    2307 

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-19 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-19 13:44 [bug report] selftest/net/xfrm: Add test for ipsec tunnel Dan Carpenter
2022-07-19 19:42 ` Dmitry Safonov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.