Remove uses of ASSERT(false)
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 May 2012 00:54:03 +0000 (00:54 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 May 2012 00:54:03 +0000 (00:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85686

Reviewed by Dean Jackson.

Replace uses of ASSERT(false) with ASSERT_NOT_REACHED(). Also, in two places, there was code structured like:

if (expr) {
    // do something
} else {
    ASSERT(false);
}

Replace this with:

ASSERT(expr);
if (!expr)
    return;

// do something

* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::deleteOrigin):
(WebCore::DatabaseTracker::doneCreatingDatabase):
(WebCore::DatabaseTracker::doneDeletingDatabase):
(WebCore::DatabaseTracker::deleteDatabase):
* bridge/objc/objc_instance.mm:
(ObjcInstance::invokeObjcMethod):
* bridge/objc/objc_utility.mm:
(JSC::Bindings::convertObjcValueToValue):
(JSC::Bindings::objcValueTypeForType):
* dom/Node.cpp:
(WebCore::Node::createRenderer):
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::setIconURLForPageURLInSQLDatabase):
(WebCore::IconDatabase::setIconIDForPageURLInSQLDatabase):
* platform/graphics/GraphicsContext3D.cpp:
(WebCore::doPacking):
* platform/text/BidiResolver.h:
(WebCore::::createBidiRunsForLine):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@116198 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/bridge/objc/objc_instance.mm
Source/WebCore/bridge/objc/objc_utility.mm
Source/WebCore/dom/Node.cpp
Source/WebCore/loader/icon/IconDatabase.cpp
Source/WebCore/platform/graphics/GraphicsContext3D.cpp
Source/WebCore/platform/text/BidiResolver.h

index b7f0505..18a277b 100644 (file)
@@ -1,3 +1,46 @@
+2012-05-04  Andy Estes  <aestes@apple.com>
+
+        Remove uses of ASSERT(false)
+        https://bugs.webkit.org/show_bug.cgi?id=85686
+
+        Reviewed by Dean Jackson.
+
+        Replace uses of ASSERT(false) with ASSERT_NOT_REACHED(). Also, in two places, there was code structured like:
+
+        if (expr) {
+            // do something
+        } else {
+            ASSERT(false);
+        }
+
+        Replace this with:
+
+        ASSERT(expr);
+        if (!expr)
+            return;
+
+        // do something
+
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::deleteOrigin):
+        (WebCore::DatabaseTracker::doneCreatingDatabase):
+        (WebCore::DatabaseTracker::doneDeletingDatabase):
+        (WebCore::DatabaseTracker::deleteDatabase):
+        * bridge/objc/objc_instance.mm:
+        (ObjcInstance::invokeObjcMethod):
+        * bridge/objc/objc_utility.mm:
+        (JSC::Bindings::convertObjcValueToValue):
+        (JSC::Bindings::objcValueTypeForType):
+        * dom/Node.cpp:
+        (WebCore::Node::createRenderer):
+        * loader/icon/IconDatabase.cpp:
+        (WebCore::IconDatabase::setIconURLForPageURLInSQLDatabase):
+        (WebCore::IconDatabase::setIconIDForPageURLInSQLDatabase):
+        * platform/graphics/GraphicsContext3D.cpp:
+        (WebCore::doPacking):
+        * platform/text/BidiResolver.h:
+        (WebCore::::createBidiRunsForLine):
+
 2012-05-04  Noel Gordon  <noel.gordon@gmail.com>
 
         [CG] Minor refactor of ImageBuffer::CGImageToDataURL and its callers
index 233b372..0e5793c 100644 (file)
@@ -759,7 +759,7 @@ bool DatabaseTracker::deleteOrigin(SecurityOrigin* origin)
         }
         if (!canDeleteOrigin(origin)) {
             LOG_ERROR("Tried to delete an origin (%s) while either creating database in it or already deleting it", origin->databaseIdentifier().ascii().data());
-            ASSERT(false);
+            ASSERT_NOT_REACHED();
             return false;
         }
         recordDeletingOrigin(origin);
