From 2bd4ab43be2592ffe0b1321c18d0169f010486ab Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Thu, 11 May 2023 11:23:01 -0500 Subject: query-param: fix clang-tidy warnings ``` ../redfish-core/include/utils/query_param.hpp:287:51: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] auto it = std::from_chars(value.data(), value.data() + value.size(), ~~~~~~^~~~~~ ../redfish-core/include/utils/query_param.hpp:307:45: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] std::from_chars(value.data(), value.data() + value.size(), param); ``` Signed-off-by: Patrick Williams Change-Id: Ic93d3e98e0539f5c7068b93ff7e4505fdd5bbfe1 --- redfish-core/include/utils/query_param.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp index e6ca9d313a..d375202408 100644 --- a/redfish-core/include/utils/query_param.hpp +++ b/redfish-core/include/utils/query_param.hpp @@ -284,13 +284,13 @@ inline bool getExpandType(std::string_view value, Query& query) } value.remove_prefix(levels.size()); - auto it = std::from_chars(value.data(), value.data() + value.size(), - query.expandLevel); + auto it = std::from_chars(value.begin(), value.end(), query.expandLevel); if (it.ec != std::errc()) { return false; } - value.remove_prefix(static_cast(it.ptr - value.data())); + value.remove_prefix( + static_cast(std::distance(value.begin(), it.ptr))); return value == ")"; } @@ -303,8 +303,8 @@ enum class QueryError inline QueryError getNumericParam(std::string_view value, size_t& param) { - std::from_chars_result r = - std::from_chars(value.data(), value.data() + value.size(), param); + std::from_chars_result r = std::from_chars(value.begin(), value.end(), + param); // If the number wasn't representable in the type, it's out of range if (r.ec == std::errc::result_out_of_range) -- cgit v1.2.3