[S] Change in libosmo-sigtran[master]: osmo_ss7_route_print(): Use osmo_ss7_pointcode_print_buf()
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40541?usp=email ) Change subject: osmo_ss7_route_print(): Use osmo_ss7_pointcode_print_buf() ...................................................................... osmo_ss7_route_print(): Use osmo_ss7_pointcode_print_buf() Use the _buf() API here since it's easy and then we can make sure a user calling this function + osmo_ss7_pointcode_print() at the same time won't cause collisions writing in the same static buffer. Change-Id: I6a6104e2cc759e79afa6da57d512e6f8436bbb33 --- M src/ss7_route.c 1 file changed, 7 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/41/40541/1 diff --git a/src/ss7_route.c b/src/ss7_route.c index 7783f85..6350f71 100644 --- a/src/ss7_route.c +++ b/src/ss7_route.c @@ -263,16 +263,19 @@ const char *osmo_ss7_route_print(const struct osmo_ss7_route *rt) { + static char buf[64]; + struct osmo_strbuf sb = { .buf = buf, .len = sizeof(buf) }; + char buf_pc[MAX_PC_STR_LEN]; const struct osmo_ss7_instance *inst = rt->rtable->inst; unsigned int pc_width = osmo_ss7_pc_width(&inst->cfg.pc_fmt); - static char buf[64]; int rc = u32_masklen(rt->cfg.mask, pc_width); + OSMO_STRBUF_PRINTF(sb, "%s/", osmo_ss7_pointcode_print_buf(buf_pc, sizeof(buf_pc), inst, rt->cfg.pc)); + if (rc < 0) - snprintf(buf, sizeof(buf), "%s/%s", osmo_ss7_pointcode_print(inst, rt->cfg.pc), - osmo_ss7_pointcode_print2(inst, rt->cfg.mask)); + OSMO_STRBUF_PRINTF(sb, "%s", osmo_ss7_pointcode_print_buf(buf_pc, sizeof(buf_pc), inst, rt->cfg.mask)); else - snprintf(buf, sizeof(buf), "%s/%u", osmo_ss7_pointcode_print(inst, rt->cfg.pc), rc); + OSMO_STRBUF_PRINTF(sb, "%u", rc); return buf; } -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40541?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I6a6104e2cc759e79afa6da57d512e6f8436bbb33 Gerrit-Change-Number: 40541 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin@sysmocom.de>
participants (1)
-
pespin