From abddf07563b9f00b6e256abf52b191f7c57655af Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Thu, 29 Sep 2016 19:51:56 +0000 Subject: [PATCH] all: scrubbed some argc CHECK MEs Signed-off-by: Daniel Walton --- isisd/isis_redist.c | 12 ------------ isisd/isis_routemap.c | 5 ----- isisd/isis_te.c | 3 +-- isisd/isis_vty.c | 2 -- lib/distribute.c | 2 -- lib/if.c | 7 +++---- lib/routemap.c | 13 ++++--------- lib/thread.c | 2 -- lib/vty.c | 6 ++---- pimd/pim_cmd.c | 7 ++----- ripd/rip_interface.c | 1 - ripd/rip_routemap.c | 9 --------- ripngd/ripng_routemap.c | 6 ------ vtysh/vtysh.c | 4 ++-- 14 files changed, 14 insertions(+), 65 deletions(-) diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 038fba77e0..7cd3027f16 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -618,7 +618,6 @@ DEFUN (no_isis_redistribute, "Redistribute into level-1\n" "Redistribute into level-2\n") { - /* CHECK ME argc referenced below */ int idx_afi = 2; int idx_protocol = 3; int idx_level = 4; @@ -628,9 +627,6 @@ DEFUN (no_isis_redistribute, int family; int afi; - if (argc < 3) - return CMD_WARNING; - family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; @@ -669,7 +665,6 @@ DEFUN (isis_default_originate, "Route map reference\n" "Pointer to route-map entries\n") { - /* CHECK ME argc referenced below */ int idx_afi = 2; int idx_level = 3; int idx_metric_rmap = 4; @@ -680,9 +675,6 @@ DEFUN (isis_default_originate, unsigned long metric; const char *routemap; - if (argc < 5) - return CMD_WARNING; - family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; @@ -741,7 +733,6 @@ DEFUN (no_isis_default_originate, "Distribute default route into level-1\n" "Distribute default route into level-2\n") { - /* CHECK ME argc referenced below */ int idx_afi = 3; int idx_level = 4; struct isis_area *area = vty->index; @@ -749,9 +740,6 @@ DEFUN (no_isis_default_originate, int family; int level; - if (argc < 2) - return CMD_WARNING; - family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c index 6d130d08d9..a1f087548f 100644 --- a/isisd/isis_routemap.c +++ b/isisd/isis_routemap.c @@ -370,7 +370,6 @@ DEFUN (no_match_ip_address, "IP access-list number (expanded range)\n" "IP Access-list name\n") { - /* CHECK ME argc referenced below */ int idx_acl = 4; if (argc <= idx_acl) return isis_route_match_delete(vty, vty->index, "ip address", NULL); @@ -404,7 +403,6 @@ DEFUN (no_match_ip_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { - /* CHECK ME argc referenced below */ int idx_word = 5; if (argc <= idx_word) return isis_route_match_delete (vty, vty->index, "ip address prefix-list", NULL); @@ -436,7 +434,6 @@ DEFUN (no_match_ipv6_address, "Match IPv6 address of route\n" "IPv6 access-list name\n") { - /* CHECK ME argc referenced below */ int idx_word = 4; if (argc <= idx_word) return isis_route_match_delete(vty, vty->index, "ipv6 address", NULL); @@ -469,7 +466,6 @@ DEFUN (no_match_ipv6_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { - /* CHECK ME argc referenced below */ int idx_word = 5; if (argc <= idx_word) return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", NULL); @@ -501,7 +497,6 @@ DEFUN (no_set_metric, "Metric value for destination routing protocol\n" "Metric value\n") { - /* CHECK ME argc referenced below */ int idx_number = 3; if (argc <= idx_number) return isis_route_set_delete(vty, vty->index, "metric", NULL); diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 2a5122a9de..95abf22310 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -1318,13 +1318,12 @@ DEFUN (show_isis_mpls_te_interface, "Interface information\n" "Interface name\n") { - /* CHECK ME argc referenced below */ int idx_interface = 4; struct interface *ifp; struct listnode *node; /* Show All Interfaces. */ - if (argc == 0) + if (argc == 4) { for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) show_mpls_te_sub (vty, ifp); diff --git a/isisd/isis_vty.c b/isisd/isis_vty.c index 91a7e2bde8..a1970a9017 100644 --- a/isisd/isis_vty.c +++ b/isisd/isis_vty.c @@ -2067,7 +2067,6 @@ DEFUN (area_passwd_md5, "Send but do not check PDUs on receiving\n" "Send and check PDUs on receiving\n") { - /* CHECK ME argc referenced below */ int idx_password = 0; int idx_word = 2; int idx_type = 5; @@ -2098,7 +2097,6 @@ DEFUN (area_passwd_clear, "Send but do not check PDUs on receiving\n" "Send and check PDUs on receiving\n") { - /* CHECK ME argc referenced below */ int idx_password = 0; int idx_word = 2; int idx_type = 5; diff --git a/lib/distribute.c b/lib/distribute.c index e0b4f0468a..8a00833915 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -308,7 +308,6 @@ DEFUN (distribute_list, "Filter outgoing routing updates\n" "Interface name\n") { - /* CHECK ME argc referenced below */ int prefix = (argv[1]->type == WORD_TKN) ? 1 : 0; /* Check of distribute list type. */ @@ -340,7 +339,6 @@ DEFUN (no_distribute_list, "Filter outgoing routing updates\n" "Interface name\n") { - /* CHECK ME argc referenced below */ int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0; /* Check of distribute list type. */ diff --git a/lib/if.c b/lib/if.c index 7b55a327cb..382e69d61c 100644 --- a/lib/if.c +++ b/lib/if.c @@ -756,10 +756,10 @@ DEFUN (interface, "Interface's name\n" VRF_CMD_HELP_STR) { - /* CHECK ME argc referenced below */ int idx_ifname = 1; + int idx_vrf = 3; const char *ifname = argv[idx_ifname]->arg; - const char *vrfname = (argc > 2) ? argv[3]->arg : NULL; + const char *vrfname = (argc > 2) ? argv[idx_vrf]->arg : NULL; struct interface *ifp; size_t sl; @@ -901,8 +901,7 @@ DEFUN (show_address, "address\n" VRF_CMD_HELP_STR) { - /* CHECK ME argc referenced below */ - int idx_vrf_cmd_str = 2; + int idx_vrf = 3; struct listnode *node; struct listnode *node2; struct interface *ifp; diff --git a/lib/routemap.c b/lib/routemap.c index 2b4ec0c67a..b3d349d2f8 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1544,13 +1544,9 @@ DEFUN (rmap_onmatch_goto, "Goto Clause number\n" "Number\n") { - /* CHECK ME argc referenced below */ int idx_number = 2; char *num = NULL; - if (!strcmp (argv[0]->text, "continue")) - num = argv[1]->arg; - else - num = argv[idx_number]->arg; + num = argv[idx_number]->arg; struct route_map_index *index = vty->index; int d = 0; @@ -1565,7 +1561,7 @@ DEFUN (rmap_onmatch_goto, return CMD_WARNING; } - if (argc == 1 && num) + if (num) VTY_GET_INTEGER_RANGE("route-map index", d, num, 1, 65535); else d = index->pref + 1; @@ -1634,10 +1630,9 @@ DEFUN (rmap_show_name, "route-map information\n" "route-map name\n") { - /* CHECK ME argc referenced below */ int idx_word = 2; - const char *name = (argc == 3) ? argv[idx_word]->arg : NULL; - return vty_show_route_map (vty, name); + const char *name = (argc == 3) ? argv[idx_word]->arg : NULL; + return vty_show_route_map (vty, name); } DEFUN (rmap_call, diff --git a/lib/thread.c b/lib/thread.c index eb85d57af0..76acd07789 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -299,7 +299,6 @@ DEFUN (show_thread_cpu, "Thread CPU usage\n" "Display filter (rwtexb)\n") { - /* CHECK ME argc referenced below */ int idx_filter = 3; int i = 0; thread_type filter = (thread_type) -1U; @@ -383,7 +382,6 @@ DEFUN (clear_thread_cpu, "Thread CPU usage\n" "Display filter (rwtexb)\n") { - /* CHECK ME argc referenced below */ int idx_filter = 3; int i = 0; thread_type filter = (thread_type) -1U; diff --git a/lib/vty.c b/lib/vty.c index 7fcf4565a2..301af667e1 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2797,10 +2797,9 @@ DEFUN (no_vty_access_class, "Filter connections based on an IP access list\n" "IP access list\n") { - /* CHECK ME argc referenced below */ int idx_word = 2; const char *accesslist = (argc == 3) ? argv[idx_word]->arg : NULL; - if (! vty_accesslist_name || (argc && strcmp(vty_accesslist_name, accesslist))) + if (! vty_accesslist_name || (argc == 3 && strcmp(vty_accesslist_name, accesslist))) { vty_out (vty, "Access-class is not currently applied to vty%s", VTY_NEWLINE); @@ -2841,12 +2840,11 @@ DEFUN (no_vty_ipv6_access_class, "Filter connections based on an IP access list\n" "IPv6 access list\n") { - /* CHECK ME argc referenced below */ int idx_word = 3; const char *accesslist = (argc == 4) ? argv[idx_word]->arg : NULL; if (! vty_ipv6_accesslist_name || - (argc && strcmp(vty_ipv6_accesslist_name, accesslist))) + (argc == 4 && strcmp(vty_ipv6_accesslist_name, accesslist))) { vty_out (vty, "IPv6 access-class is not currently applied to vty%s", VTY_NEWLINE); diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index bf68e3a51e..5f2dcefdc8 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -2534,11 +2534,10 @@ DEFUN (ip_ssmpingd, CONF_SSMPINGD_STR "Source address\n") { - /* CHECK ME argc referenced below */ int idx_ipv4 = 2; int result; struct in_addr source_addr; - const char *source_str = (argc > 0) ? argv[idx_ipv4]->arg : "0.0.0.0"; + const char *source_str = (argc > idx_ipv4) ? argv[idx_ipv4]->arg : "0.0.0.0"; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { @@ -2565,11 +2564,10 @@ DEFUN (no_ip_ssmpingd, CONF_SSMPINGD_STR "Source address\n") { - /* CHECK ME argc referenced below */ int idx_ipv4 = 3; int result; struct in_addr source_addr; - const char *source_str = (argc > 0) ? argv[idx_ipv4]->arg : "0.0.0.0"; + const char *source_str = (argc > idx_ipv4) ? argv[idx_ipv4]->arg : "0.0.0.0"; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { @@ -3562,7 +3560,6 @@ DEFUN (interface_ip_pim_hello, IFACE_PIM_HELLO_TIME_STR IFACE_PIM_HELLO_HOLD_STR) { - /* CHECK ME argc referenced below */ int idx_time = 3; int idx_hold = 4; struct interface *ifp; diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 6b2fef7f50..d6686399c2 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -1528,7 +1528,6 @@ DEFUN (ip_rip_authentication_mode, "RFC compatible\n" "Old ripd compatible\n") { - /* CHECK ME argc referenced below */ char *cryptmode = argv[4]->text; char *authlen = (argc > 5) ? argv[6]->text : NULL; struct interface *ifp; diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index e43c398c49..e1017cfb27 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -754,7 +754,6 @@ DEFUN (no_match_metric, "Match metric of route\n" "Metric value\n") { - /* CHECK ME argc referenced below */ char *mval = (argc == 4) ? argv[3]->arg : NULL; return rip_route_match_delete (vty, vty->index, "metric", mval); } @@ -779,7 +778,6 @@ DEFUN (no_match_interface, "Match first hop interface of route\n" "Interface name\n") { - /* CHECK ME argc referenced below */ char *iface = (argc == 4) ? argv[3]->arg : NULL; return rip_route_match_delete (vty, vty->index, "interface", iface); } @@ -809,7 +807,6 @@ DEFUN (no_match_ip_next_hop, "IP access-list number (expanded range)\n" "IP Access-list name\n") { - /* CHECK ME argc referenced below */ char *al = (argc == 5) ? argv[4]->arg : NULL; return rip_route_match_delete (vty, vty->index, "ip next-hop", al); } @@ -837,7 +834,6 @@ DEFUN (no_match_ip_next_hop_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { - /* CHECK ME argc referenced below */ char *plist = (argc == 6) ? argv[5]->arg : NULL; return rip_route_match_delete (vty, vty->index, "ip next-hop prefix-list", plist); } @@ -869,7 +865,6 @@ DEFUN (no_match_ip_address, "IP access-list number (expanded range)\n" "IP Access-list name\n") { - /* CHECK ME argc referenced below */ char *al = (argc == 5) ? argv[4]->arg : NULL; return rip_route_match_delete (vty, vty->index, "ip address", al); } @@ -898,7 +893,6 @@ DEFUN (no_match_ip_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { - /* CHECK ME argc referenced below */ char *plist = (argc == 6) ? argv[5]->arg : NULL; return rip_route_match_delete (vty, vty->index, "ip address prefix-list", plist); } @@ -923,7 +917,6 @@ DEFUN (no_match_tag, "Match tag of route\n" "Metric value\n") { - /* CHECK ME argc referenced below */ char *mval = (argc == 4) ? argv[3]->arg : NULL; return rip_route_match_delete (vty, vty->index, "tag", mval); } @@ -996,7 +989,6 @@ DEFUN (no_set_ip_nexthop, "Next hop address\n" "IP address of next hop\n") { - /* CHECK ME argc referenced below */ char *addr = (argc == 5) ? argv[4]->arg : NULL; return rip_route_set_delete (vty, vty->index, "ip next-hop", addr); } @@ -1021,7 +1013,6 @@ DEFUN (no_set_tag, "Tag value for routing protocol\n" "Tag value\n") { - /* CHECK ME argc referenced below */ char *tag = (argc == 4) ? argv[3]->arg : NULL; return rip_route_set_delete (vty, vty->index, "tag", tag); } diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index 52aae9affc..6ecf084660 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -519,7 +519,6 @@ DEFUN (no_match_metric, "Match metric of route\n" "Metric value\n") { - /* CHECK ME argc referenced below */ char *mval = (argc == 4) ? argv[3]->arg : NULL; return ripng_route_match_delete (vty, vty->index, "metric", mval); } @@ -544,7 +543,6 @@ DEFUN (no_match_interface, "Match first hop interface of route\n" "Interface name\n") { - /* CHECK ME argc referenced below */ char *iface = (argc == 4) ? argv[3]->arg : NULL; return ripng_route_match_delete (vty, vty->index, "interface", iface); } @@ -569,7 +567,6 @@ DEFUN (no_match_tag, "Match tag of route\n" "Metric value\n") { - /* CHECK ME argc referenced below */ char *mval = (argc == 4) ? argv[3]->arg : NULL; return ripng_route_match_delete (vty, vty->index, "tag", mval); } @@ -596,7 +593,6 @@ DEFUN (no_set_metric, "Metric value for destination routing protocol\n" "Metric value\n") { - /* CHECK ME argc referenced below */ char *mval = (argc == 4) ? argv[3]->arg : NULL; return ripng_route_set_delete (vty, vty->index, "metric", mval); } @@ -641,7 +637,6 @@ DEFUN (no_set_ipv6_nexthop_local, "IPv6 local address\n" "IPv6 address of next hop\n") { - /* CHECK ME argc referenced below */ char *addr = (argc == 6) ? argv[5]->arg : NULL; return ripng_route_set_delete (vty, vty->index, "ipv6 next-hop local", addr); } @@ -666,7 +661,6 @@ DEFUN (no_set_tag, "Tag value for routing protocol\n" "Tag value\n") { - /* CHECK ME argc referenced below */ char *tag = (argc == 4) ? argv[3]->arg : NULL; return ripng_route_set_delete (vty, vty->index, "tag", tag); } diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 44985adbf0..09f761a3f7 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1732,12 +1732,12 @@ DEFUN (vtysh_show_thread, "Thread CPU usage\n" "Display filter (rwtexb)\n") { - /* CHECK ME argc referenced below */ + int idx_filter = 3; unsigned int i; int ret = CMD_SUCCESS; char line[100]; - sprintf(line, "show thread cpu %s\n", (argc == 1) ? argv[0] : ""); + sprintf(line, "show thread cpu %s\n", (argc == 4) ? argv[idx_filter] : ""); for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) { -- 2.39.5