Use s.c_str() in log messages
Fixes issues with data passed to phosphor::logging::log(entry()).
This is part of a series of commits that resolves openbmc 2905.
Tested: static_assert only
Change-Id: I9fac771f54e4acbec97ce1360c106b6e3eb4fe9d
Signed-off-by: Joseph Reynolds <jrey@us.ibm.com>
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index be3e27e..d4f0ff5 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -1110,7 +1110,7 @@
catch (std::exception& e)
{
log<level::INFO>("Failure to read power value from D-Bus object",
- entry("OBJECT_PATH=%s", objectPath),
+ entry("OBJECT_PATH=%s", objectPath.c_str()),
entry("INTERFACE=%s", SENSOR_VALUE_INTF));
}
return power;
diff --git a/host-interface.cpp b/host-interface.cpp
index 19ca291..8663929 100644
--- a/host-interface.cpp
+++ b/host-interface.cpp
@@ -57,7 +57,7 @@
log<level::DEBUG>("Pushing cmd on to queue",
entry("CONTROL_HOST_CMD=%s",
- convertForMessage(command)));
+ convertForMessage(command).c_str()));
auto cmd = std::make_tuple(ipmiCommand.at(command),
std::bind(&Host::commandStatusHandler,
diff --git a/read_fru_data.cpp b/read_fru_data.cpp
index a1bced9..5133612 100644
--- a/read_fru_data.cpp
+++ b/read_fru_data.cpp
@@ -55,8 +55,8 @@
{
//If property is not found simply return empty value
log<level::ERR>("Error in reading property values from inventory",
- entry("INTERFACE=%s", intf),
- entry("PATH=%s", objPath));
+ entry("INTERFACE=%s", intf.c_str()),
+ entry("PATH=%s", objPath.c_str()));
return properties;
}
reply.read(properties);
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index 20006dc..2d4ac3a 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -44,8 +44,8 @@
if (mapperResponseMsg.is_method_error())
{
log<level::ERR>("Mapper GetSubTree failed",
- entry("PATH=%s", path),
- entry("INTERFACE=%s", interface));
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACE=%s", interface.c_str()));
elog<InternalFailure>();
}
@@ -54,8 +54,8 @@
if (mapperResponse.empty())
{
log<level::ERR>("Invalid mapper response",
- entry("PATH=%s", path),
- entry("INTERFACE=%s", interface));
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACE=%s", interface.c_str()));
elog<InternalFailure>();
}
@@ -69,8 +69,8 @@
if (iter == mapperResponse.end())
{
log<level::ERR>("Couldn't find D-Bus path",
- entry("PATH=%s", path),
- entry("INTERFACE=%s", interface));
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACE=%s", interface.c_str()));
elog<InternalFailure>();
}
return std::make_pair(iter->first, iter->second.begin()->first);
diff --git a/softoff/softoff.cpp b/softoff/softoff.cpp
index f76cd4f..d76750a 100644
--- a/softoff/softoff.cpp
+++ b/softoff/softoff.cpp
@@ -86,9 +86,9 @@
else
{
log<level::INFO>("Timer started waiting for host to shutdown",
- entry("TIMEOUT_IN_MSEC=%llu",
- duration_cast<milliseconds>(seconds
- (IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS))));
+ entry("TIMEOUT_IN_MSEC=%llu",
+ (duration_cast<milliseconds>(seconds
+ (IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS))).count()));
}
}
else
diff --git a/transporthandler.cpp b/transporthandler.cpp
index bafeb16..98d9573 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -877,7 +877,7 @@
{
log<level::INFO>("Failed to get IP object which matches",
entry("INTERFACE=%s", ipmi::network::IP_INTERFACE),
- entry("MATCH=%s", ethIp));
+ entry("MATCH=%s", ethIp.c_str()));
}
auto systemProperties = ipmi::getAllDbusProperties(
diff --git a/utils.cpp b/utils.cpp
index 4f59f6c..bfe924c 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -543,7 +543,7 @@
if (rc <= 0)
{
log<level::ERR>("inet_pton failed:",
- entry("SUBNETMASK=%s", subnetMask));
+ entry("SUBNETMASK=%s", subnetMask.c_str()));
return 0;
}
@@ -556,7 +556,7 @@
else
{
log<level::ERR>("Invalid Mask",
- entry("SUBNETMASK=%s", subnetMask));
+ entry("SUBNETMASK=%s", subnetMask.c_str()));
return 0;
}
}