diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2016-12-09 17:50:01 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2016-12-09 17:50:01 +0100 |
commit | 5304ba7e560fc9b5f13fd5657e370d726714673b (patch) | |
tree | a505ad39c3396ecf20d5f1d2192bb83258dd59c8 | |
parent | lib: remove vty->index (diff) | |
download | frr-5304ba7e560fc9b5f13fd5657e370d726714673b.tar.xz frr-5304ba7e560fc9b5f13fd5657e370d726714673b.zip |
*: kill useless if(...) after VTY_DECLVAR_CONTEXT
VTY_DECLVAR_CONTEXT already contains a NULL check, vty warning message
and return statement. These are not needed.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to '')
-rw-r--r-- | bgpd/bgp_vty.c | 10 | ||||
-rw-r--r-- | bgpd/rfapi/bgp_rfapi_cfg.c | 290 | ||||
-rw-r--r-- | isisd/isisd.c | 12 | ||||
-rw-r--r-- | ospf6d/ospf6_top.c | 6 | ||||
-rw-r--r-- | ospfd/ospf_opaque.c | 6 | ||||
-rw-r--r-- | ospfd/ospf_te.c | 6 | ||||
-rw-r--r-- | ospfd/ospf_vty.c | 230 | ||||
-rw-r--r-- | tools/vty_check.cocci | 22 |
8 files changed, 22 insertions, 560 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index ba1e86bc5..1c2cc037f 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1621,9 +1621,6 @@ DEFUN (bgp_graceful_restart_stalepath_time, int idx_number = 3; u_int32_t stalepath; - if (! bgp) - return CMD_WARNING; - VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); bgp->stalepath_time = stalepath; return CMD_SUCCESS; @@ -1641,9 +1638,6 @@ DEFUN (bgp_graceful_restart_restart_time, int idx_number = 3; u_int32_t restart; - if (! bgp) - return CMD_WARNING; - VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); bgp->restart_time = restart; return CMD_SUCCESS; @@ -1659,8 +1653,6 @@ DEFUN (no_bgp_graceful_restart_stalepath_time, "Delay value (seconds)\n") { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (! bgp) - return CMD_WARNING; bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; return CMD_SUCCESS; @@ -1676,8 +1668,6 @@ DEFUN (no_bgp_graceful_restart_restart_time, "Delay value (seconds)\n") { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (! bgp) - return CMD_WARNING; bgp->restart_time = BGP_DEFAULT_RESTART_TIME; return CMD_SUCCESS; diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 4e8325b70..b6c162eb1 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -299,12 +299,6 @@ DEFUN (vnc_advertise_un_method, { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "VNC not configured%s", VTY_NEWLINE); @@ -387,11 +381,6 @@ DEFUN (vnc_defaults_rt_import, "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } return set_ecom_list (vty, argc - 2, argv + 2, &bgp->rfapi_cfg->default_rt_import_list); } @@ -404,11 +393,6 @@ DEFUN (vnc_defaults_rt_export, "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } return set_ecom_list (vty, argc - 2, argv + 2, &bgp->rfapi_cfg->default_rt_export_list); } @@ -423,11 +407,6 @@ DEFUN (vnc_defaults_rt_both, VTY_DECLVAR_CONTEXT(bgp, bgp); int rc; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } rc = set_ecom_list (vty, argc - 2, argv + 2, &bgp->rfapi_cfg->default_rt_import_list); if (rc != CMD_SUCCESS) @@ -446,12 +425,6 @@ DEFUN (vnc_defaults_rd, int ret; struct prefix_rd prd; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!strncmp (argv[1]->arg, "auto:vn:", 8)) { /* @@ -508,12 +481,6 @@ DEFUN (vnc_defaults_l2rd, VTY_DECLVAR_CONTEXT(bgp, bgp); uint8_t value = 0; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!strcmp (argv[1]->arg, "auto:vn")) { value = 0; @@ -552,12 +519,6 @@ DEFUN (vnc_defaults_no_l2rd, { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - bgp->rfapi_cfg->default_l2rd = 0; bgp->rfapi_cfg->flags &= ~BGP_VNC_CONFIG_L2RD; @@ -576,12 +537,6 @@ DEFUN (vnc_defaults_responselifetime, struct listnode *hdnode; struct rfapi_descriptor *rfd; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - h = bgp->rfapi; if (!h) return CMD_WARNING; @@ -834,11 +789,6 @@ DEFUN (vnc_redistribute_rh_roo_localadmin, uint32_t localadmin; char *endptr; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } if (!bgp->rfapi_cfg) { vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE); @@ -895,11 +845,6 @@ DEFUN (vnc_redistribute_mode, VTY_DECLVAR_CONTEXT(bgp, bgp); vnc_redist_mode_t newmode; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } if (!bgp->rfapi_cfg) { vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE); @@ -955,11 +900,6 @@ DEFUN (vnc_redistribute_protocol, int type = ZEBRA_ROUTE_MAX; /* init to bogus value */ afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } if (!bgp->rfapi_cfg) { vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE); @@ -1008,11 +948,6 @@ DEFUN (vnc_no_redistribute_protocol, int type; afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } if (!bgp->rfapi_cfg) { vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE); @@ -1054,11 +989,6 @@ DEFUN (vnc_redistribute_bgp_exterior, int type; afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } if (!bgp->rfapi_cfg) { vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE); @@ -1091,12 +1021,6 @@ DEFUN (vnc_redistribute_nvegroup, { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1129,12 +1053,6 @@ DEFUN (vnc_redistribute_no_nvegroup, { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1163,12 +1081,6 @@ DEFUN (vnc_redistribute_lifetime, { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1210,12 +1122,6 @@ DEFUN (vnc_redist_bgpdirect_no_prefixlist, struct rfapi_cfg *hc; uint8_t route_type = 0; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!(hc = bgp->rfapi_cfg)) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1269,12 +1175,6 @@ DEFUN (vnc_redist_bgpdirect_prefixlist, afi_t afi; uint8_t route_type = 0; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!(hc = bgp->rfapi_cfg)) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1325,12 +1225,6 @@ DEFUN (vnc_redist_bgpdirect_no_routemap, struct rfapi_cfg *hc; uint8_t route_type = 0; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!(hc = bgp->rfapi_cfg)) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1371,12 +1265,6 @@ DEFUN (vnc_redist_bgpdirect_routemap, struct rfapi_cfg *hc; uint8_t route_type = 0; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!(hc = bgp->rfapi_cfg)) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1422,12 +1310,6 @@ DEFUN (vnc_nve_group_redist_bgpdirect_no_prefixlist, VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg) afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1477,12 +1359,6 @@ DEFUN (vnc_nve_group_redist_bgpdirect_prefixlist, VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1531,12 +1407,6 @@ DEFUN (vnc_nve_group_redist_bgpdirect_no_routemap, VTY_DECLVAR_CONTEXT(bgp, bgp); VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1573,12 +1443,6 @@ DEFUN (vnc_nve_group_redist_bgpdirect_routemap, VTY_DECLVAR_CONTEXT(bgp, bgp); VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1628,12 +1492,6 @@ DEFUN (vnc_export_mode, uint32_t oldmode = 0; uint32_t newmode = 0; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "VNC not configured%s", VTY_NEWLINE); @@ -1756,12 +1614,6 @@ DEFUN (vnc_export_nvegroup, VTY_DECLVAR_CONTEXT(bgp, bgp); struct rfapi_nve_group_cfg *rfg_new; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1864,12 +1716,6 @@ DEFUN (vnc_no_export_nvegroup, struct listnode *node, *nnode; struct rfapi_rfg_name *rfgn; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -1931,12 +1777,6 @@ DEFUN (vnc_nve_group_export_no_prefixlist, VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -2006,12 +1846,6 @@ DEFUN (vnc_nve_group_export_prefixlist, VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -2069,12 +1903,6 @@ DEFUN (vnc_nve_group_export_no_routemap, VTY_DECLVAR_CONTEXT(bgp, bgp); VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -2134,12 +1962,6 @@ DEFUN (vnc_nve_group_export_routemap, VTY_DECLVAR_CONTEXT(bgp, bgp); VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!bgp->rfapi_cfg) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -2191,12 +2013,6 @@ DEFUN (vnc_nve_export_no_prefixlist, struct rfapi_cfg *hc; afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!(hc = bgp->rfapi_cfg)) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -2259,12 +2075,6 @@ DEFUN (vnc_nve_export_prefixlist, struct rfapi_cfg *hc; afi_t afi; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!(hc = bgp->rfapi_cfg)) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -2312,12 +2122,6 @@ DEFUN (vnc_nve_export_no_routemap, VTY_DECLVAR_CONTEXT(bgp, bgp); struct rfapi_cfg *hc; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!(hc = bgp->rfapi_cfg)) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -2370,12 +2174,6 @@ DEFUN (vnc_nve_export_routemap, VTY_DECLVAR_CONTEXT(bgp, bgp); struct rfapi_cfg *hc; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!(hc = bgp->rfapi_cfg)) { vty_out (vty, "rfapi not configured%s", VTY_NEWLINE); @@ -2616,12 +2414,6 @@ DEFUN (vnc_nve_group, struct listnode *node, *nnode; struct rfapi_rfg_name *rfgn; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* Search for name */ rfg = rfapi_group_lookup_byname (bgp, argv[2]->arg); @@ -2913,11 +2705,6 @@ DEFUN (vnc_no_nve_group, { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } return bgp_rfapi_delete_named_nve_group (vty, bgp, argv[3]->arg); } @@ -2938,12 +2725,6 @@ DEFUN (vnc_nve_group_prefix, struct route_node *rn; int is_un_prefix = 0; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { @@ -3063,12 +2844,6 @@ DEFUN (vnc_nve_group_rt_import, int is_export_bgp = 0; int is_export_zebra = 0; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { @@ -3135,12 +2910,6 @@ DEFUN (vnc_nve_group_rt_export, VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); int rc; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { @@ -3179,12 +2948,6 @@ DEFUN (vnc_nve_group_rt_both, struct listnode *node; struct rfapi_rfg_name *rfgn; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { @@ -3266,12 +3029,6 @@ DEFUN (vnc_nve_group_l2rd, VTY_DECLVAR_CONTEXT(bgp, bgp); VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { @@ -3320,12 +3077,6 @@ DEFUN (vnc_nve_group_no_l2rd, VTY_DECLVAR_CONTEXT(bgp, bgp); VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { @@ -3351,12 +3102,6 @@ DEFUN (vnc_nve_group_rd, struct prefix_rd prd; VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { @@ -3433,12 +3178,6 @@ DEFUN (vnc_nve_group_responselifetime, struct rfapi_descriptor *rfd; struct listnode *hdnode; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { @@ -3509,12 +3248,6 @@ DEFUN (vnc_l2_group, VTY_DECLVAR_CONTEXT(bgp, bgp); struct rfapi_l2_group_cfg *rfg; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* Search for name */ rfg = rfapi_l2_group_lookup_byname (bgp, argv[2]->arg); @@ -3601,11 +3334,6 @@ DEFUN (vnc_no_l2_group, { VTY_DECLVAR_CONTEXT(bgp, bgp); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } return bgp_rfapi_delete_named_l2_group (vty, bgp, argv[3]->arg); } @@ -3619,12 +3347,6 @@ DEFUN (vnc_l2_group_lni, VTY_DECLVAR_CONTEXT(bgp, bgp); VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg); - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg)) { @@ -3648,12 +3370,6 @@ DEFUN (vnc_l2_group_labels, VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg); struct list *ll; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg)) { @@ -3694,12 +3410,6 @@ DEFUN (vnc_l2_group_no_labels, VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg); struct list *ll; - if (!bgp) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg)) { diff --git a/isisd/isisd.c b/isisd/isisd.c index 4ca9e7fff..f09afeb93 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -320,12 +320,6 @@ area_net_title (struct vty *vty, const char *net_title) u_char buff[255]; - if (!area) - { - vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); - return CMD_ERR_NO_MATCH; - } - /* We check that we are not over the maximal number of addresses */ if (listcount (area->area_addrs) >= isis->max_area_addrs) { @@ -420,12 +414,6 @@ area_clear_net_title (struct vty *vty, const char *net_title) struct listnode *node; u_char buff[255]; - if (!area) - { - vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); - return CMD_ERR_NO_MATCH; - } - addr.addr_len = dotformat2buff (buff, net_title); if (addr.addr_len < 8 || addr.addr_len > 20) { diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 32d7a3391..6da9680fe 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -407,9 +407,6 @@ DEFUN (ospf6_timers_lsa, int idx_number = 3; unsigned int minarrival; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); ospf->lsa_minarrival = minarrival; @@ -429,9 +426,6 @@ DEFUN (no_ospf6_timers_lsa, int idx_number = 4; unsigned int minarrival; - if (!ospf) - return CMD_SUCCESS; - if (argc == 5) { VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index e43314779..56efa2ebd 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -771,9 +771,6 @@ DEFUN (capability_opaque, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - /* Turn on the "master switch" of opaque-lsa capability. */ if (!CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) { @@ -804,9 +801,6 @@ DEFUN (no_capability_opaque, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - /* Turn off the "master switch" of opaque-lsa capability. */ if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) { diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index ec9a14590..c691aac04 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -2268,9 +2268,6 @@ DEFUN (ospf_mpls_te_on, struct listnode *node; struct mpls_te_link *lp; - if (!ospf) - return CMD_SUCCESS; - if (OspfMplsTE.status == enabled) return CMD_SUCCESS; @@ -2336,9 +2333,6 @@ DEFUN (ospf_mpls_te_router_addr, struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr; struct in_addr value; - if (!ospf) - return CMD_SUCCESS; - if (! inet_aton (argv[idx_ipv4]->arg, &value)) { vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index a670e8de6..c2999ca02 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -216,9 +216,6 @@ DEFUN (ospf_router_id, struct in_addr router_id; int ret; - if (!ospf) - return CMD_SUCCESS; - ret = inet_aton (argv[idx_ipv4]->arg, &router_id); if (!ret) { @@ -254,9 +251,6 @@ DEFUN_HIDDEN (ospf_router_id_old, struct in_addr router_id; int ret; - if (!ospf) - return CMD_SUCCESS; - ret = inet_aton (argv[idx_ipv4]->arg, &router_id); if (!ret) { @@ -291,9 +285,6 @@ DEFUN (no_ospf_router_id, struct listnode *node; struct ospf_area *area; - if (!ospf) - return CMD_SUCCESS; - ospf->router_id_static.s_addr = 0; for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) @@ -389,9 +380,6 @@ DEFUN (ospf_passive_interface, struct ospf_if_params *params; struct route_node *rn; - if (!ospf) - return CMD_SUCCESS; - if (strcmp (argv[1]->text, "default") == 0) { ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); @@ -462,9 +450,6 @@ DEFUN (no_ospf_passive_interface, int ret; struct route_node *rn; - if (!ospf) - return CMD_SUCCESS; - if (strcmp (argv[2]->text, "default") == 0) { ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); @@ -529,9 +514,6 @@ DEFUN (ospf_network_area, struct in_addr area_id; int ret, format; - if (!ospf) - return CMD_SUCCESS; - if (ospf->instance) { vty_out (vty, "The network command is not supported in multi-instance ospf%s", @@ -577,9 +559,6 @@ DEFUN (no_ospf_network_area, struct in_addr area_id; int ret, format; - if (!ospf) - return CMD_SUCCESS; - if (ospf->instance) { vty_out (vty, "The network command is not supported in multi-instance ospf%s", @@ -623,9 +602,6 @@ DEFUN (ospf_area_range, int format; u_int32_t cost; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); @@ -659,9 +635,6 @@ DEFUN (ospf_area_range_cost, int format; u_int32_t cost; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); @@ -690,9 +663,6 @@ DEFUN (ospf_area_range_not_advertise, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); @@ -724,9 +694,6 @@ DEFUN (no_ospf_area_range, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); @@ -754,9 +721,6 @@ DEFUN (ospf_area_range_substitute, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); @@ -786,9 +750,6 @@ DEFUN (no_ospf_area_range_substitute, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); @@ -1070,9 +1031,6 @@ DEFUN (ospf_area_vlink, char md5_key[OSPF_AUTH_MD5_SIZE+1]; int i; int ret; - - if (!ospf) - return CMD_SUCCESS; ospf_vl_config_data_init(&vl_config, vty); @@ -1183,9 +1141,6 @@ DEFUN (ospf_area_vlink_intervals, struct ospf_vl_config_data vl_config; int ret = 0; - if (!ospf) - return CMD_SUCCESS; - ospf_vl_config_data_init(&vl_config, vty); char *area_id = argv[1]->arg; @@ -1244,9 +1199,6 @@ DEFUN (no_ospf_area_vlink, int i; int ret, format; - if (!ospf) - return CMD_SUCCESS; - ospf_vl_config_data_init(&vl_config, vty); ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format); @@ -1348,9 +1300,6 @@ DEFUN (no_ospf_area_vlink_intervals, struct ospf_vl_config_data vl_config; int ret = 0; - if (!ospf) - return CMD_SUCCESS; - ospf_vl_config_data_init(&vl_config, vty); char *area_id = argv[2]->arg; @@ -1406,9 +1355,6 @@ DEFUN (ospf_area_shortcut, int mode; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); @@ -1449,9 +1395,6 @@ DEFUN (no_ospf_area_shortcut, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); @@ -1477,9 +1420,6 @@ DEFUN (ospf_area_stub, struct in_addr area_id; int ret, format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_area_stub_set (ospf, area_id); @@ -1509,9 +1449,6 @@ DEFUN (ospf_area_stub_no_summary, struct in_addr area_id; int ret, format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_area_stub_set (ospf, area_id); @@ -1541,9 +1478,6 @@ DEFUN (no_ospf_area_stub, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_stub_unset (ospf, area_id); @@ -1567,9 +1501,6 @@ DEFUN (no_ospf_area_stub_no_summary, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_no_summary_unset (ospf, area_id); @@ -1584,9 +1515,6 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv, struct in_addr area_id; int ret, format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg); ret = ospf_area_nssa_set (ospf, area_id); @@ -1695,9 +1623,6 @@ DEFUN (no_ospf_area_nssa, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_nssa_unset (ospf, area_id); @@ -1727,9 +1652,6 @@ DEFUN (ospf_area_default_cost, int format; struct prefix_ipv4 p; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[idx_number]->arg, 0, 16777215); @@ -1773,9 +1695,6 @@ DEFUN (no_ospf_area_default_cost, int format; struct prefix_ipv4 p; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[idx_number]->arg, 0, OSPF_LS_INFINITY); @@ -1821,9 +1740,6 @@ DEFUN (ospf_area_export_list, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); @@ -1848,9 +1764,6 @@ DEFUN (no_ospf_area_export_list, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); @@ -1878,9 +1791,6 @@ DEFUN (ospf_area_import_list, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); @@ -1905,9 +1815,6 @@ DEFUN (no_ospf_area_import_list, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); @@ -1940,9 +1847,6 @@ DEFUN (ospf_area_filter_list, struct prefix_list *plist; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); @@ -1990,9 +1894,6 @@ DEFUN (no_ospf_area_filter_list, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) @@ -2046,9 +1947,6 @@ DEFUN (ospf_area_authentication_message_digest, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); @@ -2071,9 +1969,6 @@ DEFUN (ospf_area_authentication, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); @@ -2097,9 +1992,6 @@ DEFUN (no_ospf_area_authentication, struct in_addr area_id; int format; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); @@ -2128,9 +2020,6 @@ DEFUN (ospf_abr_type, int idx_vendor = 2; u_char abr_type = OSPF_ABR_UNKNOWN; - if (!ospf) - return CMD_SUCCESS; - if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) abr_type = OSPF_ABR_CISCO; else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) @@ -2167,9 +2056,6 @@ DEFUN (no_ospf_abr_type, int idx_vendor = 3; u_char abr_type = OSPF_ABR_UNKNOWN; - if (!ospf) - return CMD_SUCCESS; - if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) abr_type = OSPF_ABR_CISCO; else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) @@ -2198,9 +2084,6 @@ DEFUN (ospf_log_adjacency_changes, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); return CMD_SUCCESS; @@ -2214,9 +2097,6 @@ DEFUN (ospf_log_adjacency_changes_detail, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); return CMD_SUCCESS; @@ -2230,9 +2110,6 @@ DEFUN (no_ospf_log_adjacency_changes, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); return CMD_SUCCESS; @@ -2247,9 +2124,6 @@ DEFUN (no_ospf_log_adjacency_changes_detail, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); return CMD_SUCCESS; @@ -2263,9 +2137,6 @@ DEFUN (ospf_compatible_rfc1583, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) { SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); @@ -2283,9 +2154,6 @@ DEFUN (no_ospf_compatible_rfc1583, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) { UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); @@ -2313,9 +2181,6 @@ ospf_timers_spf_set (struct vty *vty, unsigned int delay, unsigned int max) { VTY_DECLVAR_CONTEXT(ospf, ospf); - - if (!ospf) - return CMD_SUCCESS; ospf->spf_delay = delay; ospf->spf_holdtime = hold; @@ -2337,9 +2202,6 @@ DEFUN (ospf_timers_min_ls_interval, int idx_number = 4; unsigned int interval; - if (!ospf) - return CMD_SUCCESS; - if (argc != 1) { vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); @@ -2382,9 +2244,6 @@ DEFUN (ospf_timers_min_ls_arrival, int idx_number = 3; unsigned int arrival; - if (!ospf) - return CMD_SUCCESS; - if (argc != 1) { vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); @@ -2409,9 +2268,6 @@ DEFUN (no_ospf_timers_min_ls_arrival, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; return CMD_SUCCESS; @@ -2476,9 +2332,6 @@ DEFUN (ospf_timers_lsa, int idx_number = 3; unsigned int minarrival; - if (!ospf) - return CMD_SUCCESS; - if (argc != 1) { vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); @@ -2504,9 +2357,6 @@ DEFUN (no_ospf_timers_lsa, VTY_DECLVAR_CONTEXT(ospf, ospf); unsigned int minarrival; - if (!ospf) - return CMD_SUCCESS; - if (argc > 4) { VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[4]->arg); @@ -2539,9 +2389,6 @@ DEFUN (ospf_neighbor, unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); if (argc > 2) @@ -2579,9 +2426,6 @@ DEFUN (ospf_neighbor_poll_interval, unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535); @@ -2613,9 +2457,6 @@ DEFUN (no_ospf_neighbor, int idx_ipv4 = 2; struct in_addr nbr_addr; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); (void)ospf_nbr_nbma_unset (ospf, nbr_addr); @@ -2638,9 +2479,6 @@ DEFUN (no_ospf_neighbor_poll, int idx_ipv4 = 2; struct in_addr nbr_addr; - if (!ospf) - return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); (void)ospf_nbr_nbma_unset (ospf, nbr_addr); @@ -2658,9 +2496,6 @@ DEFUN (ospf_refresh_timer, VTY_DECLVAR_CONTEXT(ospf, ospf); int idx_number = 2; unsigned int interval; - - if (!ospf) - return CMD_SUCCESS; VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; @@ -2682,9 +2517,6 @@ DEFUN (no_ospf_refresh_timer, int idx_number = 3; unsigned int interval; - if (!ospf) - return CMD_SUCCESS; - if (argc == 1) { VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); @@ -2713,9 +2545,6 @@ DEFUN (ospf_auto_cost_reference_bandwidth, struct listnode *node; struct interface *ifp; - if (!ospf) - return CMD_SUCCESS; - refbw = strtol (argv[idx_number]->arg, NULL, 10); if (refbw < 1 || refbw > 4294967) { @@ -2746,9 +2575,6 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth, struct listnode *node, *nnode; struct interface *ifp; - if (!ospf) - return CMD_SUCCESS; - if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) return CMD_SUCCESS; @@ -2773,9 +2599,6 @@ DEFUN (ospf_write_multiplier, int idx_number; u_int32_t write_oi_count; - if (!ospf) - return CMD_SUCCESS; - if (argc == 3) idx_number = 2; else @@ -2808,9 +2631,6 @@ DEFUN (no_ospf_write_multiplier, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; return CMD_SUCCESS; } @@ -7346,8 +7166,6 @@ DEFUN (no_ospf_redistribute_source, int idx_protocol = 2; int source; struct ospf_redist *red; - if (!ospf) - return CMD_SUCCESS; source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) @@ -7456,9 +7274,6 @@ DEFUN (no_ospf_redistribute_instance_source, struct ospf_redist *red; int source; - if (!ospf) - return CMD_SUCCESS; - if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) source = ZEBRA_ROUTE_OSPF; else @@ -7500,9 +7315,6 @@ DEFUN (ospf_distribute_list_out, int idx_word = 1; int source; - if (!ospf) - return CMD_SUCCESS; - /* Get distribute source. */ source = proto_redistnum(AFI_IP, argv[4]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) @@ -7524,9 +7336,6 @@ DEFUN (no_ospf_distribute_list_out, int idx_word = 2; int source; - if (!ospf) - return CMD_SUCCESS; - source = proto_redistnum(AFI_IP, argv[5]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; @@ -7556,9 +7365,6 @@ DEFUN (ospf_default_information_originate, int metric = -1; struct ospf_redist *red; - if (!ospf) - return CMD_SUCCESS; - if (argc < 4) return CMD_WARNING; /* this should not happen */ @@ -7606,9 +7412,6 @@ DEFUN (no_ospf_default_information_originate, struct prefix_ipv4 p; struct ospf_external *ext; struct ospf_redist *red; - - if (!ospf) - return CMD_SUCCESS; p.family = AF_INET; p.prefix.s_addr = 0; @@ -7640,9 +7443,6 @@ DEFUN (ospf_default_metric, int idx_number = 1; int metric = -1; - if (!ospf) - return CMD_SUCCESS; - if (!str2metric (argv[idx_number]->arg, &metric)) return CMD_WARNING; @@ -7660,9 +7460,6 @@ DEFUN (no_ospf_default_metric, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - ospf->default_metric = -1; return CMD_SUCCESS; @@ -7678,9 +7475,6 @@ DEFUN (ospf_distance, VTY_DECLVAR_CONTEXT(ospf, ospf); int idx_number = 1; - if (!ospf) - return CMD_SUCCESS; - ospf->distance_all = atoi (argv[idx_number]->arg); return CMD_SUCCESS; @@ -7695,9 +7489,6 @@ DEFUN (no_ospf_distance, { VTY_DECLVAR_CONTEXT(ospf, ospf); - if (!ospf) - return CMD_SUCCESS; - ospf->distance_all = 0; return CMD_SUCCESS; @@ -7763,9 +7554,6 @@ DEFUN (ospf_distance_ospf, VTY_DECLVAR_CONTEXT(ospf, ospf); int idx_area_distance = 2; - if (!ospf) - return CMD_SUCCESS; - if (argc < 3) /* should not happen */ return CMD_WARNING; @@ -7969,9 +7757,6 @@ DEFUN (ospf_max_metric_router_lsa_admin, VTY_DECLVAR_CONTEXT(ospf, ospf); struct listnode *ln; struct ospf_area *area; - - if (!ospf) - return CMD_SUCCESS; for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) { @@ -7998,9 +7783,6 @@ DEFUN (no_ospf_max_metric_router_lsa_admin, VTY_DECLVAR_CONTEXT(ospf, ospf); struct listnode *ln; struct ospf_area *area; - - if (!ospf) - return CMD_SUCCESS; for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) { @@ -8029,9 +7811,6 @@ DEFUN (ospf_max_metric_router_lsa_startup, VTY_DECLVAR_CONTEXT(ospf, ospf); int idx_number = 3; unsigned int seconds; - - if (!ospf) - return CMD_SUCCESS; if (argc != 1) { @@ -8058,9 +7837,6 @@ DEFUN (no_ospf_max_metric_router_lsa_startup, VTY_DECLVAR_CONTEXT(ospf, ospf); struct listnode *ln; struct ospf_area *area; - - if (!ospf) - return CMD_SUCCESS; ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; @@ -8091,9 +7867,6 @@ DEFUN (ospf_max_metric_router_lsa_shutdown, VTY_DECLVAR_CONTEXT(ospf, ospf); int idx_number = 3; unsigned int seconds; - - if (!ospf) - return CMD_SUCCESS; if (argc != 1) { @@ -8118,9 +7891,6 @@ DEFUN (no_ospf_max_metric_router_lsa_shutdown, "Time (seconds) to wait till full shutdown\n") { VTY_DECLVAR_CONTEXT(ospf, ospf); - - if (!ospf) - return CMD_SUCCESS; ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; diff --git a/tools/vty_check.cocci b/tools/vty_check.cocci new file mode 100644 index 000000000..7e5fcc405 --- /dev/null +++ b/tools/vty_check.cocci @@ -0,0 +1,22 @@ +/* + * VTY_DECLVAR_CONTEXT contains a built-in "if (!var) return;" + */ +@@ +identifier var, typ; +statement S; +@@ + + { + ... + \( + VTY_DECLVAR_CONTEXT(typ, var); + \| + VTY_DECLVAR_CONTEXT_SUB(typ, var); + \) + ... +- if ( +- \( !var \| var == NULL \) +- ) +- S + ... + } |