clang-tidy: Enable readability-const-return-type check
Checks for functions with a const-qualified return type and
recommends removal of the const keyword. Such use of const is usually
superfluous, and can prevent valuable compiler optimizations. Does
not (yet) fix trailing return types.
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: Ifff7541c95d7881d8c6407b20c906ec7eb13abf1
diff --git a/.clang-tidy b/.clang-tidy
index 3e07c71..c3291cd 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -253,6 +253,7 @@
performance-trivially-destructible,
performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
+readability-const-return-type,
readability-delete-null-pointer,
readability-deleted-default,
readability-function-size,
diff --git a/fault-monitor/operational-status-monitor.cpp b/fault-monitor/operational-status-monitor.cpp
index e5b0c7f..10299f7 100644
--- a/fault-monitor/operational-status-monitor.cpp
+++ b/fault-monitor/operational-status-monitor.cpp
@@ -55,7 +55,7 @@
}
}
-const std::vector<std::string>
+std::vector<std::string>
Monitor::getLedGroupPaths(const std::string& inventoryPath) const
{
// Get endpoints from fType
diff --git a/fault-monitor/operational-status-monitor.hpp b/fault-monitor/operational-status-monitor.hpp
index 6bd2efc..751b970 100644
--- a/fault-monitor/operational-status-monitor.hpp
+++ b/fault-monitor/operational-status-monitor.hpp
@@ -79,7 +79,7 @@
*
* @return std::vector<std::string> - Vector of LED Group D-Bus object paths
*/
- const std::vector<std::string>
+ std::vector<std::string>
getLedGroupPaths(const std::string& inventoryPath) const;
/**
diff --git a/manager/json-parser.hpp b/manager/json-parser.hpp
index 0846a03..d7043be 100644
--- a/manager/json-parser.hpp
+++ b/manager/json-parser.hpp
@@ -133,7 +133,7 @@
*
* @return phosphor::led::GroupMap
*/
-const phosphor::led::GroupMap loadJsonConfigV1(const Json& json)
+phosphor::led::GroupMap loadJsonConfigV1(const Json& json)
{
phosphor::led::GroupMap ledMap{};
@@ -153,7 +153,7 @@
*
* @return phosphor::led::GroupMap
*/
-const phosphor::led::GroupMap loadJsonConfig(const fs::path& path)
+phosphor::led::GroupMap loadJsonConfig(const fs::path& path)
{
auto json = readJson(path);
@@ -180,7 +180,7 @@
* @note if config is an empty string, daemon will interrogate dbus for
* compatible strings.
*/
-const phosphor::led::GroupMap getSystemLedMap(fs::path config)
+phosphor::led::GroupMap getSystemLedMap(fs::path config)
{
if (config.empty())
{
diff --git a/utils.cpp b/utils.cpp
index 70e40b7..a2a72cb 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -10,8 +10,8 @@
{
// Get service name
-const std::string DBusHandler::getService(const std::string& path,
- const std::string& interface) const
+std::string DBusHandler::getService(const std::string& path,
+ const std::string& interface) const
{
using InterfaceList = std::vector<std::string>;
std::unordered_map<std::string, std::vector<std::string>> mapperResponse;
@@ -37,8 +37,8 @@
}
// Get all properties
-const PropertyMap DBusHandler::getAllProperties(
- const std::string& objectPath, const std::string& interface) const
+PropertyMap DBusHandler::getAllProperties(const std::string& objectPath,
+ const std::string& interface) const
{
PropertyMap properties;
@@ -60,9 +60,9 @@
}
// Get the property name
-const PropertyValue DBusHandler::getProperty(
- const std::string& objectPath, const std::string& interface,
- const std::string& propertyName) const
+PropertyValue DBusHandler::getProperty(const std::string& objectPath,
+ const std::string& interface,
+ const std::string& propertyName) const
{
PropertyValue value{};
@@ -102,8 +102,8 @@
bus.call_noreply(method);
}
-const std::vector<std::string> DBusHandler::getSubTreePaths(
- const std::string& objectPath, const std::string& interface)
+std::vector<std::string> DBusHandler::getSubTreePaths(
+ const std::string& objectPath, const std::string& interface) const
{
std::vector<std::string> paths;
diff --git a/utils.hpp b/utils.hpp
index eb28e07..cd79fd5 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -52,8 +52,8 @@
* @return std::string - the D-Bus service name
*
*/
- const std::string getService(const std::string& path,
- const std::string& interface) const;
+ std::string getService(const std::string& path,
+ const std::string& interface) const;
/** @brief Get All properties
*
@@ -64,8 +64,8 @@
*
* @throw sdbusplus::exception_t when it fails
*/
- const PropertyMap getAllProperties(const std::string& objectPath,
- const std::string& interface) const;
+ PropertyMap getAllProperties(const std::string& objectPath,
+ const std::string& interface) const;
/** @brief Get property(type: variant)
*
@@ -77,9 +77,9 @@
*
* @throw sdbusplus::exception_t when it fails
*/
- const PropertyValue getProperty(const std::string& objectPath,
- const std::string& interface,
- const std::string& propertyName) const;
+ PropertyValue getProperty(const std::string& objectPath,
+ const std::string& interface,
+ const std::string& propertyName) const;
/** @brief Set D-Bus property
*
@@ -102,8 +102,8 @@
*
* @return std::vector<std::string> vector of subtree paths
*/
- const std::vector<std::string> getSubTreePaths(
- const std::string& objectPath, const std::string& interface);
+ std::vector<std::string> getSubTreePaths(
+ const std::string& objectPath, const std::string& interface) const;
};
} // namespace utils