Change in libosmo-abis[master]: osmo_ortp: Log domain and fix strings without endl char

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

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue Nov 20 16:47:53 UTC 2018


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/11744 )

Change subject: osmo_ortp: Log domain and fix strings without endl char
......................................................................

osmo_ortp: Log domain and fix strings without endl char

Change-Id: Ib6df0df04cd6ba342753c84398274d04917ace40
---
M src/trau/osmo_ortp.c
1 file changed, 28 insertions(+), 1 deletion(-)

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



diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c
index d8f4abf..0eb1661 100644
--- a/src/trau/osmo_ortp.c
+++ b/src/trau/osmo_ortp.c
@@ -102,8 +102,35 @@
 #endif
 	OrtpLogLevel lev, const char *fmt, va_list args)
 {
+	/* Some strings coming from ortp are not endline terminated and mangle
+	 * the output. Make sure all strings are endl terminated before
+	 * printing.
+	 */
+	int needs_endl;
+	const char *domain_str;
+	char *str;
+	size_t fmt_len = strlen(fmt);
+#if HAVE_ORTP_LOG_DOMAIN
+	/* domain can be NULL, found experimentally */
+	domain_str = domain ? : "";
+#else
+	domain_str = "";
+#endif
+	size_t  domain_len = strlen(domain_str);
+
+	if (fmt_len == 0)
+		return;
+
+	needs_endl = fmt[fmt_len - 1] != '\n' ? 1 : 0;
+
+	str = osmo_ortp_malloc(domain_len + 2 /*": "*/ + fmt_len + needs_endl + 1);
+	sprintf(str, "%s%s%s%s", domain_str, domain_len ? ": " : "", fmt, needs_endl ? "\n" : "");
+
 	osmo_vlogp(DLMIB, ortp_to_osmo_lvl(lev), __FILE__, 0,
-		   0, fmt, args);
+		   0, str, args);
+
+	osmo_ortp_free(str);
+
 }
 
 /* ORTP signal callbacks */

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

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib6df0df04cd6ba342753c84398274d04917ace40
Gerrit-Change-Number: 11744
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181120/eb2fc19e/attachment.htm>


More information about the gerrit-log mailing list