From 17baa2715d688e5ad8065b9e38170078e762fa0a Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Sat, 20 Oct 2018 09:48:08 -0700 Subject: style: move getService into anonymous namespace Move getService into an anonymous namespace. Change-Id: I75df449858bdc8347fafe3c0ab839ff18b5a2496 Signed-off-by: Patrick Venture --- writefrudata.cpp | 66 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/writefrudata.cpp b/writefrudata.cpp index 42ebd67..130f30f 100644 --- a/writefrudata.cpp +++ b/writefrudata.cpp @@ -105,6 +105,39 @@ std::string getFRUValue(const std::string& section, const std::string& key, return fruValue; } +// Get the inventory service from the mapper. +auto getService(sdbusplus::bus::bus& bus, const std::string& intf, + const std::string& path) +{ + auto mapperCall = + bus.new_method_call("xyz.openbmc_project.ObjectMapper", + "/xyz/openbmc_project/object_mapper", + "xyz.openbmc_project.ObjectMapper", "GetObject"); + + mapperCall.append(path); + mapperCall.append(std::vector({intf})); + std::map> mapperResponse; + + try + { + auto mapperResponseMsg = bus.call(mapperCall); + mapperResponseMsg.read(mapperResponse); + } + catch (const sdbusplus::exception::SdBusError& ex) + { + log("Exception from sdbus call", + entry("WHAT=%s", ex.what())); + throw; + } + + if (mapperResponse.begin() == mapperResponse.end()) + { + throw std::runtime_error("ERROR in reading the mapper response"); + } + + return mapperResponse.begin()->first; +} + } // namespace //---------------------------------------------------------------- @@ -282,39 +315,6 @@ int verify_fru_data(const uint8_t* data, const size_t len) return EXIT_SUCCESS; } -// Get the inventory service from the mapper. -auto getService(sdbusplus::bus::bus& bus, const std::string& intf, - const std::string& path) -{ - auto mapperCall = - bus.new_method_call("xyz.openbmc_project.ObjectMapper", - "/xyz/openbmc_project/object_mapper", - "xyz.openbmc_project.ObjectMapper", "GetObject"); - - mapperCall.append(path); - mapperCall.append(std::vector({intf})); - std::map> mapperResponse; - - try - { - auto mapperResponseMsg = bus.call(mapperCall); - mapperResponseMsg.read(mapperResponse); - } - catch (const sdbusplus::exception::SdBusError& ex) - { - log("Exception from sdbus call", - entry("WHAT=%s", ex.what())); - throw; - } - - if (mapperResponse.begin() == mapperResponse.end()) - { - throw std::runtime_error("ERROR in reading the mapper response"); - } - - return mapperResponse.begin()->first; -} - //------------------------------------------------------------------------ // Takes FRU data, invokes Parser for each fru record area and updates // Inventory -- cgit v1.2.1