Hi Max,
On Thu, Mar 17, 2016 at 03:42:27PM +0100, msuraev(a)sysmocom.de wrote:
+DEFUN(bvc_reset, bvc_reset_cmd,
+ "bvc reset nsei <0-65535> bvci <0-65535>",
[...]
+ if (!strcmp(argv[0], "reset"))
+ return CMD_WARNING;
no need to do this. the generic vty parser code will make sure that you
don't end up here if the command doesn't match the synfax above.
+ if (argc != 2)
+ return CMD_WARNING;
same here. If the number of arguments is not the number of mandatory
arguments, you will never get called.
So while defensive programming is generally a good idea, in the VTY case
it doesn't add any benefit and just makes the functions longer. We
never do this kind of checking in other functions, as we rely on
libosmovty to handle this.
The only places where you need to check for argc is when you have
optional arguments, and !strcmp() is only needed if you have something
like "bvc (start|stop)" in order to determien if start or stop was
stated.
Also, it might make sense to prefix the entire command with bssgp so
that it becomes "bssgp bvc reset ...."
--
- Harald Welte <laforge(a)gnumonks.org>
http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)