@@ -853,19 +853,20 @@ void DatabaseTracker::doneCreatingDatabase(SecurityOrigin *origin, const String&
 {
     ASSERT(!m_databaseGuard.tryLock());
     NameCountMap* nameMap = m_beingCreated.get(origin);
-    if (nameMap) {
-        long count = nameMap->get(name);
-        ASSERT(count > 0);
-        if (count <= 1) {
-            nameMap->remove(name);
-            if (nameMap->isEmpty()) {
-                m_beingCreated.remove(origin);
-                delete nameMap;
-            }
-        } else
-            nameMap->set(name, count - 1);
+    ASSERT(nameMap);
+    if (!nameMap)
+        return;
+
+    long count = nameMap->get(name);
+    ASSERT(count > 0);
+    if (count <= 1) {
+        nameMap->remove(name);
+        if (nameMap->isEmpty()) {
+            m_beingCreated.remove(origin);
+            delete nameMap;
+        }
     } else
-        ASSERT(false);
+        nameMap->set(name, count - 1);
 }
 
 bool DatabaseTracker::creatingDatabase(SecurityOrigin *origin, const String& name)
@@ -898,15 +899,15 @@ void DatabaseTracker::doneDeletingDatabase(SecurityOrigin *origin, const String&
 {
     ASSERT(!m_databaseGuard.tryLock());
     NameSet* nameSet = m_beingDeleted.get(origin);
-    if (nameSet) {
-        ASSERT(nameSet->contains(name));
-        nameSet->remove(name);
-        if (nameSet->isEmpty()) {
-            m_beingDeleted.remove(origin);
-            delete nameSet;
-        }
-    } else {
-        ASSERT(false);
+    ASSERT(nameSet);
+    if (!nameSet)
+        return;
+
+    ASSERT(nameSet->contains(name));
+    nameSet->remove(name);
+    if (nameSet->isEmpty()) {
+        m_beingDeleted.remove(origin);
+        delete nameSet;
     }
 }
 
@@ -952,7 +953,7 @@ bool DatabaseTracker::deleteDatabase(SecurityOrigin* origin, const String& name)
             return false;
 
         if (!canDeleteDatabase(origin, name)) {
-            ASSERT(FALSE);
+            ASSERT_NOT_REACHED();
             return false;
         }
         recordDeletingDatabase(origin, name);
index 60dc229..af544b6 100644 (file)
@@ -315,7 +315,7 @@ JSValue ObjcInstance::invokeObjcMethod(ExecState* exec, ObjcMethod* method)
                     // the assert above should have fired in the impossible case
                     // of an invalid type anyway).
                     fprintf(stderr, "%s: invalid type (%d)\n", __PRETTY_FUNCTION__, (int)objcValueType);
-                    ASSERT(false);
+                    ASSERT_NOT_REACHED();
             }
         }
     }
index b929ac0..999f732 100644 (file)
@@ -232,7 +232,7 @@ JSValue convertObjcValueToValue(ExecState* exec, void* buffer, ObjcValueType typ
         default:
             // Should never get here. Argument types are filtered.
             fprintf(stderr, "%s: invalid type (%d)\n", __PRETTY_FUNCTION__, (int)type);
-            ASSERT(false);
+            ASSERT_NOT_REACHED();
     }
     
     return jsUndefined();
@@ -298,7 +298,7 @@ ObjcValueType objcValueTypeForType(const char *type)
             default:
                 // Unhandled type. We don't handle C structs, unions, etc.
                 // FIXME: throw an exception?
-                ASSERT(false);
+                ASSERT_NOT_REACHED();
         }
 
         if (objcValueType != ObjcInvalidType)
index 39a400c..bdbdd5a 100644 (file)
@@ -1434,7 +1434,7 @@ bool Node::rendererIsNeeded(const NodeRenderingContext& context)
 
 RenderObject* Node::createRenderer(RenderArena*, RenderStyle*)
 {
-    ASSERT(false);
+    ASSERT_NOT_REACHED();
     return 0;
 }
     
index ce4f010..6e97c02 100644 (file)
@@ -1895,7 +1895,7 @@ void IconDatabase::setIconURLForPageURLInSQLDatabase(const String& iconURL, cons
     
     if (!iconID) {
         LOG_ERROR("Failed to establish an ID for iconURL %s", urlForLogging(iconURL).ascii().data());
-        ASSERT(false);
+        ASSERT_NOT_REACHED();
         return;
     }
     
@@ -1912,7 +1912,7 @@ void IconDatabase::setIconIDForPageURLInSQLDatabase(int64_t iconID, const String
 
     int result = m_setIconIDForPageURLStatement->step();
     if (result != SQLResultDone) {
-        ASSERT(false);
+        ASSERT_NOT_REACHED();
         LOG_ERROR("setIconIDForPageURLQuery failed for url %s", urlForLogging(pageURL).ascii().data());
     }
 
index a282e80..c1b36f6 100644 (file)
@@ -1348,7 +1348,7 @@ static void doPacking(const void* sourceData,
         break;
     }
     default:
-        ASSERT(false);
+        ASSERT_NOT_REACHED();
     }
 }
 
index 5806ca5..5f4ce15 100644 (file)
@@ -854,7 +854,7 @@ void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, Vis
                         m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : EuropeanNumber;
                         break;
                     default:
-                        ASSERT(false);
+                        ASSERT_NOT_REACHED();
                 }
                 appendRun();
             }