diff options
author | Dario Lombardo <lomato@gmail.com> | 2018-01-30 17:39:03 +0100 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2018-02-01 07:21:11 +0000 |
commit | d3e50fedf744a7fbef9535c750f0eafe5f6f83b7 (patch) | |
tree | 28a925494f393b96c5bef0b129529c41a45b8c73 /wsutil/buffer.c | |
parent | dd3b82ebc87bee5bb61d64d1a1417364e013a505 (diff) |
buffer: add g_assert to all functions.
This pacify clang warnings as well.
Change-Id: I5d61a82bfc43b93281f0d0caabcb7109c849788b
Reviewed-on: https://code.wireshark.org/review/25518
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'wsutil/buffer.c')
-rw-r--r-- | wsutil/buffer.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/wsutil/buffer.c b/wsutil/buffer.c index b32d11d2ea..40ef5a348d 100644 --- a/wsutil/buffer.c +++ b/wsutil/buffer.c @@ -20,6 +20,7 @@ static GPtrArray *small_buffers = NULL; /* Guaranteed to be at least SMALL_BUFFE void ws_buffer_init(Buffer* buffer, gsize space) { + g_assert(buffer); if G_UNLIKELY(!small_buffers) small_buffers = g_ptr_array_sized_new(1024); if (space <= SMALL_BUFFER_SIZE) { @@ -41,6 +42,7 @@ ws_buffer_init(Buffer* buffer, gsize space) void ws_buffer_free(Buffer* buffer) { + g_assert(buffer); if (buffer->allocated == SMALL_BUFFER_SIZE) { g_ptr_array_add(small_buffers, buffer->data); } else { @@ -56,6 +58,7 @@ ws_buffer_free(Buffer* buffer) void ws_buffer_assure_space(Buffer* buffer, gsize space) { + g_assert(buffer); gsize available_at_end = buffer->allocated - buffer->first_free; gsize space_used; gboolean space_at_beginning; @@ -94,6 +97,7 @@ ws_buffer_assure_space(Buffer* buffer, gsize space) void ws_buffer_append(Buffer* buffer, guint8 *from, gsize bytes) { + g_assert(buffer); ws_buffer_assure_space(buffer, bytes); memcpy(buffer->data + buffer->first_free, from, bytes); buffer->first_free += bytes; @@ -102,6 +106,7 @@ ws_buffer_append(Buffer* buffer, guint8 *from, gsize bytes) void ws_buffer_remove_start(Buffer* buffer, gsize bytes) { + g_assert(buffer); if (buffer->start + bytes > buffer->first_free) { g_error("ws_buffer_remove_start trying to remove %" G_GINT64_MODIFIER "u bytes. s=%" G_GINT64_MODIFIER "u ff=%" G_GINT64_MODIFIER "u!\n", (guint64)bytes, (guint64)buffer->start, @@ -121,6 +126,7 @@ ws_buffer_remove_start(Buffer* buffer, gsize bytes) void ws_buffer_clean(Buffer* buffer) { + g_assert(buffer); ws_buffer_remove_start(buffer, ws_buffer_length(buffer)); } #endif @@ -129,6 +135,7 @@ ws_buffer_clean(Buffer* buffer) void ws_buffer_increase_length(Buffer* buffer, gsize bytes) { + g_assert(buffer); buffer->first_free += bytes; } #endif @@ -137,6 +144,7 @@ ws_buffer_increase_length(Buffer* buffer, gsize bytes) gsize ws_buffer_length(Buffer* buffer) { + g_assert(buffer); return buffer->first_free - buffer->start; } #endif @@ -145,6 +153,7 @@ ws_buffer_length(Buffer* buffer) guint8 * ws_buffer_start_ptr(Buffer* buffer) { + g_assert(buffer); return buffer->data + buffer->start; } #endif @@ -153,6 +162,7 @@ ws_buffer_start_ptr(Buffer* buffer) guint8 * ws_buffer_end_ptr(Buffer* buffer) { + g_assert(buffer); return buffer->data + buffer->first_free; } #endif @@ -161,6 +171,7 @@ ws_buffer_end_ptr(Buffer* buffer) void ws_buffer_append_buffer(Buffer* buffer, Buffer* src_buffer) { + g_assert(buffer); ws_buffer_append(buffer, ws_buffer_start_ptr(src_buffer), ws_buffer_length(src_buffer)); } #endif |