[PATCH openBSC] libmgcp: add enum mgcp_type

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
Fri Jul 5 16:13:53 UTC 2013


pablo at gnumonks.org wrote:
> +++ b/openbsc/src/libmgcp/mgcp_network.c
> @@ -371,10 +371,19 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what)
..
> +	switch (endp->type) {
> +	case MGCP_RTP_DEFAULT:
> +		return send_to(endp, DEST_BTS, proto == PROTO_RTP, &addr,
> +			       buf, rc);
> +	case MGCP_RTP_TRANSCODED:
> +		return send_transcoder(&endp->trans_net, endp->cfg,
> +				       proto == PROTO_RTP, buf, rc);
> +	default:
> +		LOGP(DMGCP, LOGL_ERROR, "Bad MGCP type %u on endpoint %u\n",
> +		     endp->type, ENDPOINT_NUMBER(endp));
> +	}
> +	return 0;

Please consider not having a default: case in the two switch ()
statements added by this patch.

No default: case makes the compiler warn if a value is added to the
enum in the future, without corresponding cases being added to the
switch ().

Since the pattern is to make each case return (I like it!) it would
be easy to move the LOGP() to before the return 0; to still get a
warning at runtime, even if the compile time warning was ignored.


//Peter




More information about the OpenBSC mailing list