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
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/31496 )
Change subject: utils: use built-in static_assert() if available
......................................................................
Patch Set 1:
(3 comments)
File include/osmocom/core/utils.h:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-3976):
https://gerrit.osmocom.org/c/libosmocore/+/31496/comment/6abd79f2_349a09ac
PS1, Line 88: #define osmo_static_assert(exp, name) \
macros should not use a trailing semicolon
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-3976):
https://gerrit.osmocom.org/c/libosmocore/+/31496/comment/865b4847_d2b24a07
PS1, Line 89: typedef int dummy##name [(exp) ? 1 : -1] __attribute__((__unused__));
do not add new typedefs
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-3976):
https://gerrit.osmocom.org/c/libosmocore/+/31496/comment/577f7fcd_1faf421e
PS1, Line 89: typedef int dummy##name [(exp) ? 1 : -1] __attribute__((__unused__));
space prohibited before open square bracket '['
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/31496
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I5ca34bc14c05e8c38c721d7df33feb1c6c41c76e
Gerrit-Change-Number: 31496
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Fri, 24 Feb 2023 12:10:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/31495 )
Change subject: gsm: use OSMO_ASSERT() in osmo_iuup_msgb_alloc_c()
......................................................................
gsm: use OSMO_ASSERT() in osmo_iuup_msgb_alloc_c()
This patch is a preparation for the upcoming change making use of
the built-in static_assert(), which is available since C11.
When using built-in static_assert(), gcc v12.2.1 fails:
iuup.c: In function 'osmo_iuup_msgb_alloc_c':
iuup.c:194:33: error: expression in static assertion is not constant
194 | osmo_static_assert(size > IUUP_MSGB_HEADROOM_MIN_REQUIRED, iuup_msgb_alloc_headroom_bigger);
../../include/osmocom/core/utils.h:86:24: note: in definition of macro 'osmo_static_assert'
86 | static_assert((exp), "(" #exp ") failed")
| ^~~
This one is not really a *static* assert(), because it operates on the
user supplied argument 'size', which is not guaranteed to be an integer
literal. Neither it triggers a compilation failure as expected, nor
does it abort at run-time. It simply does nothing.
Change-Id: I53db679728250e0c60ed277efb18142073ffe9c4
---
M src/gsm/iuup.c
1 file changed, 27 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/95/31495/1
diff --git a/src/gsm/iuup.c b/src/gsm/iuup.c
index c6a575e..16a6f5e 100644
--- a/src/gsm/iuup.c
+++ b/src/gsm/iuup.c
@@ -191,7 +191,7 @@
#define IUUP_MSGB_HEADROOM_MIN_REQUIRED (OSMO_MAX(sizeof(struct osmo_iuup_tnl_prim), sizeof(struct osmo_iuup_rnl_prim)) + (PTR_ALIGNMENT_BYTES - 1))
static inline struct msgb *osmo_iuup_msgb_alloc_c(void *ctx, size_t size)
{
- osmo_static_assert(size > IUUP_MSGB_HEADROOM_MIN_REQUIRED, iuup_msgb_alloc_headroom_bigger);
+ OSMO_ASSERT(size > IUUP_MSGB_HEADROOM_MIN_REQUIRED);
return msgb_alloc_headroom_c(ctx, size, IUUP_MSGB_HEADROOM_MIN_REQUIRED, "iuup-msgb");
}
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/31495
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I53db679728250e0c60ed277efb18142073ffe9c4
Gerrit-Change-Number: 31495
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/31494 )
Change subject: msgb: use OSMO_ASSERT in msgb_alloc_headroom[_c]()
......................................................................
msgb: use OSMO_ASSERT in msgb_alloc_headroom[_c]()
This patch is a preparation for the upcoming change making use of
the built-in static_assert(), which is available since C11.
When using built-in static_assert(), gcc v12.2.1 fails:
include/osmocom/core/msgb.h: In function 'msgb_alloc_headroom_c':
include/osmocom/core/msgb.h:532:33: error: expression in static assertion is not constant
532 | osmo_static_assert(size >= headroom, headroom_bigger);
include/osmocom/core/utils.h:86:24: note: in definition of macro 'osmo_static_assert'
86 | static_assert((exp), "(" #exp ") failed")
| ^~~
include/osmocom/core/msgb.h: In function 'msgb_alloc_headroom':
include/osmocom/core/msgb.h:554:33: error: expression in static assertion is not constant
554 | osmo_static_assert(size >= headroom, headroom_bigger);
include/osmocom/core/utils.h:86:24: note: in definition of macro 'osmo_static_assert'
86 | static_assert((exp), "(" #exp ") failed")
| ^~~
These are not really *static* assert()s, because they operate on the
user supplied arguments 'size' and 'headroom', which are not guaranteed
to be integer literals. Neither they trigger compilation failures
as expected, nor do they abort at run-time. They simply do nothing.
Change-Id: I17ef4f3283ce20a5b452b7874c826acfb02a0123
---
M include/osmocom/core/msgb.h
1 file changed, 34 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/94/31494/1
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 3fdb189..2529c0e 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -529,7 +529,7 @@
static inline struct msgb *msgb_alloc_headroom_c(const void *ctx, uint16_t size, uint16_t headroom,
const char *name)
{
- osmo_static_assert(size >= headroom, headroom_bigger);
+ OSMO_ASSERT(size >= headroom);
struct msgb *msg = msgb_alloc_c(ctx, size, name);
if (OSMO_LIKELY(msg))
@@ -551,7 +551,7 @@
static inline struct msgb *msgb_alloc_headroom(uint16_t size, uint16_t headroom,
const char *name)
{
- osmo_static_assert(size >= headroom, headroom_bigger);
+ OSMO_ASSERT(size >= headroom);
struct msgb *msg = msgb_alloc(size, name);
if (OSMO_LIKELY(msg))
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/31494
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I17ef4f3283ce20a5b452b7874c826acfb02a0123
Gerrit-Change-Number: 31494
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/31496 )
Change subject: utils: use built-in static_assert() if available
......................................................................
utils: use built-in static_assert() if available
Static assertion is part of the C language since C11. It produces
more readable [user supplied] error messages than:
error: size of array ‘dummy_foo_bar’ is negative
and is generally smarter than the current osmo_static_assert()
implementation as it would fail when non-constant expression is
given, whereas osmo_static_assert() would have no effect at all.
See also https://en.cppreference.com/w/c/language/_Static_assert.
Change-Id: I5ca34bc14c05e8c38c721d7df33feb1c6c41c76e
---
M include/osmocom/core/utils.h
1 file changed, 29 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/96/31496/1
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index ee7cfa4..482babc 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
+#include <assert.h>
#include <osmocom/core/backtrace.h>
#include <osmocom/core/talloc.h>
@@ -79,7 +80,14 @@
char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len) __attribute__((__deprecated__));
-#define osmo_static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1] __attribute__((__unused__));
+#ifdef static_assert
+/* static_assert() is available in C11 or later */
+#define osmo_static_assert(exp, _name) \
+ static_assert((exp), "(" #exp ")")
+#else
+#define osmo_static_assert(exp, name) \
+ typedef int dummy##name [(exp) ? 1 : -1] __attribute__((__unused__));
+#endif
void osmo_str2lower(char *out, const char *in)
OSMO_DEPRECATED("Use osmo_str_tolower() or osmo_str_tolower_buf() instead,"
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/31496
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I5ca34bc14c05e8c38c721d7df33feb1c6c41c76e
Gerrit-Change-Number: 31496
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange
Attention is currently required from: dexter.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/31456 )
Change subject: i460_mux: add define constant for maximum number of subchannels
......................................................................
Patch Set 6: Code-Review+1
(1 comment)
Patchset:
PS6:
since the struct with the array is public, anyone could already do ARRAY_SIZE of that array. But well, it doesn't hurt to have a #define.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/31456
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id3a3782927c7dcbc873223d56129f291c04fee26
Gerrit-Change-Number: 31456
Gerrit-PatchSet: 6
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 24 Feb 2023 12:02:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: msuraev, dexter.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/31454 )
Change subject: trau_pcu_ericsson: add testvectors for MCS1-MCS8
......................................................................
Patch Set 2: Code-Review+1
(1 comment)
Patchset:
PS2:
I think it would have made sense to write a function rather than copy+pasting code in the first place - but I don't think it's worth spending even more time on rewriting it now.
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/31454
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I7e7e35930a373c9db74faef24f6c404eb5516278
Gerrit-Change-Number: 31454
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: msuraev <msuraev(a)sysmocom.de>
Gerrit-Attention: msuraev <msuraev(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 24 Feb 2023 12:01:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment