From f1ad60e4d861d5ff462a8d7ab481ad082360f346 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 5 Jan 2018 14:19:33 +0100 Subject: Add function to properly encode RAI Add gsm48_encode_ra() which takes appropriate struct as [out] parameter instead of generic buffer. Using uint8_t buffer instead of proper struct type prooved to be error-prone - see Coverity CID57877, CID57876. Old gsm48_construct_ra() is made into tiny wrapper around new function. The test output is adjusted because of the change in function return value which was constant and hence ignored anyway. Related: OS#1640 Change-Id: I31f9605277f4945f207c2c44ff82e62399f8db74 --- tests/gsm0408/gsm0408_test.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tests/gsm0408/gsm0408_test.c') diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c index 935ec21d..77a88224 100644 --- a/tests/gsm0408/gsm0408_test.c +++ b/tests/gsm0408/gsm0408_test.c @@ -137,8 +137,7 @@ static inline void dump_ra(const struct gprs_ra_id *raid) static inline void check_ra(const struct gprs_ra_id *raid) { - uint8_t buf[6]; - int res; + struct gsm48_ra_id ra; struct gprs_ra_id raid0 = { .mnc = 0, .mcc = 0, @@ -146,10 +145,10 @@ static inline void check_ra(const struct gprs_ra_id *raid) .rac = 0, }; - res = gsm48_construct_ra(buf, raid); - printf("Constructed RA: %d - %s\n", res, res != sizeof(buf) ? "FAIL" : "OK"); + gsm48_encode_ra(&ra, raid); + printf("Constructed RA:\n"); - gsm48_parse_ra(&raid0, buf); + gsm48_parse_ra(&raid0, (const uint8_t *)&ra); dump_ra(raid); dump_ra(&raid0); printf("RA test..."); -- cgit v1.2.3