Fix mutex_test.cc so it'll compile with both GCC versions we support.
Change-Id: Ifde47a2413a6a00fe9604519c89400217289884a
diff --git a/src/mutex_test.cc b/src/mutex_test.cc
index 63aa14b..4931551 100644
--- a/src/mutex_test.cc
+++ b/src/mutex_test.cc
@@ -42,16 +42,18 @@
MutexTester::AssertDepth(mu, 0U);
}
-TEST(Mutex, TryLockUnlock) {
+// GCC doesn't get recursive mutexes, so we have to turn off thread safety analysis.
+static void TryLockUnlockTest() NO_THREAD_SAFETY_ANALYSIS {
Mutex mu("test mutex");
MutexTester::AssertDepth(mu, 0U);
- bool locked = mu.TryLock();
- ASSERT_TRUE(locked);
- if (locked) { // Keep GCC happy.
- MutexTester::AssertDepth(mu, 1U);
- mu.Unlock();
- MutexTester::AssertDepth(mu, 0U);
- }
+ ASSERT_TRUE(mu.TryLock());
+ MutexTester::AssertDepth(mu, 1U);
+ mu.Unlock();
+ MutexTester::AssertDepth(mu, 0U);
+}
+
+TEST(Mutex, TryLockUnlock) {
+ TryLockUnlockTest();
}
// GCC doesn't get recursive mutexes, so we have to turn off thread safety analysis.