Hi,
* Holger Hans Peter Freyther <holger(a)freyther.de> [2010-07-19 22:13]:
On 07/10/2010 12:56 AM, Nico Golde wrote:
Alright, cleaned up the previous code a bit,
implemented the
decoder and added a test case which the previous code
encoded incorrect. Please note that just using the new test
case string in the old code will also pass the test even
though the encoding is wrong. You need to compare the
encoded values to e.g. output of pduspy[0]. Patch attached.
I have finally applied your patch, thanks for poking me. I have
also made two modifications. The first is to separate testing of
encoding/decoding and comparing it to a byte array/string, the
second is to fix a possible off by one.
Good catch, I already had this fixed locally but was waiting
with another patch until you have looked at this one. Will
repost an update in case something like this occurs again to
prevent this doubled work.
I used the current result of the encoding and there
seems to
be at least one more bug with our encoding routines. We append
zero byte(s) at the end that are not touched by the encoding
routine but covered by the length.
A nice way to test this is to change the memset(something, 0 to
memset(something, 23 and see how it is going to change.
Would you be interested in changing that?
I just looked into this and if I'm not mistaken this is no
bug in the encoding but just a bug when comparing the
encoded result. The current code memcmp's n bytes where n is
the result of gsm_7bit_encode() with the input string
bytewise. The problem with this is that the function returns
the number of septets not octets. Attached is a patch for
the test code that should fix this.
Cheers
Nico