Change in libosmocore[master]: gsm: gsm_utils: Fix return type of API ms_class_gmsk_dbm() and add un...

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/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Nov 6 04:55:16 UTC 2019


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/15924 )

Change subject: gsm: gsm_utils: Fix return type of API ms_class_gmsk_dbm() and add unit tests
......................................................................

gsm: gsm_utils: Fix return type of API ms_class_gmsk_dbm() and add unit tests

Only known user of API is in osmocom-bb and it compiles fine after the
change.

Related: OS#4244
Change-Id: Ia10345008b3aca50b30482ef3b852b03eca71995
---
M include/osmocom/gsm/gsm_utils.h
M src/gsm/gsm_utils.c
M tests/gsm0408/gsm0408_test.c
3 files changed, 23 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h
index 38a3f6e..de63434 100644
--- a/include/osmocom/gsm/gsm_utils.h
+++ b/include/osmocom/gsm/gsm_utils.h
@@ -115,8 +115,7 @@
 uint8_t gsm_get_octet_len(const uint8_t sept_len);
 int gsm_7bit_decode_n_hdr(char *decoded, size_t n, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind);
 
-unsigned int ms_class_gmsk_dbm(enum gsm_band band, int ms_class);
-
+int ms_class_gmsk_dbm(enum gsm_band band, int ms_class);
 int ms_pwr_ctl_lvl(enum gsm_band band, unsigned int dbm);
 int ms_pwr_dbm(enum gsm_band band, uint8_t lvl);
 
diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c
index 365920f..ae77a9d 100644
--- a/src/gsm/gsm_utils.c
+++ b/src/gsm/gsm_utils.c
@@ -501,8 +501,8 @@
 /*! Convert power class to dBm according to GSM TS 05.05
  *  \param[in] band GSM frequency band
  *  \param[in] class GSM power class
- *  \returns maximum transmit power of power class in dBm */
-unsigned int ms_class_gmsk_dbm(enum gsm_band band, int class)
+ *  \returns maximum transmit power of power class in dBm, negative on error */
+int ms_class_gmsk_dbm(enum gsm_band band, int class)
 {
 	switch (band) {
 	case GSM_BAND_450:
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 2488024..9617823 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -1136,6 +1136,7 @@
 static void test_power_ctrl()
 {
 	int8_t rc8;
+	int rc;
 
 	rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_850, 0x00);
 	VERIFY(rc8, ==, 1);
@@ -1153,6 +1154,25 @@
 	VERIFY(rc8, <, 0);
 	rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_900, 0xf2);
 	VERIFY(rc8, <, 0);
+
+	rc = ms_class_gmsk_dbm(GSM_BAND_850, 0);
+	VERIFY(rc, <, 0);
+	rc = ms_class_gmsk_dbm(GSM_BAND_850, 1);
+	VERIFY(rc, ==, 43);
+	rc = ms_class_gmsk_dbm(GSM_BAND_900, 3);
+	VERIFY(rc, ==, 37);
+	rc = ms_class_gmsk_dbm(GSM_BAND_1800, 2);
+	VERIFY(rc, ==, 24);
+	rc = ms_class_gmsk_dbm(GSM_BAND_1800, 3);
+	VERIFY(rc, ==, 36);
+	rc = ms_class_gmsk_dbm(GSM_BAND_1900, 3);
+	VERIFY(rc, ==, 33);
+	rc = ms_class_gmsk_dbm(GSM_BAND_1900, 4);
+	VERIFY(rc, <, 0);
+	rc = ms_class_gmsk_dbm(GSM_BAND_900, 5);
+	VERIFY(rc, ==, 29);
+	rc = ms_class_gmsk_dbm(GSM_BAND_900, 6);
+	VERIFY(rc, <, 0);
 }
 
 int main(int argc, char **argv)

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15924
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ia10345008b3aca50b30482ef3b852b03eca71995
Gerrit-Change-Number: 15924
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191106/4349144f/attachment.htm>


More information about the gerrit-log mailing list