Message ID | 20160229000810.GA28083@dub6 |
---|---|
State | Changes Requested |
Headers | show |
> On 29 Feb 2016, at 01:08, Neels Hofmeyr <nhofmeyr@sysmocom.de> wrote: > > > > So we have the API talking about length "in octets" while the implementation > clearly employs septet length. > > Fixing the implementation to match the API doc would break binary > compatibility. I should probably fix the API doc to match that weird > implementation, but it nags and hurts a little. > > Any opinions? please fix the API comment. IIRC there are several fields in encoded messages where the length is passed as septets. E.g. for SMS the last 7 bits of an octet might not belong to the text anymore. Passing the number of septets avoids this issue. holger
diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index e8e452f..a9afc1a 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -184,8 +184,9 @@ return text - text_buf_begin; } -int gsm_7bit_decode_n(char *text, size_t n, const uint8_t *user_data, uint8_t septet_l) +int gsm_7bit_decode_n(char *text, size_t n, const uint8_t *user_data, uint8_t octet_l) { + uint8_t septet_l = ((uint16_t)octet_l * 8) / 7; return gsm_7bit_decode_n_hdr(text, n, user_data, septet_l, 0); }