Browse Source

general: Clean up asserts which were abusing NULL

Sam Edwards 7 years ago
parent
commit
d422d74abb

+ 0 - 1
dtool/src/interrogate/interfaceMaker.cxx

@@ -665,7 +665,6 @@ record_object(TypeIndex type_index) {
 
   InterrogateDatabase *idb = InterrogateDatabase::get_ptr();
   const InterrogateType &itype = idb->get_type(type_index);
-  assert(&itype != NULL);
 
   Object *object = new Object(itype);
   bool inserted = _objects.insert(Objects::value_type(type_index, object)).second;

+ 0 - 2
dtool/src/interrogate/interrogateBuilder.cxx

@@ -1696,8 +1696,6 @@ get_function(CPPInstance *function, string description,
     InterrogateFunction &ifunction =
       InterrogateDatabase::get_ptr()->update_function(index);
 
-    nassertr(&ifunction != NULL, 0);
-
     ifunction._flags |= flags;
 
     // Also, make sure this particular signature is defined.

+ 0 - 4
panda/src/express/nodeReferenceCount.I

@@ -52,8 +52,6 @@ NodeReferenceCount(const NodeReferenceCount &copy) : ReferenceCount(copy) {
  */
 INLINE void NodeReferenceCount::
 operator = (const NodeReferenceCount &copy) {
-  nassertv(this != NULL);
-
   // If this assertion fails, our own pointer was recently deleted.  Possibly
   // you used a real pointer instead of a PointerTo at some point, and the
   // object was deleted when the PointerTo went out of scope.  Maybe you tried
@@ -74,8 +72,6 @@ operator = (const NodeReferenceCount &copy) {
  */
 INLINE NodeReferenceCount::
 ~NodeReferenceCount() {
-  nassertv(this != NULL);
-
   // If this assertion fails, we're trying to delete an object that was just
   // deleted.  Possibly you used a real pointer instead of a PointerTo at some
   // point, and the object was deleted when the PointerTo went out of scope.

+ 0 - 2
panda/src/express/nodeReferenceCount.cxx

@@ -21,8 +21,6 @@ TypeHandle NodeReferenceCount::_type_handle;
  */
 bool NodeReferenceCount::
 do_test_ref_count_integrity() const {
-  nassertr(this != NULL, false);
-
   // If this assertion fails, we're trying to delete an object that was just
   // deleted.  Possibly you used a real pointer instead of a PointerTo at some
   // point, and the object was deleted when the PointerTo went out of scope.

+ 0 - 4
panda/src/express/referenceCount.I

@@ -63,8 +63,6 @@ ReferenceCount(const ReferenceCount &) {
  */
 INLINE void ReferenceCount::
 operator = (const ReferenceCount &) {
-  nassertv(this != NULL);
-
   // If this assertion fails, our own pointer was recently deleted.  Possibly
   // you used a real pointer instead of a PointerTo at some point, and the
   // object was deleted when the PointerTo went out of scope.  Maybe you tried
@@ -80,8 +78,6 @@ operator = (const ReferenceCount &) {
 ReferenceCount::
 ~ReferenceCount() {
   TAU_PROFILE("ReferenceCount::~ReferenceCount()", " ", TAU_USER);
-  nassertv(this != NULL);
-
   // If this assertion fails, we're trying to delete an object that was just
   // deleted.  Possibly you used a real pointer instead of a PointerTo at some
   // point, and the object was deleted when the PointerTo went out of scope.

+ 0 - 2
panda/src/express/referenceCount.cxx

@@ -23,8 +23,6 @@ TypeHandle ReferenceCount::_type_handle;
  */
 bool ReferenceCount::
 do_test_ref_count_integrity() const {
-  nassertr(this != NULL, false);
-
   // If this assertion fails, we're trying to delete an object that was just
   // deleted.  Possibly you used a real pointer instead of a PointerTo at some
   // point, and the object was deleted when the PointerTo went out of scope.

+ 8 - 8
panda/src/express/weakPointerTo.I

@@ -45,7 +45,7 @@ WeakPointerTo(const WeakPointerTo<T> &copy) :
 template<class T>
 INLINE TYPENAME WeakPointerTo<T>::To &WeakPointerTo<T>::
 operator *() const {
-  nassertr(!this->was_deleted(), *((To *)NULL));
+  assert(!this->was_deleted());
   return *((To *)WeakPointerToBase<T>::_void_ptr);
 }
 
@@ -55,7 +55,7 @@ operator *() const {
 template<class T>
 INLINE TYPENAME WeakPointerTo<T>::To *WeakPointerTo<T>::
 operator -> () const {
-  nassertr(!this->was_deleted(), (To *)NULL);
+  assert(!this->was_deleted());
   return (To *)WeakPointerToBase<T>::_void_ptr;
 }
 
@@ -68,7 +68,7 @@ operator -> () const {
 template<class T>
 INLINE WeakPointerTo<T>::
 operator T * () const {
-  nassertr(!this->was_deleted(), (To *)NULL);
+  assert(!this->was_deleted());
   return (To *)WeakPointerToBase<T>::_void_ptr;
 }
 
@@ -108,7 +108,7 @@ lock() const {
 template<class T>
 INLINE TYPENAME WeakPointerTo<T>::To *WeakPointerTo<T>::
 p() const {
-  nassertr(!this->was_deleted(), (To *)NULL);
+  assert(!this->was_deleted());
   return (To *)WeakPointerToBase<T>::_void_ptr;
 }
 
@@ -208,7 +208,7 @@ WeakConstPointerTo(const WeakConstPointerTo<T> &copy) :
 template<class T>
 INLINE const TYPENAME WeakConstPointerTo<T>::To &WeakConstPointerTo<T>::
 operator *() const {
-  nassertr(!this->was_deleted(), *((To *)NULL));
+  assert(!this->was_deleted());
   return *((To *)WeakPointerToBase<T>::_void_ptr);
 }
 
@@ -218,7 +218,7 @@ operator *() const {
 template<class T>
 INLINE const TYPENAME WeakConstPointerTo<T>::To *WeakConstPointerTo<T>::
 operator -> () const {
-  nassertr(!this->was_deleted(), (To *)NULL);
+  assert(!this->was_deleted());
   return (To *)WeakPointerToBase<T>::_void_ptr;
 }
 
@@ -232,7 +232,7 @@ operator -> () const {
 template<class T>
 INLINE WeakConstPointerTo<T>::
 operator const T * () const {
-  nassertr(!this->was_deleted(), (To *)NULL);
+  assert(!this->was_deleted());
   return (To *)WeakPointerToBase<T>::_void_ptr;
 }
 
@@ -269,7 +269,7 @@ lock() const {
 template<class T>
 INLINE const TYPENAME WeakConstPointerTo<T>::To *WeakConstPointerTo<T>::
 p() const {
-  nassertr(!this->was_deleted(), (To *)NULL);
+  assert(!this->was_deleted());
   return (To *)WeakPointerToBase<T>::_void_ptr;
 }
 

+ 0 - 4
panda/src/putil/cachedTypedWritableReferenceCount.I

@@ -49,8 +49,6 @@ CachedTypedWritableReferenceCount(const CachedTypedWritableReferenceCount &copy)
  */
 INLINE void CachedTypedWritableReferenceCount::
 operator = (const CachedTypedWritableReferenceCount &copy) {
-  nassertv(this != NULL);
-
   // If this assertion fails, our own pointer was recently deleted.  Possibly
   // you used a real pointer instead of a PointerTo at some point, and the
   // object was deleted when the PointerTo went out of scope.  Maybe you tried
@@ -71,8 +69,6 @@ operator = (const CachedTypedWritableReferenceCount &copy) {
  */
 INLINE CachedTypedWritableReferenceCount::
 ~CachedTypedWritableReferenceCount() {
-  nassertv(this != NULL);
-
   // If this assertion fails, we're trying to delete an object that was just
   // deleted.  Possibly you used a real pointer instead of a PointerTo at some
   // point, and the object was deleted when the PointerTo went out of scope.

+ 0 - 2
panda/src/putil/cachedTypedWritableReferenceCount.cxx

@@ -21,8 +21,6 @@ TypeHandle CachedTypedWritableReferenceCount::_type_handle;
  */
 bool CachedTypedWritableReferenceCount::
 do_test_ref_count_integrity() const {
-  nassertr(this != NULL, false);
-
   // If this assertion fails, we're trying to delete an object that was just
   // deleted.  Possibly you used a real pointer instead of a PointerTo at some
   // point, and the object was deleted when the PointerTo went out of scope.

+ 0 - 4
panda/src/putil/nodeCachedReferenceCount.I

@@ -49,8 +49,6 @@ NodeCachedReferenceCount(const NodeCachedReferenceCount &copy) : CachedTypedWrit
  */
 INLINE void NodeCachedReferenceCount::
 operator = (const NodeCachedReferenceCount &copy) {
-  nassertv(this != NULL);
-
   // If this assertion fails, our own pointer was recently deleted.  Possibly
   // you used a real pointer instead of a PointerTo at some point, and the
   // object was deleted when the PointerTo went out of scope.  Maybe you tried
@@ -71,8 +69,6 @@ operator = (const NodeCachedReferenceCount &copy) {
  */
 INLINE NodeCachedReferenceCount::
 ~NodeCachedReferenceCount() {
-  nassertv(this != NULL);
-
   // If this assertion fails, we're trying to delete an object that was just
   // deleted.  Possibly you used a real pointer instead of a PointerTo at some
   // point, and the object was deleted when the PointerTo went out of scope.

+ 0 - 2
panda/src/putil/nodeCachedReferenceCount.cxx

@@ -21,8 +21,6 @@ TypeHandle NodeCachedReferenceCount::_type_handle;
  */
 bool NodeCachedReferenceCount::
 do_test_ref_count_integrity() const {
-  nassertr(this != NULL, false);
-
   // If this assertion fails, we're trying to delete an object that was just
   // deleted.  Possibly you used a real pointer instead of a PointerTo at some
   // point, and the object was deleted when the PointerTo went out of scope.

+ 3 - 1
panda/src/speedtree/speedTreeNode.I

@@ -47,7 +47,9 @@ get_tree(int n) const {
  */
 INLINE const SpeedTreeNode::InstanceList &SpeedTreeNode::
 get_instance_list(int n) const {
-  nassertr(n >= 0 && n < (int)_trees.size(), *(InstanceList *)NULL);
+  // TODO: This should be nassertr instead of assert, but there's nothing we
+  // can really return when the assert fails.
+  assert(n >= 0 && n < (int)_trees.size());
   InstanceList *instance_list = _trees[n];
   return *instance_list;
 }

+ 4 - 2
panda/src/speedtree/speedTreeNode.cxx

@@ -145,8 +145,10 @@ count_total_instances() const {
  */
 SpeedTreeNode::InstanceList &SpeedTreeNode::
 add_tree(const STTree *tree) {
-  nassertr(is_valid(), *(InstanceList *)NULL);
-  nassertr(tree->is_valid(), *(InstanceList *)NULL);
+  // TODO: These should be nassertr instead of assert, but there's nothing we
+  // can really return when the assert fails.
+  assert(is_valid());
+  assert(tree->is_valid());
 
   InstanceList ilist(tree);
   Trees::iterator ti = _trees.find(&ilist);