fixeria has submitted this change. (
https://gerrit.osmocom.org/c/libosmocore/+/31491 )
Change subject: gsm: ensure completeness of osmo_bts_features_{descs,names}[]
......................................................................
gsm: ensure completeness of osmo_bts_features_{descs,names}[]
It already happened several times [1][2] that new features were added
to enum osmo_bts_features, but the osmo_bts_features_{descs,names}[]
were left unchanged. Let's add static_assert()s to prevent this.
Change-Id: I8e3b7d3996e9f3e16c6d4e0d1d406fa538d5e9be
Related: [1] f4f5d54ea2cb47a51aeaec2b5fb990664755900a
Related: [2] 18c6a8183f92915e77368ecffb1cbf7f555453a3
---
M include/osmocom/gsm/bts_features.h
M src/gsm/bts_features.c
2 files changed, 23 insertions(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
msuraev: Looks good to me, but someone else must approve
dexter: Looks good to me, approved
diff --git a/include/osmocom/gsm/bts_features.h b/include/osmocom/gsm/bts_features.h
index d6eb246..cf1db4a 100644
--- a/include/osmocom/gsm/bts_features.h
+++ b/include/osmocom/gsm/bts_features.h
@@ -7,7 +7,7 @@
/* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to
avoid breaking compatibility
with BTS compiled against earlier version of this header. Also make sure that the
description strings
- osmo_bts_features_descs[] in gsm_data.c are also updated accordingly! */
+ osmo_bts_features_{descs,names}[] in bts_features.c are also updated accordingly! */
enum osmo_bts_features {
BTS_FEAT_HSCSD,
BTS_FEAT_GPRS,
diff --git a/src/gsm/bts_features.c b/src/gsm/bts_features.c
index 1e041c7..b6cd82e 100644
--- a/src/gsm/bts_features.c
+++ b/src/gsm/bts_features.c
@@ -16,6 +16,7 @@
* GNU General Public License for more details.
*/
+#include <osmocom/core/utils.h>
#include <osmocom/gsm/bts_features.h>
const struct value_string osmo_bts_features_descs[] = {
@@ -49,6 +50,9 @@
{ 0, NULL }
};
+/* Ensure that all BTS_FEAT_* entries are present in osmo_bts_features_descs[] */
+osmo_static_assert(ARRAY_SIZE(osmo_bts_features_descs) == _NUM_BTS_FEAT + 1,
_bts_features_descs);
+
/*! return description string of a BTS feature (osmo_bts_features_descs).
* To get the plain feature name, use osmo_bts_features_name() instead. */
const char *osmo_bts_feature_name(enum osmo_bts_features feature)
@@ -86,3 +90,6 @@
{ BTS_FEAT_VGCS, "VGCS" },
{}
};
+
+/* Ensure that all BTS_FEAT_* entries are present in osmo_bts_features_names[] */
+osmo_static_assert(ARRAY_SIZE(osmo_bts_features_names) == _NUM_BTS_FEAT + 1,
_bts_features_names);
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/31491
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8e3b7d3996e9f3e16c6d4e0d1d406fa538d5e9be
Gerrit-Change-Number: 31491
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: msuraev <msuraev(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: merged