diff options
author | Ravi Teja <raviteja28031990@gmail.com> | 2023-06-13 14:55:02 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2023-07-12 21:35:07 +0300 |
commit | 9eef578458f6dc3587bd27039f1ebb367041000b (patch) | |
tree | cc6ca27c80f9565de10bc60482d686ad0c68b1b6 | |
parent | 814bf20a383c891931b9f68b2d49c6b52318603d (diff) | |
download | bmcweb-9eef578458f6dc3587bd27039f1ebb367041000b.tar.xz |
Fix clang-tidy error for ibm/locks
ibm/locks that has had clang-tidy warnings disabled for a while due to
multiple safety and endianness issues.
https://github.com/openbmc/bmcweb/commit/26b3630b181d1093483e4d5ebe6aeeb91a6a2976
this commit uncomments locks code which causes warnings and fixes these warnings
Tested by: create & list locks with redfish curl and management console
Change-Id: I569e0dc5c11f259b7cca4b22722c9b4d87c68c80
Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
-rw-r--r-- | include/ibm/locks.hpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp index 0b3165e417..b61f9a5e47 100644 --- a/include/ibm/locks.hpp +++ b/include/ibm/locks.hpp @@ -187,7 +187,7 @@ class Lock inline RcGetLockList Lock::getLockList(const ListOfSessionIds& listSessionId) { - std::vector<std::pair<uint32_t, LockRequests>> lockList; + std::vector<std::pair<uint32_t, LockRequests>> lockList{}; if (!lockTable.empty()) { @@ -513,30 +513,20 @@ inline bool Lock::isConflictRequest(const LockRequests& refLockRequestStructure) // If all the elements in the lock requests which are subjected for comparison // are same, then the last comparison would be to check for the respective // bytes in the resourceid based on the segment length. - -inline bool Lock::checkByte(uint64_t /*resourceId1*/, uint64_t /*resourceId2*/, - uint32_t /*position*/) +inline bool Lock::checkByte(uint64_t resourceId1, uint64_t resourceId2, + uint32_t position) { - BMCWEB_LOG_ERROR - << "This code is disabled due to clang-tidy issues that prevent CI " - "from passing."; - std::terminate(); - -#if 0 - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - uint8_t* p = reinterpret_cast<uint8_t*>(&resourceId1); - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - uint8_t* q = reinterpret_cast<uint8_t*>(&resourceId2); - - // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - uint8_t pPosition = p[position]; - // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - uint8_t qPosition = q[position]; - - BMCWEB_LOG_DEBUG << "Comparing bytes " << std::to_string(pPosition) << "," - << std::to_string(qPosition); + if (position >= sizeof(resourceId1)) + { + return false; + } + + uint8_t pPosition = 0; + uint8_t qPosition = 0; + pPosition = 0xFF & (resourceId1 >> (8 * position)); + qPosition = 0xFF & (resourceId2 >> (8 * position)); + return pPosition == qPosition; -#endif } inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1, |