fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35753?usp=email )
Change subject: coding: inprove readability in osmo_conv_decode_ber_punctured() ......................................................................
coding: inprove readability in osmo_conv_decode_ber_punctured()
Change-Id: Iaece6d0fe42f173187baa5c87fcbe3cfc60c21fc Related: OS#6342, OS#6200 --- M src/coding/gsm0503_coding.c 1 file changed, 20 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/53/35753/1
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c index d63140e..9272fdb 100644 --- a/src/coding/gsm0503_coding.c +++ b/src/coding/gsm0503_coding.c @@ -536,7 +536,7 @@ int *n_errors, int *n_bits_total, const uint8_t *data_punc) { - int res, i, coded_len; + int res, coded_len; ubit_t recoded[EGPRS_DATA_C_MAX];
res = osmo_conv_decode(code, input, output); @@ -550,11 +550,15 @@ /* Count bit errors */ if (n_errors) { *n_errors = 0; - for (i = 0; i < coded_len; i++) { - if (((!data_punc) || (data_punc && !data_punc[i])) && - !((recoded[i] && input[i] < 0) || - (!recoded[i] && input[i] > 0)) ) - *n_errors += 1; + for (unsigned int i = 0; i < coded_len; i++) { + /* punctured bits do not count as bit errors */ + if (data_punc != NULL && data_punc[i]) + continue; + if (recoded[i] == 1 && input[i] < 0) + continue; + if (recoded[i] == 0 && input[i] > 0) + continue; + *n_errors += 1; } }