used sdbusplus::unpackPropertiesNoThrow part 8

used sdbusplus::unpackPropertiesNoThrow in other places, also replaced
all usages of "GetAll" with sdbusplus::asio::getAllProperties

    bmcweb size: 2697640 -> 2685336 (-12304)
compressed size: 1129728 -> 1126078 (-3650)

Tested:
  - Executed redfish service validator, no new errors detected

Change-Id: I916e462e004fcbde67c209daef295de8f5fb68eb
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index b4d6433..47c5c91 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -21,6 +21,9 @@
 #include <dbus_utility.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
+#include <sdbusplus/asio/property.hpp>
+#include <sdbusplus/unpack_properties.hpp>
+#include <utils/dbus_utils.hpp>
 
 namespace redfish
 {
@@ -174,6 +177,49 @@
                 return;
             }
 
+            const std::string* manufacturer = nullptr;
+            const std::string* deviceType = nullptr;
+            const std::string* generationInUse = nullptr;
+
+            const bool success = sdbusplus::unpackPropertiesNoThrow(
+                dbus_utils::UnpackErrorPrinter(), pcieDevProperties,
+                "Manufacturer", manufacturer, "DeviceType", deviceType,
+                "GenerationInUse", generationInUse);
+
+            if (!success)
+            {
+                messages::internalError(asyncResp->res);
+                return;
+            }
+
+            if (generationInUse != nullptr)
+            {
+                std::optional<std::string> redfishGenerationInUse =
+                    redfishPcieGenerationFromDbus(*generationInUse);
+                if (!redfishGenerationInUse)
+                {
+                    messages::internalError(asyncResp->res);
+                    return;
+                }
+                if (redfishGenerationInUse->empty())
+                {
+                    // unknown, no need to handle
+                    return;
+                }
+                asyncResp->res.jsonValue["PCIeInterface"]["PCIeType"] =
+                    *redfishGenerationInUse;
+            }
+
+            if (manufacturer != nullptr)
+            {
+                asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
+            }
+
+            if (deviceType != nullptr)
+            {
+                asyncResp->res.jsonValue["DeviceType"] = *deviceType;
+            }
+
             asyncResp->res.jsonValue["@odata.type"] =
                 "#PCIeDevice.v1_4_0.PCIeDevice";
             asyncResp->res.jsonValue["@odata.id"] =
@@ -184,57 +230,12 @@
             asyncResp->res.jsonValue["PCIeFunctions"]["@odata.id"] =
                 "/redfish/v1/Systems/system/PCIeDevices/" + device +
                 "/PCIeFunctions";
-            for (const auto& property : pcieDevProperties)
-            {
-                const std::string* propertyString =
-                    std::get_if<std::string>(&property.second);
-                if (property.first == "Manufacturer")
-                {
-                    if (propertyString == nullptr)
-                    {
-                        messages::internalError(asyncResp->res);
-                        return;
-                    }
-                    asyncResp->res.jsonValue["Manufacturer"] = *propertyString;
-                }
-                if (property.first == "DeviceType")
-                {
-                    if (propertyString == nullptr)
-                    {
-                        messages::internalError(asyncResp->res);
-                        return;
-                    }
-                    asyncResp->res.jsonValue["DeviceType"] = *propertyString;
-                }
-                if (property.first == "GenerationInUse")
-                {
-                    if (propertyString == nullptr)
-                    {
-                        messages::internalError(asyncResp->res);
-                        return;
-                    }
-                    std::optional<std::string> generationInUse =
-                        redfishPcieGenerationFromDbus(*propertyString);
-                    if (!generationInUse)
-                    {
-                        messages::internalError(asyncResp->res);
-                        return;
-                    }
-                    if (generationInUse->empty())
-                    {
-                        // unknown, no need to handle
-                        return;
-                    }
-                    asyncResp->res.jsonValue["PCIeInterface"]["PCIeType"] =
-                        *generationInUse;
-                }
-            }
         };
         std::string escapedPath = std::string(pciePath) + "/" + device;
         dbus::utility::escapePathForDbus(escapedPath);
-        crow::connections::systemBus->async_method_call(
-            std::move(getPCIeDeviceCallback), pcieService, escapedPath,
-            "org.freedesktop.DBus.Properties", "GetAll", pcieDeviceInterface);
+        sdbusplus::asio::getAllProperties(
+            *crow::connections::systemBus, pcieService, escapedPath,
+            pcieDeviceInterface, std::move(getPCIeDeviceCallback));
         });
 }
 
@@ -320,9 +321,9 @@
         };
         std::string escapedPath = std::string(pciePath) + "/" + device;
         dbus::utility::escapePathForDbus(escapedPath);
-        crow::connections::systemBus->async_method_call(
-            std::move(getPCIeDeviceCallback), pcieService, escapedPath,
-            "org.freedesktop.DBus.Properties", "GetAll", pcieDeviceInterface);
+        sdbusplus::asio::getAllProperties(
+            *crow::connections::systemBus, pcieService, escapedPath,
+            pcieDeviceInterface, std::move(getPCIeDeviceCallback));
         });
 }
 
@@ -435,9 +436,9 @@
         };
         std::string escapedPath = std::string(pciePath) + "/" + device;
         dbus::utility::escapePathForDbus(escapedPath);
-        crow::connections::systemBus->async_method_call(
-            std::move(getPCIeDeviceCallback), pcieService, escapedPath,
-            "org.freedesktop.DBus.Properties", "GetAll", pcieDeviceInterface);
+        sdbusplus::asio::getAllProperties(
+            *crow::connections::systemBus, pcieService, escapedPath,
+            pcieDeviceInterface, std::move(getPCIeDeviceCallback));
         });
 }