[PATCH] sms: Fix gsm_7bit legacy functions return value

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/.

Jacob Erlbeck jerlbeck at sysmocom.de
Wed Jan 8 11:33:48 UTC 2014


On 08.01.2014 10:38, Holger Hans Peter Freyther wrote:
> On Tue, Jan 07, 2014 at 12:07:16PM +0100, Jacob Erlbeck wrote:
>>  	for (i = 0; i < ARRAY_SIZE(test_encode); ++i) {
>> +		/* Test legacy function (return value only) */
>> +		septet_length = gsm_7bit_encode(coded,
>> +						(const char *) test_encode[i].input);
>> +		printf("Legacy encode case %d: "
>> +		       "septet length %d (expected %d)\n"
>> +		       , i
>> +		       , septet_length, test_encode[i].expected_septet_length
>> +		      );
>> +		OSMO_ASSERT (septet_length == test_encode[i].expected_septet_length);
>> +
>> +		/* Test new function */
>>  		memset(coded, 0x42, sizeof(coded));
> 
> I think we should do the memset before the first encode/decode as well.
> Do you mind if I update the patch for that?

The data that is written to 'coded' by gsm_7bit_encode() is not checked
so initialising it wouldn't change anything since it will not been read
before the existing memset(). So I would only add it when the encoded
data is verified, too. This would mean using gsm_7bit_encode_oct()
instead of gsm_7bit_encode() and copying the OSME_ASSERT with the call
to memcmp().

Jacob




More information about the OpenBSC mailing list