mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 17:06:28 +00:00
lib: better warnings for install_element
Also fixes misuse of vector_slot() - that one doesn't check for access beyond end of vector... And print node names in grammar sandbox "printall". Fixes: #543 Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
427f8e61bb
commit
3cbb67f229
@ -360,21 +360,23 @@ void install_element(enum node_type ntype, struct cmd_element *cmd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cnode = vector_slot(cmdvec, ntype);
|
cnode = vector_lookup(cmdvec, ntype);
|
||||||
|
|
||||||
if (cnode == NULL) {
|
if (cnode == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Command node %d doesn't exist, please check it\n",
|
"%s[%s]:\n"
|
||||||
ntype);
|
"\tnode %d (%s) does not exist.\n"
|
||||||
fprintf(stderr,
|
"\tplease call install_node() before install_element()\n",
|
||||||
"Have you called install_node before this install_element?\n");
|
cmd->name, cmd->string, ntype, node_names[ntype]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hash_lookup(cnode->cmd_hash, cmd) != NULL) {
|
if (hash_lookup(cnode->cmd_hash, cmd) != NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Multiple command installs to node %d of command:\n%s\n",
|
"%s[%s]:\n"
|
||||||
ntype, cmd->string);
|
"\tnode %d (%s) already has this command installed.\n"
|
||||||
|
"\tduplicate install_element call?\n",
|
||||||
|
cmd->name, cmd->string, ntype, node_names[ntype]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,21 +409,23 @@ void uninstall_element(enum node_type ntype, struct cmd_element *cmd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cnode = vector_slot(cmdvec, ntype);
|
cnode = vector_lookup(cmdvec, ntype);
|
||||||
|
|
||||||
if (cnode == NULL) {
|
if (cnode == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Command node %d doesn't exist, please check it\n",
|
"%s[%s]:\n"
|
||||||
ntype);
|
"\tnode %d (%s) does not exist.\n"
|
||||||
fprintf(stderr,
|
"\tplease call install_node() before uninstall_element()\n",
|
||||||
"Have you called install_node before this install_element?\n");
|
cmd->name, cmd->string, ntype, node_names[ntype]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hash_release(cnode->cmd_hash, cmd) == NULL) {
|
if (hash_release(cnode->cmd_hash, cmd) == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Trying to uninstall non-installed command (node %d):\n%s\n",
|
"%s[%s]:\n"
|
||||||
ntype, cmd->string);
|
"\tnode %d (%s) does not have this command installed.\n"
|
||||||
|
"\tduplicate uninstall_element call?\n",
|
||||||
|
cmd->name, cmd->string, ntype, node_names[ntype]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +404,8 @@ DEFUN (grammar_findambig,
|
|||||||
nodegraph = cnode->cmdgraph;
|
nodegraph = cnode->cmdgraph;
|
||||||
if (!nodegraph)
|
if (!nodegraph)
|
||||||
continue;
|
continue;
|
||||||
vty_out(vty, "scanning node %d\n", scannode - 1);
|
vty_out(vty, "scanning node %d (%s)\n",
|
||||||
|
scannode - 1, node_names[scannode - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
commands = cmd_graph_permutations(nodegraph);
|
commands = cmd_graph_permutations(nodegraph);
|
||||||
|
Loading…
Reference in New Issue
Block a user