summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2023-05-11 01:42:24 +0300
committerPatrick Williams <patrick@stwcx.xyz>2023-05-11 06:24:35 +0300
commit97c920c5ebb6407f1d5e08b55029c3dfe53ac8cc (patch)
treede73b5deec906bba75bebfd5ea6c108d40760c73
parentd13f468c6d188fe4c17f650e0cb55e45ce969f1c (diff)
downloadbmcweb-97c920c5ebb6407f1d5e08b55029c3dfe53ac8cc.tar.xz
time-utils: fix clang-tidy warning
The code already does size checking to ensure that buffer overruns are not done, so switch to using operator[] rather than pointer arithmetic. ``` ../redfish-core/include/utils/time_utils.hpp:71:19: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] end = fmt.data() + pos; ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Iaabe82d7c1621dc27ad10288732609dfd0516d17
-rw-r--r--redfish-core/include/utils/time_utils.hpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp
index cb018eff20..e2a6051eec 100644
--- a/redfish-core/include/utils/time_utils.hpp
+++ b/redfish-core/include/utils/time_utils.hpp
@@ -64,11 +64,11 @@ bool fromDurationItem(std::string_view& fmt, const char postfix,
std::chrono::milliseconds::rep ticks = 0;
if constexpr (std::is_same_v<FromTime, std::chrono::milliseconds>)
{
- end = fmt.data() + std::min<size_t>(pos, 3U);
+ end = &fmt[std::min<size_t>(pos, 3U)];
}
else
{
- end = fmt.data() + pos;
+ end = &fmt[pos];
}
auto [ptr, ec] = std::from_chars(fmt.data(), end, ticks);