fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35313?usp=email )
Change subject: utils: improve readability of OSMO_STRBUF_CHAR_COUNT
......................................................................
utils: improve readability of OSMO_STRBUF_CHAR_COUNT
Similarly to OSMO_STRBUF_REMAIN, let's improve the code readability
by adding a static inline function. We should generally prefer using
static inline functions over macros, unless there is something that
only the proprocessor can do.
Change-Id: I71f24b87c13fd83952029171a6993f8da5e32e5b
---
M include/osmocom/core/utils.h
1 file changed, 28 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/13/35313/1
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 973a9d0..9a6e6b2 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -297,11 +297,21 @@
#define OSMO_STRBUF_REMAIN(STRBUF) \
_osmo_strbuf_remain(&(STRBUF))
+/*! Get number of actual characters (without terminating nul) in the given struct osmo_strbuf.
+ * \param[in] sb the string buffer to get the number of characters for.
+ * \returns number of actual characters (without terminating nul). */
+static inline size_t _osmo_strbuf_char_count(const struct osmo_strbuf *sb)
+{
+ if (OSMO_UNLIKELY(sb == NULL || sb->buf == NULL))
+ return 0;
+ if (sb->pos == NULL || sb->pos <= sb->buf)
+ return 0;
+ return OSMO_MIN(sb->pos - sb->buf, sb->len - 1);
+}
+
/*! Return number of actual characters contained in struct osmo_strbuf (without terminating nul). */
-#define OSMO_STRBUF_CHAR_COUNT(STRBUF) ((STRBUF).buf && ((STRBUF).pos > (STRBUF).buf) ? \
- OSMO_MIN((STRBUF).pos - (STRBUF).buf, \
- (STRBUF).len - 1) \
- : 0)
+#define OSMO_STRBUF_CHAR_COUNT(STRBUF) \
+ _osmo_strbuf_char_count(&(STRBUF))
/*! Like OSMO_STRBUF_APPEND(), but for function signatures that return the char* buffer instead of a length.
* When using this function, the final STRBUF.chars_needed may not reflect the actual number of characters needed, since
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35313?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I71f24b87c13fd83952029171a6993f8da5e32e5b
Gerrit-Change-Number: 35313
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange
Attention is currently required from: neels.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-sip-connector/+/35308?usp=email )
Change subject: verbosely log MNCC and SDP
......................................................................
Patch Set 2:
(1 comment)
File src/mncc.c:
https://gerrit.osmocom.org/c/osmo-sip-connector/+/35308/comment/8c6b2b2b_ae…
PS2, Line 1059: Log about the received MNCC message
Given that this whole new code chunk is only for `LOGL_DEBUG` logging, I think it can be moved into a separate function and called conditionally `if (log_check_level(DMNCC, LOGL_DEBUG))`?
--
To view, visit https://gerrit.osmocom.org/c/osmo-sip-connector/+/35308?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-Change-Id: Ie923117929c6b79b1eb61e5a9f02a169edabc599
Gerrit-Change-Number: 35308
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 11 Dec 2023 06:19:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: jolly.
neels has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/35135?usp=email )
Change subject: Only check for intersecting AMR codec support on matching TS rate
......................................................................
Patch Set 1: Verified+1 Code-Review+2
(1 comment)
Patchset:
PS1:
nice! I verified that this patch now allows me to configure only AMR rate 12k2 in an all-TCH/F setup.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35135?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ia4a8e7f22dc652655ee7c5458624df8ae136dd95
Gerrit-Change-Number: 35135
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-Comment-Date: Mon, 11 Dec 2023 04:27:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35309?usp=email )
Change subject: logging: fix NULL pointer dereference in _output_buf()
......................................................................
logging: fix NULL pointer dereference in _output_buf()
In the _output_buf() we explicitly initialize only the 'buf' and 'len'
fields of the struct osmo_strbuf, leaving the 'pos' field implicitly
initialized to NULL. Later, in this function, 'sb.pos' is passed to
ctime_r() and strlen(), leading to a NULL pointer dereference (segfault)
in certain scenarios.
This situation can occur when color logging is disabled or when
a specific logging subsystem has no associated color. Any application
using libosmocore's logging API would crash with the following config:
log stderr
logging filter all 1
logging timestamp 1
logging color 0
Fix this by initializing the 'pos' field explicitly.
Change-Id: I7ec9badf525e03e54e10b725d820c636eaa3fd1c
Fixes: d71331bc "logging: fix nul octets in log output / use osmo_strbuf"
Fixes: CID#336550
---
M src/core/logging.c
1 file changed, 29 insertions(+), 1 deletion(-)
Approvals:
neels: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/core/logging.c b/src/core/logging.c
index 0d215f4..6941f9b 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -488,7 +488,7 @@
{
int ret;
const char *c_subsys = NULL;
- struct osmo_strbuf sb = { .buf = buf, .len = buf_len };
+ struct osmo_strbuf sb = { .buf = buf, .pos = buf, .len = buf_len };
/* safety net in case of encountering errors and returning nothing */
buf[0] = '\0';
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35309?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I7ec9badf525e03e54e10b725d820c636eaa3fd1c
Gerrit-Change-Number: 35309
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: manawyrm <osmocom.account(a)tbspace.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: merged
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/1627?usp=email )
Change subject: tests/conv: separate test logic
......................................................................
Patch Set 4:
(1 comment)
File tests/conv/conv.c:
https://gerrit.osmocom.org/c/libosmocore/+/1627/comment/3b257a42_c8f2d659
PS4, Line 42: return -1;
> Would it be possible to separate test code in Coverity from 'regular' code? I'd say that would make […]
Sorry for very late feedback. It's possible to exclude specific files or even directories from the analysis (in the project settings). But it's not like we're getting too much of those issues. For now I am fine with clicking "ignore" on such CIDs. Also, we may not see real bugs in tests if we exclude them.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/1627?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Idbdc7e19cb9b9a36cd1fccd621cd858e87530d98
Gerrit-Change-Number: 1627
Gerrit-PatchSet: 4
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: tnt <tnt(a)246tNt.com>
Gerrit-CC: arehbein <arehbein(a)sysmocom.de>
Gerrit-Comment-Date: Sun, 10 Dec 2023 17:03:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: arehbein <arehbein(a)sysmocom.de>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: comment