From 5a2484b10e8aeec3841833b79a8973cacb37bcee Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 28 Apr 2015 09:28:18 +0200 Subject: [PATCH] mgcp: Move assignment of src_codec downwards Currently the src_codec const variable is set to &src_end->codec before src_end is checked against NULL. Since the assigment is just an address operation and the memory where it points to is only accessed after the NULL check, this does not harm technically. Nevertheless this is potential source for errors if that code is changed. This commit moves the definition below the NULL check. This does not comply with the coding style, but it cannot be split into definition and a later assignment due to the const qualifier. Sponsored-by: On-Waves ehf --- openbsc/src/libmgcp/mgcp_transcode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openbsc/src/libmgcp/mgcp_transcode.c b/openbsc/src/libmgcp/mgcp_transcode.c index daf2510da..12cce2616 100644 --- a/openbsc/src/libmgcp/mgcp_transcode.c +++ b/openbsc/src/libmgcp/mgcp_transcode.c @@ -141,7 +141,6 @@ int mgcp_transcoding_setup(struct mgcp_endpoint *endp, { struct mgcp_process_rtp_state *state; enum audio_format src_fmt, dst_fmt; - const struct mgcp_rtp_codec *src_codec = &src_end->codec; const struct mgcp_rtp_codec *dst_codec = &dst_end->codec; /* cleanup first */ @@ -153,6 +152,8 @@ int mgcp_transcoding_setup(struct mgcp_endpoint *endp, if (!src_end) return 0; + const struct mgcp_rtp_codec *src_codec = &src_end->codec; + if (endp->tcfg->no_audio_transcoding) { LOGP(DMGCP, LOGL_NOTICE, "Transcoding disabled on endpoint 0x%x\n",