Skip to content

Commit 2e22b23

Browse files
committed
Remove remaining fmt::format use
The only remaining use of the fmt::format library was for something std::format can't yet handle, printing ranges. This was only used twice, in the same file, so just manually build up the vectors in question into a string and use std::format. This was already being done in other places anyway. Now the fmt::format subproject and dependencies can be completely removed. An added benefit is that those two fmt::format calls were failing to build on my system when I was trying to build using subprojects, and without them everything works. Tested: Can still see the traces, though I only have a 1 element vector to test with: Adding fan target lock of 11300 on fans [fan0] zone 0", Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I90055e9d1c8d0b79b151e1cfd0af2052005cef3c
1 parent 023d2c7 commit 2e22b23

File tree

6 files changed

+23
-24
lines changed

6 files changed

+23
-24
lines changed

control/json/actions/override_fan_target.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
#include "action.hpp"
2121
#include "group.hpp"
2222

23-
#include <fmt/format.h>
24-
#include <fmt/ranges.h>
25-
2623
#include <nlohmann/json.hpp>
2724

25+
#include <format>
26+
2827
namespace phosphor::fan::control::json
2928
{
3029

@@ -83,8 +82,17 @@ void OverrideFanTarget::lockFans(Zone& zone)
8382
{
8483
if (!_locked)
8584
{
86-
record(fmt::format("Adding fan target lock of {} on fans {} zone {}",
87-
_target, _fans, zone.getName()));
85+
std::string fanList;
86+
if (!_fans.empty())
87+
{
88+
fanList = std::accumulate(std::next(_fans.begin()), _fans.end(),
89+
_fans[0], [](auto list, auto fan) {
90+
return std::move(list) + ", " + fan;
91+
});
92+
}
93+
94+
record(std::format("Adding fan target lock of {} on fans [{}] zone {}",
95+
_target, fanList, zone.getName()));
8896

8997
for (auto& fan : _fans)
9098
{
@@ -97,8 +105,16 @@ void OverrideFanTarget::lockFans(Zone& zone)
97105

98106
void OverrideFanTarget::unlockFans(Zone& zone)
99107
{
100-
record(fmt::format("Un-locking fan target {} on fans {} zone {}", _target,
101-
_fans, zone.getName()));
108+
std::string fanList;
109+
if (!_fans.empty())
110+
{
111+
fanList = std::accumulate(
112+
std::next(_fans.begin()), _fans.end(), _fans[0],
113+
[](auto list, auto fan) { return std::move(list) + ", " + fan; });
114+
}
115+
116+
record(std::format("Un-locking fan target {} on fans [{}] zone {}", _target,
117+
fanList, zone.getName()));
102118

103119
// unlock all fans in this instance
104120
for (auto& fan : _fans)

control/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ fanctl = executable(
100100
'fanctl.cpp',
101101
dependencies: [
102102
cli11_dep,
103-
fmt_dep,
104103
json_dep,
105104
phosphor_logging_dep,
106105
sdbusplus_dep,

meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ else
5252
json_dep = dependency('nlohmann_json')
5353
endif
5454

55-
fmt_dep = dependency('fmt')
56-
5755
phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
5856
phosphor_logging_dep = dependency('phosphor-logging')
5957
sdbusplus_dep = dependency('sdbusplus')

monitor/test/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ phosphor_fan_monitor_test_include_directories = include_directories(
33
)
44

55
test_deps=[
6-
fmt_dep,
76
gmock_dep,
87
gtest_dep,
98
json_dep,

subprojects/fmt.wrap

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ test_include_directories = include_directories(
44
)
55

66
test_deps=[
7-
fmt_dep,
87
gmock_dep,
98
gtest_dep,
109
json_dep,

0 commit comments

Comments
 (0)