phosphor-ipmi-flash: Code Health Cleanup
Removed the following warning.
- using decl '*' is unused
- 'push_back' is called inside a loop; consider pre-allocating the
container capacity before the loop
- function '*' defined in a header file; function
definitions in header files can lead to ODR violations
Change-Id: I44e4b0f8056a853fb45b690394be1a8ebec45b20
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/bmc/version-handler/test/version_mock.hpp b/bmc/version-handler/test/version_mock.hpp
index 4cae248..d8035a5 100644
--- a/bmc/version-handler/test/version_mock.hpp
+++ b/bmc/version-handler/test/version_mock.hpp
@@ -1,18 +1,18 @@
+#pragma once
#include "handler_config.hpp"
#include "image_mock.hpp"
#include "triggerable_mock.hpp"
#include "version_handler.hpp"
-#include <memory>
#include <string>
-#include <utility>
namespace ipmi_flash
{
-auto createMockVersionConfig(const std::string& id,
- ImageHandlerMock** im = nullptr,
- TriggerMock** tm = nullptr)
+static HandlerConfig<VersionBlobHandler::ActionPack>
+ createMockVersionConfig(const std::string& id,
+ ImageHandlerMock** im = nullptr,
+ TriggerMock** tm = nullptr)
{
HandlerConfig<VersionBlobHandler::ActionPack> ret;
ret.blobId = id;
@@ -34,15 +34,16 @@
template <typename C, typename Im = std::map<std::string, ImageHandlerMock*>,
typename Tm = std::map<std::string, TriggerMock*>>
-auto createMockVersionConfigs(const C& ids, Im* im = nullptr, Tm* tm = nullptr)
+static std::vector<HandlerConfig<VersionBlobHandler::ActionPack>>
+ createMockVersionConfigs(const C& ids, Im* im = nullptr, Tm* tm = nullptr)
{
std::vector<HandlerConfig<VersionBlobHandler::ActionPack>> ret;
- for (const auto& id : ids)
- {
- ret.push_back(
+ ret.reserve(ids.size());
+ std::for_each(ids.begin(), ids.end(), [im, tm, &ret](const auto& id) {
+ ret.emplace_back(
createMockVersionConfig(id, im == nullptr ? nullptr : &(*im)[id],
tm == nullptr ? nullptr : &(*tm)[id]));
- }
+ });
return ret;
}