[PATCH] D21582: [libcxx] [test] Avoid mixing assignment and returning.
Stephan T. Lavavej via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 21 17:51:30 PDT 2016
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
Avoid mixing assignment and returning. "return locked = true;" looks really suspicious, even though it happens to be correct here. Spend an extra statement to make the code clearer, and compilers happier.
Fixes MSVC warning C6282 "Incorrect operator: assignment of constant in Boolean context. Consider using '==' instead."
http://reviews.llvm.org/D21582
Files:
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp
Index: test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp
===================================================================
--- test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp
@@ -28,7 +28,7 @@
~TestMutex() { assert(!locked); }
void lock() { assert(!locked); locked = true; }
- bool try_lock() { if (locked) return false; return locked = true; }
+ bool try_lock() { if (locked) return false; locked = true; return true; }
void unlock() { assert(locked); locked = false; }
TestMutex(TestMutex const&) = delete;
Index: test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp
===================================================================
--- test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp
@@ -25,7 +25,7 @@
TestMutex() = default;
void lock() { assert(!locked); locked = true; }
- bool try_lock() { if (locked) return false; return locked = true; }
+ bool try_lock() { if (locked) return false; locked = true; return true; }
void unlock() { assert(locked); locked = false; }
TestMutex(TestMutex const&) = delete;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21582.61475.patch
Type: text/x-patch
Size: 1396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160622/e7e67152/attachment.bin>
More information about the cfe-commits
mailing list