summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-06 23:51:13 +0300
committerEd Tanous <ed@tanous.net>2024-04-10 21:26:25 +0300
commitf1a1e3dcca1db1ee7c39b673a387ec6cd231561b (patch)
tree74e68e24a0d816d0e042a0d8141ed6e44d9ae2e0 /redfish-core
parent2b9c1dfece51feb6f3f44a6b7a7e5802f5dff416 (diff)
downloadbmcweb-f1a1e3dcca1db1ee7c39b673a387ec6cd231561b.tar.xz
Simplify query_param
Static analysis notes that the values in these functions are never initialized, and that a small section of the branch is no longer possible to hit, now that a default case has been added in 4da0490bc07a458ad3fc7d586c7eabf6053c572f Remove the dead code and initialize variables where appropriate. Tested: Unit tests pass. Decent coverage here. Change-Id: I42ec4678672fea5b21f98aaae05dfca0629652e7 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/include/utils/query_param.hpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp
index dc06a3a8de..0f987632d2 100644
--- a/redfish-core/include/utils/query_param.hpp
+++ b/redfish-core/include/utils/query_param.hpp
@@ -205,7 +205,7 @@ struct QueryCapabilities
// handlers so that handlers don't need to query again.
inline Query delegate(const QueryCapabilities& queryCapabilities, Query& query)
{
- Query delegated;
+ Query delegated{};
// delegate only
if (query.isOnly && queryCapabilities.canDelegateOnly)
{
@@ -376,7 +376,7 @@ inline bool getSelectParam(std::string_view value, Query& query)
inline std::optional<Query> parseParameters(boost::urls::params_view urlParams,
crow::Response& res)
{
- Query ret;
+ Query ret{};
for (const boost::urls::params_view::value_type& it : urlParams)
{
if (it.key == "only")
@@ -700,30 +700,22 @@ inline std::optional<std::string> formatQueryForExpand(const Query& query)
return "";
}
std::string str = "?$expand=";
- bool queryTypeExpected = false;
switch (query.expandType)
{
- case ExpandType::None:
- return "";
case ExpandType::Links:
- queryTypeExpected = true;
str += '~';
break;
case ExpandType::NotLinks:
- queryTypeExpected = true;
str += '.';
break;
case ExpandType::Both:
- queryTypeExpected = true;
str += '*';
break;
+ case ExpandType::None:
+ return "";
default:
return std::nullopt;
}
- if (!queryTypeExpected)
- {
- return std::nullopt;
- }
str += "($levels=";
str += std::to_string(query.expandLevel - 1);
str += ')';