sms: Fix gsm_7bit legacy functions return value

The legacy 7bit conversion functions (those without the '_n_' in the
name) gave wrong return values on 64 bit platforms due to unproper
signed/unsigned conversions and the usage of SIZE_MAX.

This patch fixes this by using a smaller max size (see
GSM_7BIT_LEGACY_MAX_BUFFER_SIZE, currently set to 64k) for the legacy
wrappers and by using unsigned int for max_septets.
In addition, there are tests now that check the return values of
legacy encoding and decoding.

Sponsored-by: On-Waves ehf
diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c
index 2c9d8d8..755b321 100644
--- a/tests/sms/sms_test.c
+++ b/tests/sms/sms_test.c
@@ -280,6 +280,17 @@
 
 	/* test 7-bit encoding */
 	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));
 		septet_length = gsm_7bit_encode_n(coded, sizeof(coded),
 			       			  (const char *) test_encode[i].input,
@@ -296,6 +307,7 @@
 		OSMO_ASSERT (octets_written == test_encode[i].expected_octet_length);
 		OSMO_ASSERT (octets_written == computed_octet_length);
 		OSMO_ASSERT (memcmp(coded, test_encode[i].expected, octets_written) == 0);
+		OSMO_ASSERT (septet_length == test_encode[i].expected_septet_length);
 
 		/* check buffer limiting */
 		memset(coded, 0xaa, sizeof(coded));
@@ -357,6 +369,16 @@
 
 	/* test 7-bit decoding */
 	for (i = 0; i < ARRAY_SIZE(test_decode); ++i) {
+		/* Test legacy function (return value only) */
+		if (!test_decode[i].ud_hdr_ind) {
+			nchars = gsm_7bit_decode(result, test_decode[i].input,
+						 test_decode[i].expected_septet_length);
+			printf("Legacy decode case %d: "
+			       "return value %d (expected %d)\n",
+			       i, nchars, test_decode[i].expected_septet_length);
+		}
+
+		/* Test new function */
 		memset(result, 0x42, sizeof(result));
 		nchars = gsm_7bit_decode_n_hdr(result, sizeof(result), test_decode[i].input,
 				test_decode[i].expected_septet_length, test_decode[i].ud_hdr_ind);