diff options
| author | Ed Tanous <ed.tanous@intel.com> | 2019-10-24 10:18:09 -0700 |
|---|---|---|
| committer | James Feist <james.feist@linux.intel.com> | 2019-11-11 21:35:05 +0000 |
| commit | 42c201821cca6162da111c1ef77cd85009825308 (patch) | |
| tree | df5ce41b1f9cd91f0b6b5fcc3f325ce7c901cdd4 /include | |
| parent | 99131cd04bfc4a187e7a8d63803cb8911e64a08e (diff) | |
| download | bmcweb-42c201821cca6162da111c1ef77cd85009825308.tar.gz bmcweb-42c201821cca6162da111c1ef77cd85009825308.zip | |
Move error strings to const char*
clang-tidy flagged an error where strings were being constructed at
startup. Move them to const char* to save a little memory, and reduce
the possibility of a error being thrown at startup.
Tested: Code compiles. Error codes need tested functionally.
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I227e91879e727f4b19d955111b0d2bac8e81b6ad
Diffstat (limited to 'include')
| -rw-r--r-- | include/openbmc_dbus_rest.hpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index 73986b9..38aa630 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp @@ -35,25 +35,23 @@ using GetSubTreeType = std::vector< std::pair<std::string, std::vector<std::pair<std::string, std::vector<std::string>>>>>; -const std::string notFoundMsg = "404 Not Found"; -const std::string badReqMsg = "400 Bad Request"; -const std::string methodNotAllowedMsg = "405 Method Not Allowed"; -const std::string forbiddenMsg = "403 Forbidden"; -const std::string methodFailedMsg = "500 Method Call Failed"; -const std::string methodOutputFailedMsg = "500 Method Output Error"; - -const std::string notFoundDesc = +const char *notFoundMsg = "404 Not Found"; +const char *badReqMsg = "400 Bad Request"; +const char *methodNotAllowedMsg = "405 Method Not Allowed"; +const char *forbiddenMsg = "403 Forbidden"; +const char *methodFailedMsg = "500 Method Call Failed"; +const char *methodOutputFailedMsg = "500 Method Output Error"; +const char *notFoundDesc = "org.freedesktop.DBus.Error.FileNotFound: path or object not found"; -const std::string propNotFoundDesc = "The specified property cannot be found"; -const std::string noJsonDesc = "No JSON object could be decoded"; -const std::string methodNotFoundDesc = "The specified method cannot be found"; -const std::string methodNotAllowedDesc = "Method not allowed"; -const std::string forbiddenPropDesc = - "The specified property cannot be created"; -const std::string forbiddenResDesc = "The specified resource cannot be created"; +const char *propNotFoundDesc = "The specified property cannot be found"; +const char *noJsonDesc = "No JSON object could be decoded"; +const char *methodNotFoundDesc = "The specified method cannot be found"; +const char *methodNotAllowedDesc = "Method not allowed"; +const char *forbiddenPropDesc = "The specified property cannot be created"; +const char *forbiddenResDesc = "The specified resource cannot be created"; void setErrorResponse(crow::Response &res, boost::beast::http::status result, - const std::string &desc, const std::string &msg) + const std::string &desc, const std::string_view msg) { res.result(result); res.jsonValue = {{"data", {{"description", desc}}}, |

