[PATCH 2/2] Add vty command to explicitly reset given BVCI

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Harald Welte laforge at gnumonks.org
Thu Mar 17 15:54:58 UTC 2016


Hi Max,

On Thu, Mar 17, 2016 at 03:42:27PM +0100, msuraev at 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 at gnumonks.org>           http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)



More information about the OpenBSC mailing list