[MERGED] openbsc[master]: fix build: gprs_ra_id_by_bts(): ensure to init all values

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Mar 5 20:35:59 UTC 2018


Neels Hofmeyr has submitted this change and it was merged.

Change subject: fix build: gprs_ra_id_by_bts(): ensure to init all values
......................................................................


fix build: gprs_ra_id_by_bts(): ensure to init all values

After recent libosmocore commit "implement support for 3-digit MNC with leading
zeros" c4fce1425e19d604c199c895e227dc2519110456
Id2240f7f518494c9df6c8bda52c0d5092f90f221, struct gprs_ra_id has a new member,
namely mnc_3_digits. In gprs_ra_id_by_bts(), this new member is now not
initialized and may end up having an arbitrary value, which then may amount to
mnc_3_digits == true. Hence the resulting BCD representation of the MCC-MNC may
inadvertently and randomly indicate a leading zero on the MNC.

Use a struct assignment so that all members are guaranteed to be set, and so
that mnc_3_digits will be zero in all cases.

Since above libosmocore commit, nanobts_omlattr_test fails "randomly", fixed by
this patch.

Change-Id: I5ae899f3c236b3b4feb5c8cf762e2f2d964dbc65
---
M openbsc/src/libcommon/gsm_data.c
1 file changed, 6 insertions(+), 4 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c
index 55d6fce..2028f05 100644
--- a/openbsc/src/libcommon/gsm_data.c
+++ b/openbsc/src/libcommon/gsm_data.c
@@ -338,10 +338,12 @@
 
 void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts)
 {
-	raid->mcc = bts->network->country_code;
-	raid->mnc = bts->network->network_code;
-	raid->lac = bts->location_area_code;
-	raid->rac = bts->gprs.rac;
+	*raid = (struct gprs_ra_id){
+		.mcc = bts->network->country_code,
+		.mnc = bts->network->network_code,
+		.lac = bts->location_area_code,
+		.rac = bts->gprs.rac,
+	};
 }
 
 int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts)

-- 
To view, visit https://gerrit.osmocom.org/7120
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5ae899f3c236b3b4feb5c8cf762e2f2d964dbc65
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list