diff options
author | Kun Yi <kunyi731@gmail.com> | 2019-11-14 11:38:44 -0800 |
---|---|---|
committer | Kun Yi <kunyi731@gmail.com> | 2019-11-21 10:06:48 -0800 |
commit | fea1d8115bace4bedae2523a9d9389a990adb09f (patch) | |
tree | 527085518596fcd100d4d20e599489a5809e2dbe | |
parent | 9ce834822ed625512913e14b83c50487d4b2c12b (diff) | |
download | phosphor-ipmi-blobs-fea1d8115bace4bedae2523a9d9389a990adb09f.tar.gz phosphor-ipmi-blobs-fea1d8115bace4bedae2523a9d9389a990adb09f.zip |
cleanup: Use scoped initializers; move implementation to source file
Simplify code and address comments from
http://gerrit.openbmc-project.xyz/c/openbmc/phosphor-ipmi-blobs/+/27399:
* Use C++17 syntax of intializers in conditionals to simplify code.
* Move getActionHandle() implementation to .cpp
* return false explicitly
Tested:
Unit tests still pass.
Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: I08a78125206f284d8c748822912e11828fb39968
-rw-r--r-- | manager.cpp | 21 | ||||
-rw-r--r-- | manager.hpp | 11 |
2 files changed, 17 insertions, 15 deletions
diff --git a/manager.cpp b/manager.cpp index 15ff083..0eec6f2 100644 --- a/manager.cpp +++ b/manager.cpp @@ -170,15 +170,26 @@ GenericBlobInterface* BlobManager::getHandler(const std::string& path) return nullptr; } +GenericBlobInterface* BlobManager::getActionHandle(uint16_t session, + uint16_t requiredFlags) +{ + if (auto item = sessions.find(session); + item != sessions.end() && (item->second.flags & requiredFlags)) + { + item->second.lastActionTime = std::chrono::steady_clock::now(); + return item->second.handler; + } + return nullptr; +} + std::string BlobManager::getPath(uint16_t session) const { - auto item = sessions.find(session); - if (item == sessions.end()) + if (auto item = sessions.find(session); item != sessions.end()) { - return ""; + return item->second.blobId; } - return item->second.blobId; + return ""; } bool BlobManager::stat(const std::string& path, BlobMeta* meta) @@ -259,7 +270,7 @@ bool BlobManager::write(uint16_t session, uint32_t offset, { return handler->write(session, offset, data); } - return {}; + return false; } bool BlobManager::deleteBlob(const std::string& path) diff --git a/manager.hpp b/manager.hpp index cba7935..3097201 100644 --- a/manager.hpp +++ b/manager.hpp @@ -256,16 +256,7 @@ class BlobManager : public ManagerInterface */ GenericBlobInterface* getActionHandle( uint16_t session, - uint16_t requiredFlags = std::numeric_limits<uint16_t>::max()) - { - if (auto item = sessions.find(session); - item != sessions.end() && (item->second.flags & requiredFlags)) - { - item->second.lastActionTime = std::chrono::steady_clock::now(); - return item->second.handler; - } - return nullptr; - } + uint16_t requiredFlags = std::numeric_limits<uint16_t>::max()); /** * Given a session id will return associated path. |