]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include: Use ceph_assert for asserts
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 23 Aug 2018 15:16:52 +0000 (11:16 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 27 Aug 2018 13:09:01 +0000 (09:09 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
18 files changed:
src/include/CompatSet.h
src/include/Context.h
src/include/buffer.h
src/include/compact_map.h
src/include/compact_set.h
src/include/cpp-btree/btree.h
src/include/denc.h
src/include/elist.h
src/include/encoding.h
src/include/filepath.h
src/include/frag.h
src/include/interval_set.h
src/include/lru.h
src/include/mempool.h
src/include/on_exit.h
src/include/rangeset.h
src/include/util.h
src/include/xlist.h

index 47f86a4e722f753a9d3e59b7b2940bcbbbae0380..a9e15f76f5df76671ef12215072d038b8eaa9fb8 100644 (file)
@@ -46,8 +46,8 @@ struct CompatSet {
     friend std::ostream& operator<<(std::ostream& out, const CompatSet& compat);
     FeatureSet() : mask(1), names() {}
     void insert(const Feature& f) {
-      assert(f.id > 0);
-      assert(f.id < 64);
+      ceph_assert(f.id > 0);
+      ceph_assert(f.id < 64);
       mask |= ((uint64_t)1<<f.id);
       names[f.id] = f.name;
     }
@@ -63,7 +63,7 @@ struct CompatSet {
      */
     std::string get_name(uint64_t const f) const {
       std::map<uint64_t, std::string>::const_iterator i = names.find(f);
-      assert(i != names.end());
+      ceph_assert(i != names.end());
       return i->second;
     }
 
index 4cd77850cb67710788d339c91ef738ed6e6e2545..b5e582702f6029d6ad7a2628db2c055ea66378e7 100644 (file)
@@ -276,7 +276,7 @@ private:
   void sub_finish(ContextType* sub, int r) {
     lock.Lock();
 #ifdef DEBUG_GATHER
-    assert(waitfor.count(sub));
+    ceph_assert(waitfor.count(sub));
     waitfor.erase(sub);
 #endif
     --sub_existing_count;
@@ -338,12 +338,12 @@ public:
   }
   void set_finisher(ContextType *onfinish_) {
     Mutex::Locker l(lock);
-    assert(!onfinish);
+    ceph_assert(!onfinish);
     onfinish = onfinish_;
   }
   void activate() {
     lock.Lock();
-    assert(activated == false);
+    ceph_assert(activated == false);
     activated = true;
     if (sub_existing_count != 0) {
       lock.Unlock();
@@ -354,7 +354,7 @@ public:
   }
   ContextType *new_sub() {
     Mutex::Locker l(lock);
-    assert(activated == false);
+    ceph_assert(activated == false);
     sub_created_count++;
     sub_existing_count++;
     ContextType *s = new C_GatherSub(this);
@@ -425,7 +425,7 @@ public:
   }
   ~C_GatherBuilderBase() {
     if (c_gather) {
-      assert(activated); // Don't forget to activate your C_Gather!
+      ceph_assert(activated); // Don't forget to activate your C_Gather!
     }
     else {
       delete finisher;
@@ -440,7 +440,7 @@ public:
   void activate() {
     if (!c_gather)
       return;
-    assert(finisher != NULL);
+    ceph_assert(finisher != NULL);
     activated = true;
     c_gather->activate();
   }
@@ -456,13 +456,13 @@ public:
     return (c_gather != NULL);
   }
   int num_subs_created() {
-    assert(!activated);
+    ceph_assert(!activated);
     if (c_gather == NULL)
       return 0;
     return c_gather->get_sub_created_count();
   }
   int num_subs_remaining() {
-    assert(!activated);
+    ceph_assert(!activated);
     if (c_gather == NULL)
       return 0;
     return c_gather->get_sub_existing_count();
index fec3a2aeeeea022c3485a4e06132772059e1195c..c35f262a9abb6984e3f24be576ddc76b7598f6ad 100644 (file)
@@ -345,11 +345,19 @@ namespace buffer CEPH_BUFFER_API {
 
     // modifiers
     void set_offset(unsigned o) {
+#ifdef __CEPH__
+      ceph_assert(raw_length() >= o);
+#else
       assert(raw_length() >= o);
+#endif
       _off = o;
     }
     void set_length(unsigned l) {
+#ifdef __CEPH__
+      ceph_assert(raw_length() >= l);
+#else
       assert(raw_length() >= l);
+#endif
       _len = l;
     }
 
@@ -749,7 +757,11 @@ namespace buffer CEPH_BUFFER_API {
           it++) {
        len += (*it).length();
       }
+#ifdef __CEPH__
+      ceph_assert(len == _len);
+#else
       assert(len == _len);
+#endif // __CEPH__
 #endif
       return _len;
     }
@@ -927,7 +939,7 @@ namespace buffer CEPH_BUFFER_API {
     int write_fd_zero_copy(int fd) const;
     template<typename VectorT>
     void prepare_iov(VectorT *piov) const {
-      assert(_buffers.size() <= IOV_MAX);
+      ceph_assert(_buffers.size() <= IOV_MAX);
       piov->resize(_buffers.size());
       unsigned n = 0;
       for (auto& p : _buffers) {
index 39a9ab4f40c76bf712359ff1e5696dc690a33334..3ccb798227d929b5e62a21c9c874dba7e04c1eee 100644 (file)
@@ -183,7 +183,7 @@ public:
   }
   iterator erase (iterator p) {
     if (map) {
-      assert(this == p.map);
+      ceph_assert(this == p.map);
       auto it = map->erase(p.it);
       if (map->empty()) {
         free_internal();
index 10510a8e3435b12182816cb148e3f723eb598849..ba743fb0e1cd05a18af8a13700a5d58b0974846c 100644 (file)
@@ -142,7 +142,7 @@ public:
   }
   iterator erase (iterator p) {
     if (set) {
-      assert(this == p.set);
+      ceph_assert(this == p.set);
       auto it = set->erase(p.it);
       if (set->empty()) {
         free_internal();
index 48635159dc0baa8d9cd78b777311ea54175e49c0..22872b6ba30e7e9cb1ac9b4c51f507256c6f3ccd 100644 (file)
 #ifndef UTIL_BTREE_BTREE_H__
 #define UTIL_BTREE_BTREE_H__
 
-#include <assert.h>
 #include <stddef.h>
 #include <string.h>
 #include <sys/types.h>
 #include <string>
 #include <utility>
 
+#include "include/assert.h"
+
 namespace btree {
 
 // Inside a btree method, if we just call swap(), it will choose the
@@ -533,7 +534,7 @@ class btree_node {
   // be a leaf.
   bool is_root() const { return parent()->leaf(); }
   void make_root() {
-    assert(parent()->is_root());
+    ceph_assert(parent()->is_root());
     fields_.parent = fields_.parent->parent();
   }
 
@@ -1263,7 +1264,7 @@ class btree : public Params::key_compare {
   }
   void delete_internal_node(node_type *node) {
     node->destroy();
-    assert(node != root());
+    ceph_assert(node != root());
     mutable_internal_allocator()->deallocate(
         reinterpret_cast<char*>(node), sizeof(internal_fields));
   }
@@ -1419,7 +1420,7 @@ class btree : public Params::key_compare {
 // btree_node methods
 template <typename P>
 inline void btree_node<P>::insert_value(int i, const value_type &x) {
-  assert(i <= count());
+  ceph_assert(i <= count());
   value_init(count(), x);
   for (int j = count(); j > i; --j) {
     value_swap(j, this, j - 1);
@@ -1439,7 +1440,7 @@ inline void btree_node<P>::insert_value(int i, const value_type &x) {
 template <typename P>
 inline void btree_node<P>::remove_value(int i) {
   if (!leaf()) {
-    assert(child(i + 1)->count() == 0);
+    ceph_assert(child(i + 1)->count() == 0);
     for (int j = i + 1; j < count(); ++j) {
       *mutable_child(j) = child(j + 1);
       child(j)->set_position(j);
@@ -1456,11 +1457,11 @@ inline void btree_node<P>::remove_value(int i) {
 
 template <typename P>
 void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
-  assert(parent() == src->parent());
-  assert(position() + 1 == src->position());
-  assert(src->count() >= count());
-  assert(to_move >= 1);
-  assert(to_move <= src->count());
+  ceph_assert(parent() == src->parent());
+  ceph_assert(position() + 1 == src->position());
+  ceph_assert(src->count() >= count());
+  ceph_assert(to_move >= 1);
+  ceph_assert(to_move <= src->count());
 
   // Make room in the left node for the new values.
   for (int i = 0; i < to_move; ++i) {
@@ -1490,7 +1491,7 @@ void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
       set_child(1 + count() + i, src->child(i));
     }
     for (int i = 0; i <= src->count() - to_move; ++i) {
-      assert(i + to_move <= src->max_count());
+      ceph_assert(i + to_move <= src->max_count());
       src->set_child(i, src->child(i + to_move));
       *src->mutable_child(i + to_move) = NULL;
     }
@@ -1503,11 +1504,11 @@ void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
 
 template <typename P>
 void btree_node<P>::rebalance_left_to_right(btree_node *dest, int to_move) {
-  assert(parent() == dest->parent());
-  assert(position() + 1 == dest->position());
-  assert(count() >= dest->count());
-  assert(to_move >= 1);
-  assert(to_move <= count());
+  ceph_assert(parent() == dest->parent());
+  ceph_assert(position() + 1 == dest->position());
+  ceph_assert(count() >= dest->count());
+  ceph_assert(to_move >= 1);
+  ceph_assert(to_move <= count());
 
   // Make room in the right node for the new values.
   for (int i = 0; i < to_move; ++i) {
@@ -1548,7 +1549,7 @@ void btree_node<P>::rebalance_left_to_right(btree_node *dest, int to_move) {
 
 template <typename P>
 void btree_node<P>::split(btree_node *dest, int insert_position) {
-  assert(dest->count() == 0);
+  ceph_assert(dest->count() == 0);
 
   // We bias the split based on the position being inserted. If we're
   // inserting at the beginning of the left node then bias the split to put
@@ -1562,7 +1563,7 @@ void btree_node<P>::split(btree_node *dest, int insert_position) {
     dest->set_count(count() / 2);
   }
   set_count(count() - dest->count());
-  assert(count() >= 1);
+  ceph_assert(count() >= 1);
 
   // Move values from the left sibling to the right sibling.
   for (int i = 0; i < dest->count(); ++i) {
@@ -1580,7 +1581,7 @@ void btree_node<P>::split(btree_node *dest, int insert_position) {
 
   if (!leaf()) {
     for (int i = 0; i <= dest->count(); ++i) {
-      assert(child(count() + i + 1) != NULL);
+      ceph_assert(child(count() + i + 1) != NULL);
       dest->set_child(i, child(count() + i + 1));
       *mutable_child(count() + i + 1) = NULL;
     }
@@ -1589,8 +1590,8 @@ void btree_node<P>::split(btree_node *dest, int insert_position) {
 
 template <typename P>
 void btree_node<P>::merge(btree_node *src) {
-  assert(parent() == src->parent());
-  assert(position() + 1 == src->position());
+  ceph_assert(parent() == src->parent());
+  ceph_assert(position() + 1 == src->position());
 
   // Move the delimiting value to the left node.
   value_init(count());
@@ -1621,7 +1622,7 @@ void btree_node<P>::merge(btree_node *src) {
 
 template <typename P>
 void btree_node<P>::swap(btree_node *x) {
-  assert(leaf() == x->leaf());
+  ceph_assert(leaf() == x->leaf());
 
   // Swap the values.
   for (int i = count(); i < x->count(); ++i) {
@@ -1663,10 +1664,10 @@ void btree_node<P>::swap(btree_node *x) {
 template <typename N, typename R, typename P>
 void btree_iterator<N, R, P>::increment_slow() {
   if (node->leaf()) {
-    assert(position >= node->count());
+    ceph_assert(position >= node->count());
     self_type save(*this);
     while (position == node->count() && !node->is_root()) {
-      assert(node->parent()->child(node->position()) == node);
+      ceph_assert(node->parent()->child(node->position()) == node);
       position = node->position();
       node = node->parent();
     }
@@ -1674,7 +1675,7 @@ void btree_iterator<N, R, P>::increment_slow() {
       *this = save;
     }
   } else {
-    assert(position < node->count());
+    ceph_assert(position < node->count());
     node = node->child(position + 1);
     while (!node->leaf()) {
       node = node->child(0);
@@ -1703,10 +1704,10 @@ void btree_iterator<N, R, P>::increment_by(int count) {
 template <typename N, typename R, typename P>
 void btree_iterator<N, R, P>::decrement_slow() {
   if (node->leaf()) {
-    assert(position <= -1);
+    ceph_assert(position <= -1);
     self_type save(*this);
     while (position < 0 && !node->is_root()) {
-      assert(node->parent()->child(node->position()) == node);
+      ceph_assert(node->parent()->child(node->position()) == node);
       position = node->position() - 1;
       node = node->parent();
     }
@@ -1714,7 +1715,7 @@ void btree_iterator<N, R, P>::decrement_slow() {
       *this = save;
     }
   } else {
-    assert(position >= 0);
+    ceph_assert(position >= 0);
     node = node->child(position);
     while (!node->leaf()) {
       node = node->child(node->count());
@@ -1865,8 +1866,8 @@ typename btree<P>::iterator btree<P>::erase(iterator iter) {
     // Deletion of a value on an internal node. Swap the key with the largest
     // value of our left child. This is easy, we just decrement iter.
     iterator tmp_iter(iter--);
-    assert(iter.node->leaf());
-    assert(!compare_keys(tmp_iter.key(), iter.key()));
+    ceph_assert(iter.node->leaf());
+    ceph_assert(!compare_keys(tmp_iter.key(), iter.key()));
     iter.node->value_swap(iter.position, tmp_iter.node, tmp_iter.position);
     internal_delete = true;
     --*mutable_size();
@@ -1970,15 +1971,15 @@ void btree<P>::swap(self_type &x) {
 template <typename P>
 void btree<P>::verify() const {
   if (root() != NULL) {
-    assert(size() == internal_verify(root(), NULL, NULL));
-    assert(leftmost() == (++const_iterator(root(), -1)).node);
-    assert(rightmost() == (--const_iterator(root(), root()->count())).node);
-    assert(leftmost()->leaf());
-    assert(rightmost()->leaf());
+    ceph_assert(size() == internal_verify(root(), NULL, NULL));
+    ceph_assert(leftmost() == (++const_iterator(root(), -1)).node);
+    ceph_assert(rightmost() == (--const_iterator(root(), root()->count())).node);
+    ceph_assert(leftmost()->leaf());
+    ceph_assert(rightmost()->leaf());
   } else {
-    assert(size() == 0);
-    assert(leftmost() == NULL);
-    assert(rightmost() == NULL);
+    ceph_assert(size() == 0);
+    ceph_assert(leftmost() == NULL);
+    ceph_assert(rightmost() == NULL);
   }
 }
 
@@ -1986,7 +1987,7 @@ template <typename P>
 void btree<P>::rebalance_or_split(iterator *iter) {
   node_type *&node = iter->node;
   int &insert_position = iter->position;
-  assert(node->count() == node->max_count());
+  ceph_assert(node->count() == node->max_count());
 
   // First try to make room on the node by rebalancing.
   node_type *parent = node->parent();
@@ -2006,14 +2007,14 @@ void btree<P>::rebalance_or_split(iterator *iter) {
             ((left->count() + to_move) < left->max_count())) {
           left->rebalance_right_to_left(node, to_move);
 
-          assert(node->max_count() - node->count() == to_move);
+          ceph_assert(node->max_count() - node->count() == to_move);
           insert_position = insert_position - to_move;
           if (insert_position < 0) {
             insert_position = insert_position + left->count() + 1;
             node = left;
           }
 
-          assert(node->count() < node->max_count());
+          ceph_assert(node->count() < node->max_count());
           return;
         }
       }
@@ -2039,7 +2040,7 @@ void btree<P>::rebalance_or_split(iterator *iter) {
             node = right;
           }
 
-          assert(node->count() < node->max_count());
+          ceph_assert(node->count() < node->max_count());
           return;
         }
       }
@@ -2059,7 +2060,7 @@ void btree<P>::rebalance_or_split(iterator *iter) {
       parent = new_internal_root_node();
       parent->set_child(0, root());
       *mutable_root() = parent;
-      assert(*mutable_rightmost() == parent->child(0));
+      ceph_assert(*mutable_rightmost() == parent->child(0));
     } else {
       // The root node is an internal node. We do not want to create a new root
       // node because the root node is special and holds the size of the tree
@@ -2163,7 +2164,7 @@ void btree<P>::try_shrink() {
   }
   // Deleted the last item on the root node, shrink the height of the tree.
   if (root()->leaf()) {
-    assert(size() == 0);
+    ceph_assert(size() == 0);
     delete_leaf_node(root());
     *mutable_root() = NULL;
   } else {
@@ -2209,7 +2210,7 @@ btree<P>::internal_insert(iterator iter, const value_type &v) {
     if (iter.node->max_count() < kNodeValues) {
       // Insertion into the root where the root is smaller that the full node
       // size. Simply grow the size of the root node.
-      assert(iter.node == root());
+      ceph_assert(iter.node == root());
       iter.node = new_leaf_root_node(
           std::min<int>(kNodeValues, 2 * iter.node->max_count()));
       iter.node->swap(root());
@@ -2364,23 +2365,23 @@ void btree<P>::internal_dump(
 template <typename P>
 int btree<P>::internal_verify(
     const node_type *node, const key_type *lo, const key_type *hi) const {
-  assert(node->count() > 0);
-  assert(node->count() <= node->max_count());
+  ceph_assert(node->count() > 0);
+  ceph_assert(node->count() <= node->max_count());
   if (lo) {
-    assert(!compare_keys(node->key(0), *lo));
+    ceph_assert(!compare_keys(node->key(0), *lo));
   }
   if (hi) {
-    assert(!compare_keys(*hi, node->key(node->count() - 1)));
+    ceph_assert(!compare_keys(*hi, node->key(node->count() - 1)));
   }
   for (int i = 1; i < node->count(); ++i) {
-    assert(!compare_keys(node->key(i), node->key(i - 1)));
+    ceph_assert(!compare_keys(node->key(i), node->key(i - 1)));
   }
   int count = node->count();
   if (!node->leaf()) {
     for (int i = 0; i <= node->count(); ++i) {
-      assert(node->child(i) != NULL);
-      assert(node->child(i)->parent() == node);
-      assert(node->child(i)->position() == i);
+      ceph_assert(node->child(i) != NULL);
+      ceph_assert(node->child(i)->parent() == node);
+      ceph_assert(node->child(i)->position() == i);
       count += internal_verify(
           node->child(i),
           (i == 0) ? lo : &node->key(i - 1),
index 3a332ed48bfbc57b8f87d89631f998f198ec9fe5..b1bd7802ddb657fc8ae7f7f73b774c8b0477f458 100644 (file)
@@ -1631,7 +1631,7 @@ inline std::enable_if_t<traits::supported && !traits::featured> decode_nohead(
                           uint32_t *struct_len) {                      \
     const char *pos = p.get_pos();                                     \
     char *end = *start_pos + *struct_len;                              \
-    assert(pos <= end);                                                        \
+    ceph_assert(pos <= end);                                                   \
     if (pos < end) {                                                   \
       p.advance(end - pos);                                            \
     }                                                                  \
index 6719b9c92d84053196b77780f8895ff5d0075fb4..38be35dbff33a0b3a994cf108341d9accfe288a1 100644 (file)
@@ -36,7 +36,7 @@ public:
     
     item(T i=0) : _prev(this), _next(this) {}
     ~item() { 
-      assert(!is_on_list());
+      ceph_assert(!is_on_list());
     }
 
     item(const item& other) = delete;
@@ -48,7 +48,7 @@ public:
 
     bool remove_myself() {
       if (_next == this) {
-       assert(_prev == this);
+       ceph_assert(_prev == this);
        return false;
       }
       _next->_prev = _prev;
@@ -58,14 +58,14 @@ public:
     }
 
     void insert_after(item *other) {
-      assert(other->empty());
+      ceph_assert(other->empty());
       other->_prev = this;
       other->_next = _next;
       _next->_prev = other;
       _next = other;
     }
     void insert_before(item *other) {
-      assert(other->empty());
+      ceph_assert(other->empty());
       other->_next = this;
       other->_prev = _prev;
       _prev->_next = other;
@@ -73,7 +73,7 @@ public:
     }
 
     T get_item(size_t offset) {
-      assert(offset);
+      ceph_assert(offset);
       return (T)(((char *)this) - offset); 
     }
   };
@@ -88,7 +88,7 @@ public:
 
   elist(size_t o) : _head(NULL), item_offset(o) {}
   ~elist() { 
-    assert(_head.empty());
+    ceph_assert(_head.empty());
   }
 
   bool empty() const {
@@ -112,20 +112,20 @@ public:
   }
 
   T front(size_t o=0) {
-    assert(!_head.empty());
+    ceph_assert(!_head.empty());
     return _head._next->get_item(o ? o : item_offset);
   }
   T back(size_t o=0) {
-    assert(!_head.empty());
+    ceph_assert(!_head.empty());
     return _head._prev->get_item(o ? o : item_offset);
   }
 
   void pop_front() {
-    assert(!empty());
+    ceph_assert(!empty());
     _head._next->remove_myself();
   }
   void pop_back() {
-    assert(!empty());
+    ceph_assert(!empty());
     _head._prev->remove_myself();
   }
 
@@ -148,14 +148,14 @@ public:
     iterator(item *h, size_t o, mode_t m) :
       head(h), cur(h->_next), next(cur->_next), item_offset(o),
       mode(m) {
-      assert(item_offset > 0);
+      ceph_assert(item_offset > 0);
     }
     T operator*() {
       return cur->get_item(item_offset);
     }
     iterator& operator++() {
-      assert(cur);
-      assert(cur != head);
+      ceph_assert(cur);
+      ceph_assert(cur != head);
       if (mode == MAGIC) {
        // if 'cur' appears to be valid, use that.  otherwise,
        // use cached 'next'.
index 130d5dee379f2d40e7757de77434182daadbbda5..757bde705c7c7e9a310254ab1a693b4d7fa9bb0e 100644 (file)
@@ -520,7 +520,7 @@ inline void decode(T &o, const bufferlist& bl)
 {
   auto p = bl.begin();
   decode(o, p);
-  assert(p.end());
+  ceph_assert(p.end());
 }
 
 // boost optional
index 418aa92a2d6ceceb477301fd11c51e153094aa0b..832016ac1bc89e21ac202b71ba83ee778e748adf 100644 (file)
@@ -134,7 +134,7 @@ class filepath {
 
   const string& last_dentry() const {
     if (bits.empty() && path.length() > 0) parse_bits();
-    assert(!bits.empty());
+    ceph_assert(!bits.empty());
     return bits[ bits.size()-1 ];
   }
 
@@ -186,7 +186,7 @@ class filepath {
     rebuild_path();
   }
   void append(const filepath& a) {
-    assert(a.pure_relative());
+    ceph_assert(a.pure_relative());
     for (unsigned i=0; i<a.depth(); i++) 
       push_dentry(a[i]);
   }
index 23062d6ac6cfee283f690e0110cb688a22d16a21..09cb6e4867e16af2b6f37a7d202d1ad786cbb2bb 100644 (file)
@@ -104,17 +104,17 @@ class frag_t {
   bool contains(frag_t sub) const { return ceph_frag_contains_frag(_enc, sub._enc); }
   bool is_root() const { return bits() == 0; }
   frag_t parent() const {
-    assert(bits() > 0);
+    ceph_assert(bits() > 0);
     return frag_t(ceph_frag_parent(_enc));
   }
 
   // splitting
   frag_t make_child(int i, int nb) const {
-    assert(i < (1<<nb));
+    ceph_assert(i < (1<<nb));
     return frag_t(ceph_frag_make_child(_enc, nb, i));
   }
   void split(int nb, std::list<frag_t>& fragments) const {
-    assert(nb > 0);
+    ceph_assert(nb > 0);
     unsigned nway = 1 << nb;
     for (unsigned i=0; i<nway; i++) 
       fragments.push_back(make_child(i, nb));
@@ -127,7 +127,7 @@ class frag_t {
   bool is_left() const { return ceph_frag_is_left_child(_enc); }
   bool is_right() const { return ceph_frag_is_right_child(_enc); }
   frag_t get_sibling() const {
-    assert(!is_root());
+    ceph_assert(!is_root());
     return frag_t(ceph_frag_sibling(_enc));
   }
 
@@ -135,7 +135,7 @@ class frag_t {
   bool is_leftmost() const { return ceph_frag_is_leftmost(_enc); }
   bool is_rightmost() const { return ceph_frag_is_rightmost(_enc); }
   frag_t next() const {
-    assert(!is_rightmost());
+    ceph_assert(!is_rightmost());
     return frag_t(ceph_frag_next(_enc));
   }
 
@@ -332,7 +332,7 @@ public:
   frag_t operator[](unsigned v) const {
     frag_t t;
     while (1) {
-      assert(t.contains(v));
+      ceph_assert(t.contains(v));
       int nb = get_split(t);
 
       // is this a leaf?
@@ -348,7 +348,7 @@ public:
          break;
        }
       }
-      assert(i < nway);
+      ceph_assert(i < nway);
     }
   }
 
@@ -356,15 +356,15 @@ public:
   // ---------------
   // modifiers
   void split(frag_t x, int b, bool simplify=true) {
-    assert(is_leaf(x));
+    ceph_assert(is_leaf(x));
     _splits[x] = b;
     
     if (simplify)
       try_assimilate_children(get_branch_above(x));
   }
   void merge(frag_t x, int b, bool simplify=true) {
-    assert(!is_leaf(x));
-    assert(_splits[x] == b);
+    ceph_assert(!is_leaf(x));
+    ceph_assert(_splits[x] == b);
     _splits.erase(x);
 
     if (simplify)
@@ -404,7 +404,7 @@ public:
     lgeneric_dout(cct, 10) << "force_to_leaf " << x << " on " << _splits << dendl;
 
     frag_t parent = get_branch_or_leaf(x);
-    assert(parent.bits() <= x.bits());
+    ceph_assert(parent.bits() <= x.bits());
     lgeneric_dout(cct, 10) << "parent is " << parent << dendl;
 
     // do we need to split from parent to x?
@@ -416,10 +416,10 @@ public:
        // easy: split parent (a leaf) by the difference
        lgeneric_dout(cct, 10) << "splitting parent " << parent << " by spread " << spread << dendl;
        split(parent, spread);
-       assert(is_leaf(x));
+       ceph_assert(is_leaf(x));
        return true;
       }
-      assert(nb > spread);
+      ceph_assert(nb > spread);
       
       // add an intermediary split
       merge(parent, nb, false);
@@ -451,7 +451,7 @@ public:
     }
 
     lgeneric_dout(cct, 10) << "force_to_leaf done" << dendl;
-    assert(is_leaf(x));
+    ceph_assert(is_leaf(x));
     return true;
   }
 
index 575ac5ef2f4d53ebecfbc719470d62170dfbfe1b..825bcf2e4d787ccaf304a603c60fd05dab1efc25 100644 (file)
@@ -244,7 +244,7 @@ class interval_set {
 
   void intersection_size_asym(const interval_set &s, const interval_set &l) {
     typename decltype(m)::const_iterator ps = s.m.begin(), pl;
-    assert(ps != s.m.end());
+    ceph_assert(ps != s.m.end());
     T offset = ps->first;
     bool first = true;
     typename decltype(m)::iterator mi = m.begin();
@@ -280,7 +280,7 @@ class interval_set {
 
       T start = std::max<T>(ps->first, pl->first);
       T en = std::min<T>(ps->first + ps->second, offset);
-      assert(en > start);
+      ceph_assert(en > start);
       typename decltype(m)::value_type i{start, en - start};
       mi = m.insert(mi, i);
       _size += i.second;
@@ -376,7 +376,7 @@ class interval_set {
     if (p == m.end()) return false;
     if (p->first > i) return false;
     if (p->first+p->second <= i) return false;
-    assert(p->first <= i && p->first+p->second > i);
+    ceph_assert(p->first <= i && p->first+p->second > i);
     if (pstart)
       *pstart = p->first;
     if (plen)
@@ -388,7 +388,7 @@ class interval_set {
     if (p == m.end()) return false;
     if (p->first > start) return false;
     if (p->first+p->second <= start) return false;
-    assert(p->first <= start && p->first+p->second > start);
+    ceph_assert(p->first <= start && p->first+p->second > start);
     if (p->first+p->second < start+len) return false;
     return true;
   }
@@ -406,12 +406,12 @@ class interval_set {
     return m.empty();
   }
   T range_start() const {
-    assert(!empty());
+    ceph_assert(!empty());
     typename Map::const_iterator p = m.begin();
     return p->first;
   }
   T range_end() const {
-    assert(!empty());
+    ceph_assert(!empty());
     typename Map::const_iterator p = m.end();
     p--;
     return p->first+p->second;
@@ -419,20 +419,20 @@ class interval_set {
 
   // interval start after p (where p not in set)
   bool starts_after(T i) const {
-    assert(!contains(i));
+    ceph_assert(!contains(i));
     typename Map::const_iterator p = find_inc(i);
     if (p == m.end()) return false;
     return true;
   }
   T start_after(T i) const {
-    assert(!contains(i));
+    ceph_assert(!contains(i));
     typename Map::const_iterator p = find_inc(i);
     return p->first;
   }
 
   // interval end that contains start
   T end_after(T start) const {
-    assert(contains(start));
+    ceph_assert(contains(start));
     typename Map::const_iterator p = find_inc(start);
     return p->first+p->second;
   }
@@ -443,7 +443,7 @@ class interval_set {
 
   void insert(T start, T len, T *pstart=0, T *plen=0) {
     //cout << "insert " << start << "~" << len << endl;
-    assert(len > 0);
+    ceph_assert(len > 0);
     _size += len;
     typename Map::iterator p = find_adj_m(start);
     if (p == m.end()) {
@@ -486,7 +486,7 @@ class interval_set {
           m.erase(p);
           m[start] = len + psecond;  // append to front
         } else {
-          assert(p->first > start+len);
+          ceph_assert(p->first > start+len);
          if (pstart)
            *pstart = start;
          if (plen)
@@ -504,7 +504,7 @@ class interval_set {
   
   void erase(iterator &i) {
     _size -= i.get_len();
-    assert(_size >= 0);
+    ceph_assert(_size >= 0);
     m.erase(i._iter);
   }
 
@@ -517,13 +517,13 @@ class interval_set {
     typename Map::iterator p = find_inc_m(start);
 
     _size -= len;
-    assert(_size >= 0);
+    ceph_assert(_size >= 0);
 
-    assert(p != m.end());
-    assert(p->first <= start);
+    ceph_assert(p != m.end());
+    ceph_assert(p->first <= start);
 
     T before = start - p->first;
-    assert(p->second >= before+len);
+    ceph_assert(p->second >= before+len);
     T after = p->second - before - len;
     if (before) {
       if (claim && claim(p->first, before)) {
@@ -560,8 +560,8 @@ class interval_set {
 
 
   void intersection_of(const interval_set &a, const interval_set &b) {
-    assert(&a != this);
-    assert(&b != this);
+    ceph_assert(&a != this);
+    ceph_assert(&b != this);
     clear();
 
     const interval_set *s, *l;
@@ -610,7 +610,7 @@ class interval_set {
 
       T start = std::max(pa->first, pb->first);
       T en = std::min(pa->first+pa->second, pb->first+pb->second);
-      assert(en > start);
+      ceph_assert(en > start);
       typename decltype(m)::value_type i{start, en - start};
       mi = m.insert(mi, i);
       _size += i.second;
@@ -627,8 +627,8 @@ class interval_set {
   }
 
   void union_of(const interval_set &a, const interval_set &b) {
-    assert(&a != this);
-    assert(&b != this);
+    ceph_assert(&a != this);
+    ceph_assert(&b != this);
     clear();
     
     //cout << "union_of" << endl;
index c52cb567bf158509044c924e90d500d8ad15edb5..1e30cdfe8ca22be394831f4b30f1ad12ae2f7b6c 100644 (file)
@@ -62,12 +62,12 @@ public:
     while (!pintail.empty()) {
       lru_remove(pintail.front());
     }
-    assert(num_pinned == 0);
+    ceph_assert(num_pinned == 0);
   }
 
   // insert at top of lru
   void lru_insert_top(LRUObject *o) {
-    assert(!o->lru);
+    ceph_assert(!o->lru);
     o->lru = this;
     top.push_front(&o->lru_link);
     if (o->lru_pinned) num_pinned++;
@@ -76,7 +76,7 @@ public:
 
   // insert at mid point in lru
   void lru_insert_mid(LRUObject *o) {
-    assert(!o->lru);
+    ceph_assert(!o->lru);
     o->lru = this;
     bottom.push_front(&o->lru_link);
     if (o->lru_pinned) num_pinned++;
@@ -85,7 +85,7 @@ public:
 
   // insert at bottom of lru
   void lru_insert_bot(LRUObject *o) {
-    assert(!o->lru);
+    ceph_assert(!o->lru);
     o->lru = this;
     bottom.push_back(&o->lru_link);
     if (o->lru_pinned) num_pinned++;
@@ -96,7 +96,7 @@ public:
   LRUObject *lru_remove(LRUObject *o) {
     if (!o->lru) return o;
     auto list = o->lru_link.get_list();
-    assert(list == &top || list == &bottom || list == &pintail);
+    ceph_assert(list == &top || list == &bottom || list == &pintail);
     o->lru_link.remove_myself();
     if (o->lru_pinned) num_pinned--;
     o->lru = nullptr;
@@ -109,9 +109,9 @@ public:
     if (!o->lru) {
       lru_insert_top(o);
     } else {
-      assert(o->lru == this);
+      ceph_assert(o->lru == this);
       auto list = o->lru_link.get_list();
-      assert(list == &top || list == &bottom || list == &pintail);
+      ceph_assert(list == &top || list == &bottom || list == &pintail);
       top.push_front(&o->lru_link);
       adjust();
     }
@@ -123,9 +123,9 @@ public:
     if (!o->lru) {
       lru_insert_mid(o);
     } else {
-      assert(o->lru == this);
+      ceph_assert(o->lru == this);
       auto list = o->lru_link.get_list();
-      assert(list == &top || list == &bottom || list == &pintail);
+      ceph_assert(list == &top || list == &bottom || list == &pintail);
       if (list == &top) return false;
       bottom.push_front(&o->lru_link);
       adjust();
@@ -138,9 +138,9 @@ public:
     if (!o->lru) {
       lru_insert_bot(o);
     } else {
-      assert(o->lru == this);
+      ceph_assert(o->lru == this);
       auto list = o->lru_link.get_list();
-      assert(list == &top || list == &bottom || list == &pintail);
+      ceph_assert(list == &top || list == &bottom || list == &pintail);
       bottom.push_back(&o->lru_link);
       adjust();
     }
index 886fbf44032b7a7a4ad1d088563b81951eb09075..a07d167e36a99d462e45871409f7fc708c55e217 100644 (file)
@@ -514,10 +514,10 @@ bool operator!=(const std::vector<T, mempool::pool_allocator<pool_index, T>>& lh
 #define MEMPOOL_CLASS_HELPERS()                                                \
   void *operator new(size_t size);                                     \
   void *operator new[](size_t size) noexcept {                         \
-    assert(0 == "no array new");                                       \
+    ceph_assert(0 == "no array new");                                  \
     return nullptr; }                                                  \
   void  operator delete(void *);                                       \
-  void  operator delete[](void *) { assert(0 == "no array delete"); }
+  void  operator delete[](void *) { ceph_assert(0 == "no array delete"); }
 
 
 // Use this in some particular .cc file to match each class with a
index 47d222c7cc132f91e7b2042c61d2f695f9de5635..1642c6820405388e8b0b18fa2f4472e99edd498f 100644 (file)
@@ -2,9 +2,9 @@
 #define CEPH_ON_EXIT_H
 
 #include <pthread.h>
-#include <assert.h>
 #include <vector>
 
+#include "include/assert.h"
 /*
  * Create a static instance at the file level to get callbacks called when the
  * process exits via main() or exit().
@@ -15,8 +15,8 @@ class OnExitManager {
     typedef void (*callback_t)(void *arg);
 
     OnExitManager() {
-      [[maybe_unused]] int ret = pthread_mutex_init(&lock_, NULL);
-      assert(ret == 0);
+      int ret = pthread_mutex_init(&lock_, NULL);
+      ceph_assert(ret == 0);
     }
 
     ~OnExitManager() {
index 51c1c840551d82c0280da32751220390601e1a5e..e7e3d047c72aa40a76d154944e91a0ba45d71745 100644 (file)
@@ -141,12 +141,12 @@ public:
   // ...
   bool contains(T val) {
     if (theset.get_range_for(val) == theset.ranges.end()) return false;
-    assert(!empty());
+    ceph_assert(!empty());
     return true;
   }
   
   void insert(T val) {
-    assert(!contains(val));
+    ceph_assert(!contains(val));
 
     map_iterator left = theset.get_range_for(val-1);
     map_iterator right = theset.get_range_for(val+1);
@@ -187,24 +187,24 @@ public:
 
   bool empty() {
     if (theset.ranges.empty()) {
-      assert(_size == 0);
+      ceph_assert(_size == 0);
       return true;
     }
-    assert(_size>0);
+    ceph_assert(_size>0);
     return false;
   }
 
   
   T first() {
-    assert(!empty());
+    ceph_assert(!empty());
     map_iterator it = theset.ranges.begin();
     return it->first;
   }
   
   void erase(T val) {
-    assert(contains(val));
+    ceph_assert(contains(val));
     map_iterator it = theset.get_range_for(val);
-    assert(it != theset.ranges.end());
+    ceph_assert(it != theset.ranges.end());
     
     // entire range
     if (val == it->first && val == it->second) {
index caccaa9ca317f41fa3a70b68b36aa5b72da719ae..62d4b6f35d59948e09acb08238f7e420060bcf7b 100644 (file)
@@ -34,7 +34,7 @@ struct ceph_data_stats
   { }
 
   void dump(Formatter *f) const {
-    assert(f != NULL);
+    ceph_assert(f != NULL);
     f->dump_int("total", byte_total);
     f->dump_int("used", byte_used);
     f->dump_int("avail", byte_avail);
index 1d06e55cafa2f5da25ec3634aab1b95680bd8e39..0204155e169c53cddd61d2760cfeff8f60a9c69f 100644 (file)
 #ifndef CEPH_XLIST_H
 #define CEPH_XLIST_H
 
-#include "include/assert.h"
 #include <iterator>
 #include <cstdlib>
 #include <ostream>
 
+#include "include/assert.h"
+
 template<typename T>
 class xlist {
 public:
@@ -30,7 +31,7 @@ public:
     
     item(T i) : _item(i), _prev(0), _next(0), _list(0) {}
     ~item() { 
-      assert(!is_on_list());
+      ceph_assert(!is_on_list());
       //remove_myself();
     }
 
@@ -43,17 +44,17 @@ public:
     bool remove_myself() {
       if (_list) {
        _list->remove(this);
-       assert(_list == 0);
+       ceph_assert(_list == 0);
        return true;
       } else
        return false;
     }
     void move_to_front() {
-      assert(_list);
+      ceph_assert(_list);
       _list->push_front(this);
     }
     void move_to_back() {
-      assert(_list);
+      ceph_assert(_list);
       _list->push_back(this);
     }
   };
@@ -74,24 +75,24 @@ public:
 
   xlist() : _front(0), _back(0), _size(0) {}
   ~xlist() { 
-    assert(_size == 0);
-    assert(_front == 0);
-    assert(_back == 0);
+    ceph_assert(_size == 0);
+    ceph_assert(_front == 0);
+    ceph_assert(_back == 0);
   }
 
   size_t size() const {
-    assert((bool)_front == (bool)_size);
+    ceph_assert((bool)_front == (bool)_size);
     return _size;
   }
   bool empty() const { 
-    assert((bool)_front == (bool)_size);
+    ceph_assert((bool)_front == (bool)_size);
     return _front == 0; 
   }
 
   void clear() {
     while (_front)
       remove(_front);
-    assert((bool)_front == (bool)_size);
+    ceph_assert((bool)_front == (bool)_size);
   }
 
   void push_front(item *i) {
@@ -123,7 +124,7 @@ public:
     _size++;
   }
   void remove(item *i) {
-    assert(i->_list == this);
+    ceph_assert(i->_list == this);
     
     if (i->_prev)
       i->_prev->_next = i->_next;
@@ -137,7 +138,7 @@ public:
 
     i->_list = 0;
     i->_next = i->_prev = 0;
-    assert((bool)_front == (bool)_size);
+    ceph_assert((bool)_front == (bool)_size);
   }
 
   T front() { return static_cast<T>(_front->_item); }
@@ -147,11 +148,11 @@ public:
   const T back() const { return static_cast<const T>(_back->_item); }
 
   void pop_front() {
-    assert(!empty());
+    ceph_assert(!empty());
     remove(_front);
   }
   void pop_back() {
-    assert(!empty());
+    ceph_assert(!empty());
     remove(_back);
   }
 
@@ -162,8 +163,8 @@ public:
     iterator(item *i = 0) : cur(i) {}
     T operator*() { return static_cast<T>(cur->_item); }
     iterator& operator++() {
-      assert(cur);
-      assert(cur->_list);
+      ceph_assert(cur);
+      ceph_assert(cur->_list);
       cur = cur->_next;
       return *this;
     }
@@ -186,8 +187,8 @@ public:
     const_iterator(item *i = 0) : cur(i) {}
     const T operator*() { return static_cast<const T>(cur->_item); }
     const_iterator& operator++() {
-      assert(cur);
-      assert(cur->_list);
+      ceph_assert(cur);
+      ceph_assert(cur->_list);
       cur = cur->_next;
       return *this;
     }