fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/42509?usp=email )


Change subject: phy_link: phy_{link,instance}_name(): fix shared static buffer
......................................................................

phy_link: phy_{link,instance}_name(): fix shared static buffer

Both functions were writing into the same static buffer, so any caller
holding a pointer returned by one and then invoking the other would
silently end up with a stale/overwritten string.  Move name_buf into
each function as a local static, so the two buffers are independent.

Change-Id: I79e9d7f5b1e5c275911cf88854211f1ce8a28669
---
M src/common/phy_link.c
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/09/42509/1

diff --git a/src/common/phy_link.c b/src/common/phy_link.c
index ee5ef8a..8f1e389 100644
--- a/src/common/phy_link.c
+++ b/src/common/phy_link.c
@@ -149,9 +149,9 @@
        talloc_free(plink);
 }

-static char name_buf[32];
 const char *phy_link_name(const struct phy_link *plink)
 {
+       static char name_buf[32];
        snprintf(name_buf, sizeof(name_buf), "phy%u", plink->num);
        return name_buf;
 }
@@ -182,6 +182,7 @@

 const char *phy_instance_name(const struct phy_instance *pinst)
 {
+       static char name_buf[32];
        snprintf(name_buf, sizeof(name_buf), "phy%u.%u", pinst->phy_link->num,
                 pinst->num);
        return name_buf;

--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/42509?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I79e9d7f5b1e5c275911cf88854211f1ce8a28669
Gerrit-Change-Number: 42509
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>

Reply via email to