From 510eb9cc13a9437f9fc4965c080be8136d5e1320 Mon Sep 17 00:00:00 2001 From: Joseph Reynolds Date: Wed, 30 May 2018 11:51:28 -0500 Subject: 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 --- dcmihandler.cpp | 2 +- host-interface.cpp | 2 +- read_fru_data.cpp | 4 ++-- sensordatahandler.cpp | 12 ++++++------ softoff/softoff.cpp | 6 +++--- transporthandler.cpp | 2 +- utils.cpp | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dcmihandler.cpp b/dcmihandler.cpp index be3e27e..d4f0ff5 100644 --- a/dcmihandler.cpp +++ b/dcmihandler.cpp @@ -1110,7 +1110,7 @@ int64_t getPowerReading(sdbusplus::bus::bus& bus) catch (std::exception& e) { log("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 @@ void Host::execute(Base::Host::Command command) log("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 @@ ipmi::PropertyMap readAllProperties(const std::string& intf, { //If property is not found simply return empty value log("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 @@ ServicePath getServiceAndPath(sdbusplus::bus::bus& bus, if (mapperResponseMsg.is_method_error()) { log("Mapper GetSubTree failed", - entry("PATH=%s", path), - entry("INTERFACE=%s", interface)); + entry("PATH=%s", path.c_str()), + entry("INTERFACE=%s", interface.c_str())); elog(); } @@ -54,8 +54,8 @@ ServicePath getServiceAndPath(sdbusplus::bus::bus& bus, if (mapperResponse.empty()) { log("Invalid mapper response", - entry("PATH=%s", path), - entry("INTERFACE=%s", interface)); + entry("PATH=%s", path.c_str()), + entry("INTERFACE=%s", interface.c_str())); elog(); } @@ -69,8 +69,8 @@ ServicePath getServiceAndPath(sdbusplus::bus::bus& bus, if (iter == mapperResponse.end()) { log("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(); } 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 @@ void SoftPowerOff::hostControlEvent(sdbusplus::message::message& msg) else { log("Timer started waiting for host to shutdown", - entry("TIMEOUT_IN_MSEC=%llu", - duration_cast(seconds - (IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS)))); + entry("TIMEOUT_IN_MSEC=%llu", + (duration_cast(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 @@ void applyChanges(int channel) { log("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 @@ uint8_t toPrefix(int addressFamily, const std::string& subnetMask) if (rc <= 0) { log("inet_pton failed:", - entry("SUBNETMASK=%s", subnetMask)); + entry("SUBNETMASK=%s", subnetMask.c_str())); return 0; } @@ -556,7 +556,7 @@ uint8_t toPrefix(int addressFamily, const std::string& subnetMask) else { log("Invalid Mask", - entry("SUBNETMASK=%s", subnetMask)); + entry("SUBNETMASK=%s", subnetMask.c_str())); return 0; } } -- cgit v1.2.1