trx: Fix coverity BER calculation NULL dereference
Allow output of encoded bit count or error count on BER calculation without requiring both pointers to exist. Change-Id: I2c78fa6a92a3b3da4aad8f70353e5a43451b0aa5 Fixes: Coverity CID 137963 Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
This commit is contained in:
parent
af3443385b
commit
d6920df630
|
@ -442,30 +442,33 @@ struct gsm0503_mcs_code gsm0503_mcs_dl_codes[EGPRS_NUM_MCS] = {
|
|||
},
|
||||
};
|
||||
|
||||
int osmo_conv_decode_ber(const struct osmo_conv_code *code,
|
||||
static int osmo_conv_decode_ber(const struct osmo_conv_code *code,
|
||||
const sbit_t *input, ubit_t *output,
|
||||
int *n_errors, int *n_bits_total)
|
||||
{
|
||||
int res, i;
|
||||
int res, i, coded_len;
|
||||
ubit_t recoded[EGPRS_DATA_C_MAX];
|
||||
|
||||
res = osmo_conv_decode(code, input, output);
|
||||
|
||||
if (n_bits_total) {
|
||||
*n_bits_total = osmo_conv_encode(code, output, recoded);
|
||||
OSMO_ASSERT(sizeof(recoded)/sizeof(recoded[0]) >= *n_bits_total);
|
||||
if (n_bits_total || n_errors) {
|
||||
coded_len = osmo_conv_encode(code, output, recoded);
|
||||
OSMO_ASSERT(sizeof(recoded)/sizeof(recoded[0]) >= coded_len);
|
||||
}
|
||||
|
||||
/* Count bit errors */
|
||||
if (n_errors) {
|
||||
*n_errors = 0;
|
||||
for (i=0; i< *n_bits_total; i++) {
|
||||
for (i = 0; i < coded_len; i++) {
|
||||
if (! ((recoded[i] && input[i]<0) ||
|
||||
(!recoded[i] && input[i]>0)) )
|
||||
*n_errors += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (n_bits_total)
|
||||
*n_bits_total = coded_len;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue