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