aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-03-19 16:39:10 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2019-03-24 16:49:07 +0000
commit83e311fa3e651e882e8648684dfe9efbce2b9bf4 (patch)
tree6553a3209f1ababa69aadc6a39eddccd69f5dd16
parent8fa2dbe5b1c69bf2c481c9893bc88675bdfb0ede (diff)
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
-rw-r--r--src/libvlr/vlr.c14
1 files changed, 5 insertions, 9 deletions
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 @@ uint32_t vlr_timer(struct vlr_instance *vlr, uint32_t timer)
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;
}