Bug 1220544 - Fix -Wunreachable-code warnings in xpcom. r=mccr8
authorChris Peterson <cpeterson@mozilla.com>
Mon, 02 Nov 2015 21:03:03 -0800
changeset 270913 9d35ff5cf79698988fb3dac6628cb00c255e9337
parent 270912 a14abc3d5087398ec699b5e850824275ee8d5c17
child 270914 43ce9581fb647fe22dd5fa12069409cdd701b8a7
push id18459
push usercbook@mozilla.com
push dateTue, 03 Nov 2015 11:14:32 +0000
treeherderb2g-inbound@09173d8e6694 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1220544
milestone45.0a1
Bug 1220544 - Fix -Wunreachable-code warnings in xpcom. r=mccr8 xpcom/glue/PLDHashTable.cpp:471:10 [-Wunreachable-code-return] 'return' will never be executed xpcom/tests/TestAutoPtr.cpp:324:9 [-Wunreachable-code] code will never be executed xpcom/tests/TestBlockingProcess.cpp:6:11 [-Wunreachable-code-return] 'return' will never be executed
xpcom/glue/PLDHashTable.cpp
xpcom/tests/TestAutoPtr.cpp
xpcom/tests/TestBlockingProcess.cpp
--- a/xpcom/glue/PLDHashTable.cpp
+++ b/xpcom/glue/PLDHashTable.cpp
@@ -463,17 +463,16 @@ PLDHashTable::FindFreeEntry(PLDHashNumbe
 
     entry = AddressEntry(hash1);
     if (EntryIsFree(entry)) {
       return entry;
     }
   }
 
   // NOTREACHED
-  return nullptr;
 }
 
 bool
 PLDHashTable::ChangeTable(int32_t aDeltaLog2)
 {
   MOZ_ASSERT(mEntryStore.Get());
 
   // Look, but don't touch, until we succeed in getting new entry store.
@@ -841,9 +840,8 @@ PLDHashTable::Iterator::Remove()
 
 #ifdef DEBUG
 void
 PLDHashTable::MarkImmutable()
 {
   mChecker.SetNonWritable();
 }
 #endif
-
--- a/xpcom/tests/TestAutoPtr.cpp
+++ b/xpcom/tests/TestAutoPtr.cpp
@@ -314,18 +314,20 @@ int main()
         RefPtr<TestRefObject> ptr;
         printf("Should create and AddRef one |TestRefObject|:\n");
         CreateTestRefObject(getter_AddRefs(ptr));
         printf("Should Release and destroy one |TestRefObject|:\n");
     }
 
     printf("\nTesting casts and equality tests.\n");
 
-    if ((void*)(TestObject*)0x1000 ==
-        (void*)(TestObjectBaseB*)(TestObject*)0x1000)
+    // This comparison is always false, as it should be. The extra parens
+    // suppress a -Wunreachable-code warning about printf being unreachable.
+    if (((void*)(TestObject*)0x1000) ==
+        ((void*)(TestObjectBaseB*)(TestObject*)0x1000))
         printf("\n\nAll these tests are meaningless!\n\n\n");
 
     {
         nsAutoPtr<TestObject> p1(new TestObject());
         TestObjectBaseB *p2 = p1;
         printf("equality %s.\n",
                ((static_cast<void*>(p1) != static_cast<void*>(p2)) &&
                 (p1 == p2) && !(p1 != p2) && (p2 == p1) && !(p2 != p1))
@@ -390,17 +392,16 @@ int main()
     {
         printf("Should create one |TestRefObject|:\n");
         RefPtr<TestRefObject> pobj( new TestRefObject() );
         printf("Should do nothing:\n");
         RefPtr<TestRefObject> pobj2( pobj.forget() );
         printf("Should destroy one |TestRefObject|:\n");
     }
 
-
     printf("\nTesting construction.\n");
 
     {
         printf("Should create one |TestObject|:\n");
         nsAutoPtr<TestObject> pobj(new TestObject());
         printf("Should destroy one |TestObject|:\n");
     }
 
--- a/xpcom/tests/TestBlockingProcess.cpp
+++ b/xpcom/tests/TestBlockingProcess.cpp
@@ -1,8 +1,6 @@
 #include <prthread.h>
- 
+
 int main()
 {
    while(1) PR_Sleep(PR_SecondsToInterval(10));
-   return 0;
 }
-