fixeria submitted this change.
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(-)
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 change 42509. To unsubscribe, or for help writing mail filters, visit settings.