pespin has submitted this change. ( 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(-)
Approvals: osmith: Looks good to me, but someone else must approve fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved
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; }