[PATCH 2/4] vty: Hide unconfigured BTS on 'write'

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/.

Peter Stuge peter at stuge.se
Thu Sep 12 03:23:59 UTC 2013


Jacob Erlbeck wrote:
> +++ b/openbsc/src/libbsc/bsc_vty.c
> @@ -598,11 +598,13 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
>  	if (bts->excl_from_rf_lock)
>  		vty_out(vty, "  rf-lock-exclude%s", VTY_NEWLINE);
>  
> -	if (bts->model->config_write_bts)
> -		bts->model->config_write_bts(vty, bts);
> +	if (bts->model) {
> +	       if (bts->model->config_write_bts)
> +		       bts->model->config_write_bts(vty, bts);
>  
> -	llist_for_each_entry(trx, &bts->trx_list, list)
> -		config_write_trx_single(vty, trx);
> +	       llist_for_each_entry(trx, &bts->trx_list, list)
> +		       config_write_trx_single(vty, trx);
> +	}
>  }

My personal taste is to test all required conditions and exit early
if they aren't met.

That way, it's easy to get an overview of all conditions, before the
"meat" of the function takes place. It also avoids one level of
nesting for each condition. The patch would in this case become quite
simple:

+    if (!bts->model)
+        return;

(Maybe even if (!bts || !bts->model) ..)


//Peter




More information about the OpenBSC mailing list