Fixed handling maxAppendLimit
maxLimit prevented using numeric_limits<uint64_t>::max as a way to let
telemetry service deduce appendLimit. This commit fixes constrain to
allow passing this special value.
Tested:
- Added new unit tests that confirm numeric_limits<uint64_t>::max is
correctly handled in telemetry service
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I5d67e83475cdfcbb58a71b783ac9eef1e5ad7010
diff --git a/src/report.cpp b/src/report.cpp
index 2b7134a..8acf182 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -89,11 +89,12 @@
return sensorCount;
}
-uint64_t Report::deduceAppendLimit(const uint64_t appendLimitIn) const
+std::optional<uint64_t>
+ Report::deduceAppendLimit(const uint64_t appendLimitIn) const
{
if (appendLimitIn == std::numeric_limits<uint64_t>::max())
{
- return sensorCount;
+ return std::nullopt;
}
else
{
@@ -111,7 +112,7 @@
}
else
{
- return appendLimit;
+ return appendLimit.value_or(sensorCount);
}
}
@@ -243,9 +244,10 @@
return utils::enumToString(reportAction);
});
});
- dbusIface->register_property_r("AppendLimit", appendLimit,
- sdbusplus::vtable::property_::emits_change,
- [this](const auto&) { return appendLimit; });
+ dbusIface->register_property_r(
+ "AppendLimit", appendLimit.value_or(sensorCount),
+ sdbusplus::vtable::property_::emits_change,
+ [this](const auto&) { return appendLimit.value_or(sensorCount); });
dbusIface->register_property_rw(
"ReportUpdates", std::string(),
sdbusplus::vtable::property_::emits_change,
@@ -340,7 +342,8 @@
return utils::toUnderlying(reportAction);
});
data["Interval"] = interval.count();
- data["AppendLimit"] = appendLimit;
+ data["AppendLimit"] =
+ appendLimit.value_or(std::numeric_limits<uint64_t>::max());
data["ReportUpdates"] = utils::toUnderlying(reportUpdates);
data["ReadingParameters"] =
utils::transform(metrics, [](const auto& metric) {