Replace most uses of assert by ovs_assert.
[sliver-openvswitch.git] / lib / ofpbuf.c
index 02e5aa8..6484ab3 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <config.h>
 #include "ofpbuf.h"
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include "dynamic-string.h"
@@ -95,7 +94,7 @@ ofpbuf_use_stub(struct ofpbuf *b, void *base, size_t allocated)
 void
 ofpbuf_use_const(struct ofpbuf *b, const void *data, size_t size)
 {
-    ofpbuf_use__(b, (void *) data, size, OFPBUF_STACK);
+    ofpbuf_use__(b, CONST_CAST(void *, data), size, OFPBUF_STACK);
     b->size = size;
 }
 
@@ -408,7 +407,7 @@ ofpbuf_put_hex(struct ofpbuf *b, const char *s, size_t *n)
             if (n) {
                 *n = b->size - initial_size;
             }
-            return (char *) s;
+            return CONST_CAST(char *, s);
         }
 
         ofpbuf_put(b, &byte, 1);
@@ -421,7 +420,7 @@ ofpbuf_put_hex(struct ofpbuf *b, const char *s, size_t *n)
 void
 ofpbuf_reserve(struct ofpbuf *b, size_t size)
 {
-    assert(!b->size);
+    ovs_assert(!b->size);
     ofpbuf_prealloc_tailroom(b, size);
     b->data = (char*)b->data + size;
 }
@@ -473,7 +472,7 @@ ofpbuf_at(const struct ofpbuf *b, size_t offset, size_t size)
 void *
 ofpbuf_at_assert(const struct ofpbuf *b, size_t offset, size_t size)
 {
-    assert(offset + size <= b->size);
+    ovs_assert(offset + size <= b->size);
     return ((char *) b->data) + offset;
 }
 
@@ -506,7 +505,7 @@ void *
 ofpbuf_pull(struct ofpbuf *b, size_t size)
 {
     void *data = b->data;
-    assert(b->size >= size);
+    ovs_assert(b->size >= size);
     b->data = (char*)b->data + size;
     b->size -= size;
     return data;