[PATCH 1/2] Refactor mncc code

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

Holger Freyther holger at freyther.de
Tue Apr 5 20:47:13 UTC 2016


> On 24 Mar 2016, at 12:05, msuraev at sysmocom.de wrote:
> 
> From: Max <msuraev at sysmocom.de>
> 
> Use bool for boolean types.
> Consistently use enums instead of (u)int, char etc.
> Note: because actual enum representation is up to compiler this might
> change the size of gsm_mncc struct.

	=> bump protocol version then


> -int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate);
> +int gsm0808_assign_req(struct gsm_subscriber_connection *conn, enum gsm48_chan_mode chan_mode, bool full_rate);


we had this out of band. The topic is "boolean" trap, so if you want to change, then also consider using enums with just two values to express the meaning even stronger (and allow for extension).

E.g. with "full rate" it might turn into a tri-state

	* You have to use a TCH/F
	* You have to use a TCH/H
	* It would be nice to use a TCH/F..

> 
> -int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode)
> +int gsm48_lchan_modify(struct gsm_lchan *lchan, enum gsm48_chan_mode lchan_mode)
> {
> -	int rc;
> -
> -	rc = gsm48_tx_chan_mode_modify(lchan, lchan_mode);
> -	if (rc < 0)
> -		return rc;
> -
> -	return rc;
> +	return gsm48_tx_chan_mode_modify(lchan, lchan_mode);
> }


hehe, split this into a separate patch. Yes, it is obvious it returns rc either way and let's assume we don't have a unsigned -> int kind of conversion here.





More information about the OpenBSC mailing list