Change in osmo-msc[master]: vlr_subscr_name(): use OSMO_STRBUF

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
Tue Mar 19 15:43:27 UTC 2019


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/13322


Change subject: vlr_subscr_name(): use OSMO_STRBUF
......................................................................

vlr_subscr_name(): use OSMO_STRBUF

We now have a nicer way to compose strings in a buffer than this.
(Cosmetic preparation for inter-MSC handover patch.)

Change-Id: I7813068032475deb3850af05f7ba5a6f652e7fa2
---
M src/libvlr/vlr.c
1 file changed, 5 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/22/13322/1

diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index c5b3c80..cd4209d 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -84,33 +84,29 @@
 const char *vlr_subscr_name(const struct vlr_subscr *vsub)
 {
 	static char buf[128];
-	char imsi[23] = "";
-	char msisdn[25] = "";
-	char tmsi[23] = "";
-	char tmsi_new[23] = "";
+	struct osmo_strbuf sb = { .buf = buf, .len = sizeof(buf) };
 	bool present = false;
 	if (!vsub)
 		return "unknown";
 	if (vsub->imsi[0]) {
-		snprintf(imsi, sizeof(imsi), "IMSI-%s", vsub->imsi);
+		OSMO_STRBUF_PRINTF(sb, "IMSI-%s", vsub->imsi);
 		present = true;
 	}
 	if (vsub->msisdn[0]) {
-		snprintf(msisdn, sizeof(msisdn), "%sMSISDN-%s", present? ":" : "", vsub->msisdn);
+		OSMO_STRBUF_PRINTF(sb, "%sMSISDN-%s", present? ":" : "", vsub->msisdn);
 		present = true;
 	}
 	if (vsub->tmsi != GSM_RESERVED_TMSI) {
-		snprintf(tmsi, sizeof(tmsi), "%sTMSI-0x%08X", present? ":" : "", vsub->tmsi);
+		OSMO_STRBUF_PRINTF(sb, "%sTMSI-0x%08X", present? ":" : "", vsub->tmsi);
 		present = true;
 	}
 	if (vsub->tmsi_new != GSM_RESERVED_TMSI) {
-		snprintf(tmsi_new, sizeof(tmsi_new), "%sTMSInew-0x%08X", present? ":" : "", vsub->tmsi_new);
+		OSMO_STRBUF_PRINTF(sb, "%sTMSInew-0x%08X", present? ":" : "", vsub->tmsi_new);
 		present = true;
 	}
 	if (!present)
 		return "unknown";
 
-	snprintf(buf, sizeof(buf), "%s%s%s%s", imsi, msisdn, tmsi, tmsi_new);
 	return buf;
 }
 

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

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7813068032475deb3850af05f7ba5a6f652e7fa2
Gerrit-Change-Number: 13322
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190319/3e79a8b2/attachment.htm>


More information about the gerrit-log mailing list