From 6ce56e8137133f003fa42277d10c3ad03b8996e2 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 22 Jan 2022 01:11:16 +0100 Subject: Core/DBLayer: Fixed false positive msvc analysis warning --- src/server/database/Database/Transaction.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/server/database/Database/Transaction.cpp') diff --git a/src/server/database/Database/Transaction.cpp b/src/server/database/Database/Transaction.cpp index 3dc0b6e01ec..0bcc905e59f 100644 --- a/src/server/database/Database/Transaction.cpp +++ b/src/server/database/Database/Transaction.cpp @@ -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 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 lock(_deadlockLock); -- cgit v1.2.3