linux/tools/testing/selftests/net
David Ahern 87caaaf2d1 selftests: Fix get_ifidx and callers in nettest.c
Dan reported:

    The patch acda655fef: "selftests: Add nettest" from Aug 1, 2019,
    leads to the following static checker warning:

            ./tools/testing/selftests/net/nettest.c:1690 main()
            warn: unsigned 'tmp' is never less than zero.

    ./tools/testing/selftests/net/nettest.c
      1680                  case '1':
      1681                          args.has_expected_raddr = 1;
      1682                          if (convert_addr(&args, optarg,
      1683                                           ADDR_TYPE_EXPECTED_REMOTE))
      1684                                  return 1;
      1685
      1686                          break;
      1687                  case '2':
      1688                          if (str_to_uint(optarg, 0, 0x7ffffff, &tmp) != 0) {
      1689                                  tmp = get_ifidx(optarg);
      1690                                  if (tmp < 0) {

    "tmp" is unsigned so it can't be negative.  Also all the callers assume
    that get_ifidx() returns negatives on error but it looks like it really
    returns zero on error so it's a bit unclear to me.

Update get_ifidx to return -1 on errors and cleanup callers of it.

Fixes: acda655fef ("selftests: Add nettest")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-16 15:25:34 -07:00
..
forwarding selftests: net: push jq workaround into separate helper 2019-08-15 12:01:21 -07:00
.gitignore selftests/net: add missing gitignores (ipv6_flowlabel) 2019-07-25 17:13:21 -07:00
config Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-07-08 19:48:57 -07:00
fcnal-test.sh selftests: Fix detection of nettest command in fcnal-test 2019-08-09 19:54:14 -07:00
fib_nexthop_multiprefix.sh selftests: Add test with multiple prefixes using single nexthop 2019-06-10 10:44:57 -07:00
fib_nexthops.sh selftests: Add test cases for nexthop objects 2019-06-02 13:06:14 -07:00
fib_rule_tests.sh selftests: fib_rule_tests: use pre-defined DEV_ADDR 2019-05-21 13:44:17 -07:00
fib_tests.sh selftests: add a test case for rp_filter 2019-07-17 15:23:39 -07:00
fib-onlink-tests.sh selftests: fib-onlink: Make quiet by default 2019-05-22 17:50:24 -07:00
icmp_redirect.sh selftests: icmp_redirect: Add support for routing via nexthop objects 2019-06-10 10:44:57 -07:00
in_netns.sh
ip6_gre_headroom.sh
ip_defrag.c selftests: net: ip_defrag: cover new IPv6 defrag behavior 2019-01-25 21:37:11 -08:00
ip_defrag.sh selftests: net: ip_defrag: cover new IPv6 defrag behavior 2019-01-25 21:37:11 -08:00
ipv6_flowlabel_mgr.c selftests/net: ipv6 flowlabel 2019-05-28 17:18:53 -07:00
ipv6_flowlabel.c selftests/net: ipv6 flowlabel 2019-05-28 17:18:53 -07:00
ipv6_flowlabel.sh selftests/net: ipv6 flowlabel 2019-05-28 17:18:53 -07:00
l2tp.sh selftests: Add l2tp tests 2019-08-08 18:08:09 -07:00
Makefile selftests: Add l2tp tests 2019-08-08 18:08:09 -07:00
msg_zerocopy.c
msg_zerocopy.sh
netdevice.sh
nettest.c selftests: Fix get_ifidx and callers in nettest.c 2019-08-16 15:25:34 -07:00
pmtu.sh selftests: pmtu: Make list_flush_ipv6_exception test more demanding 2019-06-24 10:18:49 -07:00
psock_fanout.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 222 2019-05-30 11:29:55 -07:00
psock_lib.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 222 2019-05-30 11:29:55 -07:00
psock_snd.c
psock_snd.sh
psock_tpacket.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 222 2019-05-30 11:29:55 -07:00
reuseaddr_conflict.c
reuseport_addr_any.c selftests: net: reuseport_addr_any: silence clang warning 2018-12-20 19:26:52 -08:00
reuseport_addr_any.sh
reuseport_bpf_cpu.c
reuseport_bpf_numa.c
reuseport_bpf.c
reuseport_dualstack.c
route_localnet.sh selftests: add route_localnet test script 2019-06-24 09:02:47 -07:00
rtnetlink.sh selftests: rtnetlink: skip ipsec offload tests if netdevsim isn't present 2019-06-29 12:18:52 -07:00
run_afpackettests selftests/net: skip psock_tpacket test if KALLSYMS was not enabled 2019-07-02 20:17:49 -04:00
run_netsocktests selftests/net: correct the return value for run_netsocktests 2019-04-19 14:39:51 -07:00
so_txtime.c selftests/net: SO_TXTIME with ETF and FQ 2019-05-24 13:34:40 -07:00
so_txtime.sh selftests/net: SO_TXTIME with ETF and FQ 2019-05-24 13:34:40 -07:00
socket.c
tcp_fastopen_backup_key.c selftests/net: fix warnings in TFO key rotation selftest 2019-06-16 14:27:14 -07:00
tcp_fastopen_backup_key.sh selftests/net: add TFO key rotation selftest 2019-05-30 13:41:26 -07:00
tcp_inq.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 253 2019-06-05 17:30:27 +02:00
tcp_mmap.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 222 2019-05-30 11:29:55 -07:00
test_blackhole_dev.sh blackhole_dev: add a selftest 2019-07-01 19:34:46 -07:00
test_bpf.sh
test_vxlan_fdb_changelink.sh
test_vxlan_under_vrf.sh
tls.c selftests/tls: add a litmus test for the socket reuse through shutdown 2019-08-05 13:15:30 -07:00
txring_overwrite.c selftests: txring_overwrite: fix incorrect test of mmap() return value 2019-07-08 15:39:38 -07:00
udpgro_bench.sh
udpgro.sh selftests: fixes for UDP GRO 2019-03-01 11:24:00 -08:00
udpgso_bench_rx.c selftests: fixes for UDP GRO 2019-03-01 11:24:00 -08:00
udpgso_bench_tx.c selftests/net: make udpgso_bench skip unsupported testcases 2019-06-19 17:33:47 -04:00
udpgso_bench.sh selftests/net: make udpgso_bench skip unsupported testcases 2019-06-19 17:33:47 -04:00
udpgso.c selftest/net: Remove duplicate header 2019-03-04 11:35:51 -08:00
udpgso.sh
xfrm_policy.sh xfrm: policy: fix bydst hlist corruption on hash rebuild 2019-07-03 10:50:35 +02:00