Core/DBLayer: Fixed false positive msvc analysis warning

This commit is contained in:
Shauren
2022-01-22 01:11:16 +01:00
parent ff778a7581
commit 6ce56e8137

View File

@@ -77,9 +77,13 @@ bool TransactionTask::Execute()
if (errorCode == ER_LOCK_DEADLOCK)
{
std::ostringstream threadIdStream;
threadIdStream << std::this_thread::get_id();
std::string threadId = threadIdStream.str();
std::string threadId = []()
{
// wrapped in lambda to fix false positive analysis warning C26115
std::ostringstream threadIdStream;
threadIdStream << std::this_thread::get_id();
return threadIdStream.str();
}();
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
std::lock_guard<std::mutex> lock(_deadlockLock);
@@ -122,9 +126,13 @@ bool TransactionWithResultTask::Execute()
if (errorCode == ER_LOCK_DEADLOCK)
{
std::ostringstream threadIdStream;
threadIdStream << std::this_thread::get_id();
std::string threadId = threadIdStream.str();
std::string threadId = []()
{
// wrapped in lambda to fix false positive analysis warning C26115
std::ostringstream threadIdStream;
threadIdStream << std::this_thread::get_id();
return threadIdStream.str();
}();
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
std::lock_guard<std::mutex> lock(_deadlockLock);