summaryrefslogtreecommitdiff
path: root/include/openbmc_dbus_rest.hpp
AgeCommit message (Collapse)AuthorFilesLines
2024-05-31Remove the last instances of json patternEd Tanous1-4/+4
In the past, we've tried to erradicate the use of nlohmann::json(initiatlizer_list<...>) because it bloats binary sizes, as every type is given a new nlohmann constructor. This commit hunts down the last few places where we call this. There is still 2 remaining in openbmc_dbus_rest after this, but those are variant accesses that are difficult to triage, and considering it's a less used api, they're left as is. Tested: WIP Change-Id: Iaac24584bb78bb238da69010b511c1d598bd38bc Signed-off-by: Ed Tanous <ed@tanous.net>
2024-05-09Check return codesEd Tanous1-2/+10
Static analysis finds these two places that we don't check error codes. Check them. Tested: Deprecated code. Inspection only. Change-Id: I92c238c5a4b1f51c5c6855c59f4f943855c4e50f Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-29Break out formattersEd Tanous1-0/+2
In the change made to move to std::format, we defined some custom type formatters in logging.hpp. This had the unintended effect of making all compile units pull in the majority of boost::url, and nlohmann::json as includes. This commit breaks out boost and json formatters into their own separate includes. Tested: Code compiles. Logging changes only. Change-Id: I6a788533169f10e19130a1910cd3be0cc729b020 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-19Add missing headersEd Tanous1-1/+0
Most of these were found by breaking every redfish class handler into its own compile unit: When that's done, these missing headers become compile errors. We should just fix them. In addition, this allows us to enable automatic header checking in clang-tidy using misc-header-cleaner. Because the compiler can now "see" all the defines, it no longer tries to remove headers that it thinks are unused. [1] https://github.com/openbmc/bmcweb/commit/4fdee9e39e9f03122ee16a6fb251a380681f56ac Tested: Code compiles. Change-Id: Ifa27ac4a512362b7ded7cc3068648dc4aea6ad7b Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-03Call dump() lessEd Tanous1-4/+1
nlohmann::json::dump() is not an easy function to get the call parameters correct on. We should limit the places we use it. Luckily, both logging and redfish::messages support printing json values directly. Use them where appropriate. Tested: Error logging and out of range calls only of heavily used messages and logging calls. Inspection only. Change-Id: I57521d8791dd95250c93e8e3b2d4a959740ac713 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-25Enable bugprone clang checkEd Tanous1-1/+4
bugprone-multi-level-implicit-pointer-conversion is something that we pass currently, with one exception in the deprecated rest API. Ignore the one exception, as it's not clear how to fix it, and enable the check. Tested: Clang tidy passes. Change-Id: Idc10e0bb7b876e1c70afa28f9c27cc7bef1db0d7 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-01-19Remove some boost includesEd Tanous1-4/+12
The less we rely on boost, and more on std algorithms, the less people have to look up, and the more likely that our code will deduplicate. Replace all uses of boost::algorithms with std alternatives. Tested: Redfish Service Validator passes. Change-Id: I8a26f39b5709adc444b4178e92f5f3c7b988b05b Signed-off-by: Ed Tanous <edtanous@google.com>
2024-01-16DBus REST: Fix array and dict handlingMikhail Zhvakin1-3/+3
The bmcweb DBus REST API cannot currently handle array or dictionary data types correctly. This commit is meant to fix that. Tested: get/set DBus attributes (consisting of array and/or dictionary) via bmcweb DBus REST API. Change-Id: I9694cb888375c90d7a8fb1a10e53bdb5c0bce3bb Signed-off-by: Mikhail Zhvakin <striker_1993@mail.ru>
2023-10-31Move to file_body in boostEd Tanous1-4/+1
As is, it reads the whole file into memory before sending it. While fairly fast for the user, this wastes ram, and makes bmcweb less useful on less capable systems. This patch enables using the boost::beast::http::file_body type, which has more efficient serialization semantics than using a std::string. To do this, it adds a openFile() handler to http::Response, which can be used to properly open a file. Once the file is opened, the existing string body is ignored, and the file payload is sent instead. openFile() also returns success or failure, to allow users to properly handle 404s and other errors. To prove that it works, I moved over every instance of direct use of the body() method over to using this, including the webasset handler. The webasset handler specifically should help with system load when doing an initial page load of the webui. Tested: Redfish service validator passes. Change-Id: Ic7ea9ffefdbc81eb985de7edc0fac114822994ad Signed-off-by: Ed Tanous <ed@tanous.net>
2023-10-24clang-format: copy latest and re-formatPatrick Williams1-80/+78
clang-format-17 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest .clang-format from the docs repository and reformat the repository. Change-Id: I2f9540cf0d545a2da4d6289fc87b754f684bc9a7 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-08-21Use rangesEd Tanous1-1/+2
C++20 brought us std::ranges for a lot of algorithms. Most of these conversions were done using comby, similar to: ``` comby -verbose 'std::lower_bound(:[a].begin(),:[b].end(),:[c])' 'std::ranges::lower_bound(:[a], :[c])' $(git ls-files | grep "\.[hc]\(pp\)\?$") -in-place ``` Change-Id: I0c99c04e9368312555c08147d474ca93a5959e8d Signed-off-by: Ed Tanous <edtanous@google.com>
2023-07-20Replace logging with std::formatEd Tanous1-112/+101
std::format is a much more modern logging solution, and gives us a lot more flexibility, and better compile times when doing logging. Unfortunately, given its level of compile time checks, it needs to be a method, instead of the stream style logging we had before. This requires a pretty substantial change. Fortunately, this change can be largely automated, via the script included in this commit under scripts/replace_logs.py. This is to aid people in moving their patchsets over to the new form in the short period where old patches will be based on the old logging. The intention is that this script eventually goes away. The old style logging (stream based) looked like. BMCWEB_LOG_DEBUG << "Foo " << foo; The new equivalent of the above would be: BMCWEB_LOG_DEBUG("Foo {}", foo); In the course of doing this, this also cleans up several ignored linter errors, including macro usage, and array to pointer deconstruction. Note, This patchset does remove the timestamp from the log message. In practice, this was duplicated between journald and bmcweb, and there's no need for both to exist. One design decision of note is the addition of logPtr. Because the compiler can't disambiguate between const char* and const MyThing*, it's necessary to add an explicit cast to void*. This is identical to how fmt handled it. Tested: compiled with logging meson_option enabled, and launched bmcweb Saw the usual logging, similar to what was present before: ``` [Error include/webassets.hpp:60] Unable to find or open /usr/share/www/ static file hosting disabled [Debug include/persistent_data.hpp:133] Restored Session Timeout: 1800 [Debug redfish-core/include/event_service_manager.hpp:671] Old eventService config not exist [Info src/webserver_main.cpp:59] Starting webserver on port 18080 [Error redfish-core/include/event_service_manager.hpp:1301] inotify_add_watch failed for redfish log file. [Info src/webserver_main.cpp:137] Start Hostname Monitor Service... ``` Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I86a46aa2454be7fe80df608cb7e5573ca4029ec8
2023-06-28Rename all error_code instances to ecEd Tanous1-2/+2
We're not consistent here, which leads to people copying and pasting code all over, which has lead to a bunch of different names for error codes. This commit changes to coerce them all to "ec", because that's what boost uses for a naming convention. Tested: Rename only, code compiles. Change-Id: I7053cc738faa9f7a82f55fc46fc78618bdf702a5 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-20Refactor getManagedObjects methodGeorge Liu1-4/+4
Since the getManagedObjects method has been implemented in dbus_utility and this commit is to integrate all the places where the GetManagedObjects method is obtained, and use the method in dbus_utility uniformly. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ic13f2bef7b30f805cd3444a75d7df17b031f2eb0
2023-05-26Make all std::regex instances staticEd Tanous1-2/+2
Per [1] we really shouldn't be using regex. In the cases we do, it's a HUUUUUGE performance benefit to be compiling the regex ONCE. The only downside is a slight increase in memory usage. [1]: https://github.com/openbmc/bmcweb/issues/176 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8644b8a07810349fb60bfa0258a13e815912a38e
2023-05-12fix more push vs emplace callsPatrick Williams1-10/+10
It seems like clang-tidy doesn't catch every place that an emplace could be used instead of a push. Use a few grep/sed pairs to find and fix up some common patterns. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I93eaec26b8e3be240599e92b66cf54947073dc4c
2023-05-11clang-format: copy latest and re-formatPatrick Williams1-7/+4
clang-format-16 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest .clang-format from the docs repository and reformat the repository. Change-Id: I75f89d2959b0f1338c20d72ad669fbdc1d720835 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-03-17dbus_rest: Fix dangling reference of crow::ResponseLei YU1-19/+20
The openbmc_dbus_reset was holding reference of `crow::Response`, set the response in `~InProgressActionData()`, and call res.end() to complete the result of the response. The bmcweb code now uses `std::shared_ptr<AsyncResp>` for the response and the `res.end()` is handled in `~AsyncResp()`. By using the reference of `crow::Response`, the `InProgressActionData` is actually using a dangling reference because the `std::shared_ptr<AsyncResp>` is already destructed, and bmcweb will crash on `action` calls, or not crash but get invalid response, as it's undefined behavior. Fix the above issue by using `std::shared_ptr<AsyncResp>` to make sure the response is correctly handled. Tested: 1. Without the fix, bmcweb crashes, or get no json output response on the below method call, be noted that it's an invalid call: ``` $ curl -k -H "X-Auth-Token: $token" -x POST -d '{"data": []}' https://${bmc}/xyz/openbmc_project/logging/action/deleteAll ``` 2. With the fix, bmcweb gives expected response: ``` $ curl -k -H "X-Auth-Token: $token" -x POST -d '{"data": []}' https://${bmc}/xyz/openbmc_project/logging/action/deleteAll { "data": { "description": "The specified method cannot be found" }, "message": "404 Not Found", "status": "error" } $ curl -k -H "X-Auth-Token: $token" -x POST -d '{"data": []}' https://${bmc}/xyz/openbmc_project/logging/action/DeleteAll { "data": null, "message": "200 OK", "status": "ok" } ``` Signed-off-by: Lei YU <yulei.sh@bytedance.com> Change-Id: I38ef34fe8ff18e4e127664c853c6792461f6edf8
2023-02-24Take boost error_code by referenceEd Tanous1-13/+14
By convention, we should be following boost here, and passing error_code by reference, not by value. This makes our code consistent, and removes the need for a copy in some cases. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id42ea4a90b6685a84818b87d1506c11256b3b9ae
2023-02-24Pass string views by valueEd Tanous1-2/+1
string_view should always be passed by value; This commit is a sed replace of the code to make all string_views pass by value, per general coding guidelines[1]. [1] https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/ Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I55b342a29a0fbfce0a4ed9ea63db6014d03b134c
2023-02-17Add option for validating content-type headerEd Tanous1-11/+38
For systems implementing to the OWASP security guidelines[1] (of which all should ideally) we should be checking the content-type header all times that we parse a request as JSON. This commit adds an option for parsing content-type, and sets a default of "must get content-type". Ideally this would not be a breaking change, but given the number of guides and scripts that omit the content type, it seems worthwhile to add a trapdoor, such that people can opt into their own model on how they would like to see this checking work. Tested: ``` curl --insecure -H "Content-Type: application/json" -X POST -D headers.txt https://${bmc}/redfish/v1/SessionService/Sessions -d '{"UserName":"root", "Password":"0penBmc"}' ``` Succeeds. Removing Content-Type argument causes bmc to return Base.1.13.0.UnrecognizedRequestBody. [1] cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html Change-Id: Iaa47dd563b40036ff2fc2cacb70d941fd8853038 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-02-17Implement alternative to on boost::splitEd Tanous1-2/+3
boost::split has a documented false-positive in clang-tidy. While normally we'd handle this with NOLINTNEXTLINE, this doesn't appear to work in all cases. Unclear why, but seems to be due to some of our lambda callback complexity. Each of these uses is a case where we should be using a more specific check, rather than split, but for the moment, this is the best we have. Tested: clang-tidy passes. [1] https://github.com/llvm/llvm-project/issues/40486 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I144c6610cb740287b7225e2be03b4142a64f9563
2023-01-24Refactor GetSubTree methodGeorge Liu1-7/+5
Since the GetSubTree method has been implemented in dbus_utility and this commit is to integrate all the places where the GetSubTree method is called, and use the method in dbus_utility uniformly. Tested: Redfish Validator Passed Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: If3852b487d74e7cd8f123e0efffbd4affe92743c
2023-01-19Add the GetObject method to dbus_utilityGeorge Liu1-35/+20
There are currently many files that use the GetObject method. Since they are a general method, they are defined in the dbus_utility.hpp file and refactors them. Tested: Built bmcweb successfully and Validator passes. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: If2af77294389b023b611987252ee6149906fcd25
2023-01-18Fix a boatload of #includesEd Tanous1-4/+3
Most of these missing includes were found by running clang-tidy on all files, including headers. The existing scripts just run clang-tidy on source files, which doesn't catch most of these. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic741fbb2cc9e5e92955fd5a1b778a482830e80e8
2023-01-11Refactor GetSubTreePaths methodGeorge Liu1-7/+5
Since the GetSubTreePaths method has been implemented in dbus_utility and this commit is to integrate all the places where the GetSubTreePaths method is called, and use the method in dbus_utility uniformly. Requires https://gerrit.openbmc.org/c/openbmc/sdbusplus/+/60020 to build. Tested: Redfish Validator Passed Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ie4140d4484a7e4f4b943013f4371ffd2d44a22e9
2022-12-29cppcheck: Fix Ineffective call of function 'substr'Ed Tanous1-2/+2
This likely has no performance implications in practice, but getting a clean cppcheck run is good. Suggestion was implemented per cppcheck. Tested: This is in the deprecated rest API. Not sure how much testing we need to do. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1658697730ac07c7cdefd2b73c80ee65fba4dedb
2022-12-21Change variable scopesEd Tanous1-2/+1
cppcheck correctly notes that a lot of our variables can be declared at more specific scopes, and in every case, it seems to be correct. Tested: Redfish service validator passes. Unit test coverage on others. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia4414410d0e8f74a3bd40fdc0e0232450d1a6416
2022-09-09clang-tidy: fix misc warningsPatrick Williams1-1/+1
The following error reports have started to be reported by clang-tidy: * readability-qualified-auto - add 'const' to `auto&` iterators * bugprone-use-after-move - add break in loop after element is found Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I5314559f62f58aa032d4c74946b8e3e4ce6be808
2022-09-02used sdbusplus::unpackPropertiesNoThrow part 6Krzysztof Grobelny1-4/+4
used sdbusplus::unpackPropertiesNoThrow in openbmc_dbus_rest.hpp, memory.hpp and sensors.hpp, also replaced all usages of "GetAll" with sdbusplus::asio::getAllProperties bmcweb size: 2697624 -> 2697624 (0) compressed size: 1129645 -> 1130037 (+392) Tested: Performed get on: - /redfish/v1/Systems/system/Memory/dimm0 Performed get one of the members of: - /redfish/v1/Chassis/chassis/Sensors Get result before and after the change was in same format. Change-Id: I05efcedfd905ea2c8d1d663e909cb59ebc2cf2b7 Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
2022-08-06Use enum overload for field settingEd Tanous1-3/+4
There are two overloads of addHeader, one that takes a string, and one that takes a boost enum. For most common headers, boost contains a string table with all of those entries anyway, so there's no point in duplicating the strings, and ensures that we don't make trivial mistakes, like capitalization or - versus underscore that aren't caught at compile time. Tested: This saves a trivial amount (572 bytes) of compressed binary size. curl --insecure -vvv --user root:0penBmc https://192.168.7.2/redfish/v1 returns < Content-Type: application/json curl --insecure -vvv -H "Accept: text/html" --user root:0penBmc https://192.168.7.2/redfish/v1 Returns < Content-Type: text/html;charset=UTF-8 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I34c198b4f9e219247fcfe719f9b3616d35aea3dc
2022-07-25sdbusplus: use shorter type aliasesPatrick Williams1-23/+18
The sdbusplus headers provide shortened aliases for many types. Switch to using them to provide better code clarity and shorter lines. Possible replacements are for: * bus_t * exception_t * manager_t * match_t * message_t * object_t * slot_t Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I46a5eec210002af84239af74a93c830b1d4a13f1
2022-07-23test treewide: iwyuNan Zhou1-3/+43
These changes are done by running iwyu manually under clang14. Suppressed some obvious impl or details headers. Kept the recommended public headers. IWYU can increase readability, make maintenance easier, and avoid errors in some cases. See details in https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md. This commit also uses its best effort to correct obvious errors through iwyu pragma. See reference here: https://github.com/include-what-you-use/include-what-you-use#how-to-correct-iwyu-mistakes Tested: unit test passed. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I983b6f75601707cbb0f2f04546c3362ff4ba7fee
2022-07-16Remove usages of boost::starts/ends_withEd Tanous1-19/+16
Per the coding standard, now that C++ supports std::string::starts_with and std::string::ends_with, we should be using them over the boost alternatives. This commit goes through and updates all usages. Arguably some of these are incorrect, and instances of common error 13, but because this is mostly a mechanical it intentionally doesn't try to handle it. Tested: Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic4c6e5d0da90f7442693199dc691a47d2240fa4f
2022-07-12Fix const correctness issuesEd Tanous1-2/+2
cppcheck correctly notes that a lot of variables in the new code can be const. Make most of them const. Tested: WIP Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8f37b6353fd707923f533e1d61c5b5419282bf23
2022-06-30Require explicit decorator on one arg constructorsEd Tanous1-2/+2
We essentially follow this rule already, not relying on implicit operators, although there are a number of cases where in theory we could've implicitly constructed an object. This commit enables the clang-tidy check. Tested: Code compiles, passes clang-tidy. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia428463313b075c69614fdb326e8c5c094e7adde
2022-06-28Fix shadowed variable issuesEd Tanous1-3/+3
This patchset is the conclusion of a multi-year effort to try to fix shadowed variable names. Variables seem to be shadowed all over, and in most places they exist, there's a "code smell" of things that aren't doing what the author intended. This commit attempts to clean up these in several ways by: 1. Renaming variables where appropriate. 2. Preferring to refer to member variables directly when operating within a class 3. Rearranging code so that pass through variables are handled in the calling scope, rather than passing them through. These patterns are applied throughout the codebase, to the point where -Wshadow can be enabled in meson.build. Tested: Code compiles, unit tests pass. Still need to run redfish service validator. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If703398c2282f9e096ca2694fd94515de36a098b
2022-06-19openbmc_dbus_rest: use auto for json iteratorsNan Zhou1-3/+2
Clang++ complains about ``` error: use of overloaded operator '==' is ambiguous (with operand types 'nlohmann::json::const_iterator' (aka 'iter_impl<const nlohmann::basic_json<>>') and 'nlohmann::basic_json<>::iterator' (aka 'iter_impl<nlohmann::basic_json<>>')) if (argIt == transaction->arguments.end()) ``` Considering we often use auto for iterators, I changed all explict JSON iterator types in this file to auto. Tested: 1. compies on clang; Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I053de0618491dcb01ff8d4e25fe1ebe3c2d3c105
2022-06-01Try to fix the lambda formatting issueEd Tanous1-884/+823
clang-tidy has a setting, LambdaBodyIndentation, which it says: "For callback-heavy code, it may improve readability to have the signature indented two levels and to use OuterScope." bmcweb is very callback heavy code. Try to enable it and see if that improves things. There are many cases where the length of a lambda call will change, and reindent the entire lambda function. This is really bad for code reviews, as it's difficult to see the lines changed. This commit should resolve it. This does have the downside of reindenting a lot of functions, which is unfortunate, but probably worth it in the long run. All changes except for the .clang-format file were made by the robot. Tested: Code compiles, whitespace changes only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
2022-05-13Separate validFilename into a separate functionJosh Lehan1-2/+8
This will generalize it and make it callable from other places Tested: Added test cases, they pass Signed-off-by: Josh Lehan <krellan@google.com> Change-Id: I8df30d6fe6753a2454d7051cc2d8813ddbf14bad
2022-05-13Remove brace initialization of json objectsEd Tanous1-44/+68
Brace initialization of json objects, while quite interesting from an academic sense, are very difficult for people to grok, and lead to inconsistencies. This patchset aims to remove a majority of them in lieu of operator[]. Interestingly, this saves about 1% of the binary size of bmcweb. This also has an added benefit that as a design pattern, we're never constructing a new object, then moving it into place, we're always adding to the existing object, which in the future _could_ make things like OEM schemas or properties easier, as there's no case where we're completely replacing the response object. Tested: Ran redfish service validator. No new failures. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iae409b0a40ddd3ae6112cb2d52c6f6ab388595fe
2022-05-13Move /bus/system/<str>/<path> POST to methodEd Tanous1-345/+317
Per the reorganization we've done elsewhere, move this large lambda function to simplify it. Tested: Code move only. Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib0586b34809167120bdc127868706ac517db4474
2022-03-22Consitently use dbus::utility typesEd Tanous1-32/+19
This saves about 4k on the binary size Tested: Redfish service validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9546227a19c691b1aecb80e80307889548c0293f
2022-03-07Don't rely on operator << for object loggingEd Tanous1-1/+1
In the upcoming fmt patch, we remove the use of streams, and a number of our logging statements are relying on them. This commit changes them to no longer rely on operator>> or operator+ to build their strings. This alone isn't very useful, but in the context of the next patch makes the automation able to do a complete conversion of all log statements automatically. Tested: enabled logging on local and saw log statements print to console Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I0e5dc2cf015c6924037e38d547535eda8175a6a1
2022-03-01Change the completionhandler to accept ResNan Zhou1-3/+1
These modifications are from WIP:Redfish:Query parameters:Only (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474). It will be used in future CLs for Query Parameters. The code changed the completion handle to accept Res to be able to recall handle with a new Response object. AsyncResp owns a new res, so there is no need to pass in a res. Also fixed a self-move assignment bug. Context: Originally submitted: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/480020 Reveted here: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/48880 Because of failures here: https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864 Tested: 1. Romulus QEMU + Robot tests; all passed 2. Use scripts/websocket_test.py to test websockets. It is still work correctly. 3. Tested in real hardware; no new validator errors; tested both authless, session, and basic auth. 4. Hacked codes to return 500 errors on certain resource; response is expected; 5. Tested Eventing, the push style one (not SSE which is still under review), worked as expected. 6. Tested 404 errors; response is expected. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Signed-off-by: John Edward Broadbent <jebr@google.com> Change-Id: I52adb174476e0f6656335baa6657456752a031be
2022-02-15readability-static-accessed-through-instanceEd Tanous1-2/+2
We access std::string::npos through member variables in a couple places. Fix it. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I587f89e1580661aa311dfe4e06591ab38806e241
2022-02-15Enable readability-implicit-bool-conversion checksEd Tanous1-7/+9
These checks ensure that we're not implicitly converting ints or pointers into bools, which makes the code easier to read. Tested: Ran series through redfish service validator. No changes observed. UUID failing in Qemu both before and after. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1ca0be980d136bd4e5474341f4fd62f2f6bbdbae
2022-02-11Add readability-redundant-* checksEd Tanous1-1/+1
There's a number of redundancies in our code that clang can sanitize out. Fix the existing problems, and enable the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie63d7b7f0777b702fbf1b23a24e1bed7b4f5183b
2022-02-09Enable readability-avoid-const-params-in-declsEd Tanous1-1/+1
This check involves explicitly declaring variables const when they're declared auto, which helps in readability, and makes it more clear that the variables are const. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I71198ea03850384a389a56ad26f2c4a48c75b148
2022-01-28Enable readability-container-size-empty testsEd Tanous1-5/+5
This one is a little trivial, but it does help in readability. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5366d4eec8af2f781b3bad804131ae2eb806e3aa