Implement bugprone-branch-clone compliance
As part of getting the clang-tidy bugprone tests running, these
conditionals were found to have duplicate entries, or be somewhat
nonsensical.
Tested: clang-tidy now passes with the branch-compliance check set.
Change-Id: Ibec106f3bbd866fc471a1fc56bd8cdd5d44024e0
diff --git a/include/authorization.hpp b/include/authorization.hpp
index 1fd1b12..524064e 100644
--- a/include/authorization.hpp
+++ b/include/authorization.hpp
@@ -212,8 +212,8 @@
{
return true;
}
- else if (crow::webroutes::routes.find(std::string(req.url)) !=
- crow::webroutes::routes.end())
+ if (crow::webroutes::routes.find(std::string(req.url)) !=
+ crow::webroutes::routes.end())
{
return true;
}
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index f8d5d4a..6bb09d0 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -1112,23 +1112,7 @@
thisElement = &response.back();
}
- if (typeCode == "s")
- {
- r = readMessageItem<char*>(typeCode, m, *thisElement);
- if (r < 0)
- {
- return r;
- }
- }
- else if (typeCode == "g")
- {
- r = readMessageItem<char*>(typeCode, m, *thisElement);
- if (r < 0)
- {
- return r;
- }
- }
- else if (typeCode == "o")
+ if (typeCode == "s" || typeCode == "g" || typeCode == "o")
{
r = readMessageItem<char*>(typeCode, m, *thisElement);
if (r < 0)
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index dd63913..897c5c4 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -143,8 +143,11 @@
messages::resourceNotFound(
asyncResp->res, "#ManagerAccount.v1_4_0.ManagerAccount", username);
}
- else if (strcmp(errorMessage,
- "xyz.openbmc_project.Common.Error.InvalidArgument") == 0)
+ else if ((strcmp(errorMessage,
+ "xyz.openbmc_project.Common.Error.InvalidArgument") ==
+ 0) ||
+ (strcmp(errorMessage, "xyz.openbmc_project.User.Common.Error."
+ "UserNameGroupFail") == 0))
{
messages::propertyValueFormatError(asyncResp->res, newUser, "UserName");
}
@@ -153,11 +156,6 @@
{
messages::createLimitReachedForResource(asyncResp->res);
}
- else if (strcmp(errorMessage, "xyz.openbmc_project.User.Common.Error."
- "UserNameGroupFail") == 0)
- {
- messages::propertyValueFormatError(asyncResp->res, newUser, "UserName");
- }
else
{
messages::internalError(asyncResp->res);
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 0e93f5c..777f37e 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -107,31 +107,16 @@
inline std::string translateSeverityDbusToRedfish(const std::string& s)
{
- if (s == "xyz.openbmc_project.Logging.Entry.Level.Alert")
+ if ((s == "xyz.openbmc_project.Logging.Entry.Level.Alert") ||
+ (s == "xyz.openbmc_project.Logging.Entry.Level.Critical") ||
+ (s == "xyz.openbmc_project.Logging.Entry.Level.Emergency") ||
+ (s == "xyz.openbmc_project.Logging.Entry.Level.Error"))
{
return "Critical";
}
- else if (s == "xyz.openbmc_project.Logging.Entry.Level.Critical")
- {
- return "Critical";
- }
- else if (s == "xyz.openbmc_project.Logging.Entry.Level.Debug")
- {
- return "OK";
- }
- else if (s == "xyz.openbmc_project.Logging.Entry.Level.Emergency")
- {
- return "Critical";
- }
- else if (s == "xyz.openbmc_project.Logging.Entry.Level.Error")
- {
- return "Critical";
- }
- else if (s == "xyz.openbmc_project.Logging.Entry.Level.Informational")
- {
- return "OK";
- }
- else if (s == "xyz.openbmc_project.Logging.Entry.Level.Notice")
+ else if ((s == "xyz.openbmc_project.Logging.Entry.Level.Debug") ||
+ (s == "xyz.openbmc_project.Logging.Entry.Level.Informational") ||
+ (s == "xyz.openbmc_project.Logging.Entry.Level.Notice"))
{
return "OK";
}
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index df83f2b..34202b1 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -1750,7 +1750,7 @@
// Get the command and host vs. chassis
std::string command;
bool hostCommand;
- if (resetType == "On")
+ if ((resetType == "On") || (resetType == "ForceOn"))
{
command = "xyz.openbmc_project.State.Host.Transition.On";
hostCommand = true;
@@ -1760,11 +1760,6 @@
command = "xyz.openbmc_project.State.Chassis.Transition.Off";
hostCommand = false;
}
- else if (resetType == "ForceOn")
- {
- command = "xyz.openbmc_project.State.Host.Transition.On";
- hostCommand = true;
- }
else if (resetType == "ForceRestart")
{
command =