Use s.c_str() in log messages
Partly resolves openbmc/openbmc 2905
Bonus! The new static_assert found a related bug in log.cpp:
log("msg", entry("fmt", data, entry("fmt", data)))
which should have been:
log("msg", entry("fmt", data), entry("fmt", data))
Tested: static_assert only
Change-Id: Ie1c550a27f454ef92ee096d812adcc400a1a25cf
Signed-off-by: Joseph Reynolds <jrey@us.ibm.com>
diff --git a/util.cpp b/util.cpp
index c4e989a..9527426 100644
--- a/util.cpp
+++ b/util.cpp
@@ -57,7 +57,7 @@
if (sscanf(str.c_str(), "%hx", &buff) <= 0)
{
log<level::ERR>("Invalid Mask",
- entry("SUBNETMASK=%s", subnetMask));
+ entry("SUBNETMASK=%s", subnetMask.c_str()));
return 0;
}
@@ -72,7 +72,7 @@
if (((sizeof(buff) * 8) - (__builtin_ctz(buff))) != __builtin_popcount(buff))
{
log<level::ERR>("Invalid Mask",
- entry("SUBNETMASK=%s", subnetMask));
+ entry("SUBNETMASK=%s", subnetMask.c_str()));
return 0;
}
@@ -101,7 +101,7 @@
if (rc <= 0)
{
log<level::ERR>("inet_pton failed:",
- entry("SUBNETMASK=%s", subnetMask));
+ entry("SUBNETMASK=%s", subnetMask.c_str()));
return 0;
}
@@ -114,7 +114,7 @@
else
{
log<level::ERR>("Invalid Mask",
- entry("SUBNETMASK=%s", subnetMask));
+ entry("SUBNETMASK=%s", subnetMask.c_str()));
return 0;
}
}
@@ -384,8 +384,8 @@
if(status < 0)
{
log<level::ERR>("Unable to delete the interface",
- entry("INTF=%s", intf.c_str(),
- entry("STATUS=%d", status)));
+ entry("INTF=%s", intf.c_str()),
+ entry("STATUS=%d", status));
elog<InternalFailure>();
}
}
@@ -473,8 +473,8 @@
}
log<level::ERR>("Unable to execute the command",
- entry("CMD=%s", command.c_str(),
- entry("STATUS=%d", status)));
+ entry("CMD=%s", command.c_str()),
+ entry("STATUS=%d", status));
elog<InternalFailure>();
}
}