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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Sun Mar 24 16:49:08 UTC 2019


Neels Hofmeyr has submitted this change and it was merged. ( 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(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: I7813068032475deb3850af05f7ba5a6f652e7fa2
Gerrit-Change-Number: 13322
Gerrit-PatchSet: 2
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190324/396858e4/attachment.html>


More information about the gerrit-log mailing list