prefer std::format over fmt

Now that std::format is implemented we aren't using complex enough fmt
to warrant using it over the std version.  Switch to std and remove the
dependency.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ib03cdb6a9db4d25de345bdb49b28157880c19bc1
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index bfa8ff8..189f2de 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -6,9 +6,6 @@
 #include "xyz/openbmc_project/Common/error.hpp"
 #include "xyz/openbmc_project/State/Shutdown/Power/error.hpp"
 
-#include <fmt/format.h>
-#include <fmt/printf.h>
-
 #include <cereal/archives/json.hpp>
 #include <org/freedesktop/UPower/Device/client.hpp>
 #include <phosphor-logging/elog-errors.hpp>
@@ -22,6 +19,7 @@
 #include <xyz/openbmc_project/State/Decorator/PowerSystemInputs/server.hpp>
 
 #include <filesystem>
+#include <format>
 #include <fstream>
 
 namespace phosphor
@@ -76,10 +74,10 @@
 {
     systemdTargetTable = {
         // Use the hard off target to ensure we shutdown immediately
-        {Transition::Off, fmt::format(CHASSIS_STATE_HARD_POWEROFF_TGT_FMT, id)},
-        {Transition::On, fmt::format(CHASSIS_STATE_POWERON_TGT_FMT, id)},
+        {Transition::Off, std::format(CHASSIS_STATE_HARD_POWEROFF_TGT_FMT, id)},
+        {Transition::On, std::format(CHASSIS_STATE_POWERON_TGT_FMT, id)},
         {Transition::PowerCycle,
-         fmt::format(CHASSIS_STATE_POWERCYCLE_TGT_FMT, id)}};
+         std::format(CHASSIS_STATE_POWERCYCLE_TGT_FMT, id)}};
 }
 
 // TODO - Will be rewritten once sdbusplus client bindings are in place
@@ -98,7 +96,7 @@
     powerSysInputsPropChangeSignal = std::make_unique<sdbusplus::bus::match_t>(
         bus,
         sdbusplus::bus::match::rules::propertiesChangedNamespace(
-            fmt::format(
+            std::format(
                 "/xyz/openbmc_project/power/power_supplies/chassis{}/psus", id),
             decoratorServer::PowerSystemInputs::interface),
         [this](auto& msg) { this->powerSysInputsChangeEvent(msg); });
@@ -142,12 +140,12 @@
 
                     // Reset host sensors since system is off now
                     // Ensure Power Leds are off.
-                    startUnit(fmt::format(CHASSIS_BLACKOUT_TGT_FMT, id));
+                    startUnit(std::format(CHASSIS_BLACKOUT_TGT_FMT, id));
 
                     setStateChangeTime();
                     // Generate file indicating AC loss occurred
                     std::string chassisLostPowerFileFmt =
-                        fmt::sprintf(CHASSIS_LOST_POWER_FILE, id);
+                        std::format(CHASSIS_LOST_POWER_FILE, id);
                     fs::create_directories(BASE_FILE_DIR);
                     fs::path chassisPowerLossFile{chassisLostPowerFileFmt};
                     std::ofstream outfile(chassisPowerLossFile);
@@ -222,7 +220,7 @@
             info("power status transitioned from {START_PWR_STATE} to Good and "
                  "chassis power is off, calling APR",
                  "START_PWR_STATE", initialPowerStatus);
-            restartUnit(fmt::format(AUTO_POWER_RESTORE_SVC_FMT, this->id));
+            restartUnit(std::format(AUTO_POWER_RESTORE_SVC_FMT, this->id));
         }
     }
 }
@@ -556,7 +554,7 @@
         return 0;
     }
 
-    if ((newStateUnit == fmt::format(CHASSIS_STATE_POWEROFF_TGT_FMT, id)) &&
+    if ((newStateUnit == std::format(CHASSIS_STATE_POWEROFF_TGT_FMT, id)) &&
         (newStateResult == "done") &&
         (!stateActive(systemdTargetTable[Transition::On])))
     {
@@ -577,13 +575,10 @@
         // This file is used to indicate to chassis related systemd services
         // that the chassis is already on and they should skip running.
         // Once the chassis state is back to on we can clear this file.
-        auto size = std::snprintf(nullptr, 0, CHASSIS_ON_FILE, 0);
-        size++; // null
-        std::unique_ptr<char[]> chassisFile(new char[size]);
-        std::snprintf(chassisFile.get(), size, CHASSIS_ON_FILE, 0);
-        if (std::filesystem::exists(chassisFile.get()))
+        auto chassisFile = std::format(CHASSIS_ON_FILE, 0);
+        if (std::filesystem::exists(chassisFile))
         {
-            std::filesystem::remove(chassisFile.get());
+            std::filesystem::remove(chassisFile);
         }
     }
 
@@ -654,7 +649,7 @@
 
 fs::path Chassis::serializePOH()
 {
-    fs::path path{fmt::format(POH_COUNTER_PERSIST_PATH, id)};
+    fs::path path{std::format(POH_COUNTER_PERSIST_PATH, id)};
     std::ofstream os(path.c_str(), std::ios::binary);
     cereal::JSONOutputArchive oarchive(os);
     oarchive(pohCounter());
@@ -663,7 +658,7 @@
 
 bool Chassis::deserializePOH(uint32_t& pohCounter)
 {
-    fs::path path{fmt::format(POH_COUNTER_PERSIST_PATH, id)};
+    fs::path path{std::format(POH_COUNTER_PERSIST_PATH, id)};
     try
     {
         if (fs::exists(path))
@@ -710,7 +705,7 @@
 
 void Chassis::serializeStateChangeTime()
 {
-    fs::path path{fmt::format(CHASSIS_STATE_CHANGE_PERSIST_PATH, id)};
+    fs::path path{std::format(CHASSIS_STATE_CHANGE_PERSIST_PATH, id)};
     std::ofstream os(path.c_str(), std::ios::binary);
     cereal::JSONOutputArchive oarchive(os);
 
@@ -720,7 +715,7 @@
 
 bool Chassis::deserializeStateChangeTime(uint64_t& time, PowerState& state)
 {
-    fs::path path{fmt::format(CHASSIS_STATE_CHANGE_PERSIST_PATH, id)};
+    fs::path path{std::format(CHASSIS_STATE_CHANGE_PERSIST_PATH, id)};
 
     try
     {