fix assert with standard code analysis macro

This commit is contained in:
Jeff Lenk 2011-01-05 09:56:44 -06:00
parent 23d9a237dc
commit 1aa6bc6eec
1 changed files with 15 additions and 39 deletions

View File

@ -82,10 +82,7 @@ ESL_DECLARE(esl_status_t) esl_buffer_create(esl_buffer_t **buffer, esl_size_t bl
ESL_DECLARE(esl_size_t) esl_buffer_len(esl_buffer_t *buffer) ESL_DECLARE(esl_size_t) esl_buffer_len(esl_buffer_t *buffer)
{ {
assert(buffer != NULL); esl_assert(buffer != NULL);
if (!buffer){
return (esl_size_t)NULL;
}
return buffer->datalen; return buffer->datalen;
@ -94,10 +91,7 @@ ESL_DECLARE(esl_size_t) esl_buffer_len(esl_buffer_t *buffer)
ESL_DECLARE(esl_size_t) esl_buffer_freespace(esl_buffer_t *buffer) ESL_DECLARE(esl_size_t) esl_buffer_freespace(esl_buffer_t *buffer)
{ {
assert(buffer != NULL); esl_assert(buffer != NULL);
if (!buffer) {
return (esl_size_t)NULL;
}
if (buffer->max_len) { if (buffer->max_len) {
return (esl_size_t) (buffer->max_len - buffer->used); return (esl_size_t) (buffer->max_len - buffer->used);
@ -108,10 +102,7 @@ ESL_DECLARE(esl_size_t) esl_buffer_freespace(esl_buffer_t *buffer)
ESL_DECLARE(esl_size_t) esl_buffer_inuse(esl_buffer_t *buffer) ESL_DECLARE(esl_size_t) esl_buffer_inuse(esl_buffer_t *buffer)
{ {
assert(buffer != NULL); esl_assert(buffer != NULL);
if (!buffer) {
return (esl_size_t)NULL;
}
return buffer->used; return buffer->used;
} }
@ -120,10 +111,7 @@ ESL_DECLARE(esl_size_t) esl_buffer_seek(esl_buffer_t *buffer, esl_size_t datalen
{ {
esl_size_t reading = 0; esl_size_t reading = 0;
assert(buffer != NULL); esl_assert(buffer != NULL);
if (!buffer) {
return (esl_size_t)NULL;
}
if (buffer->used < 1) { if (buffer->used < 1) {
buffer->used = 0; buffer->used = 0;
@ -144,10 +132,7 @@ ESL_DECLARE(esl_size_t) esl_buffer_toss(esl_buffer_t *buffer, esl_size_t datalen
{ {
esl_size_t reading = 0; esl_size_t reading = 0;
assert(buffer != NULL); esl_assert(buffer != NULL);
if (!buffer) {
return (esl_size_t)NULL;
}
if (buffer->used < 1) { if (buffer->used < 1) {
buffer->used = 0; buffer->used = 0;
@ -188,11 +173,8 @@ ESL_DECLARE(esl_size_t) esl_buffer_read(esl_buffer_t *buffer, void *data, esl_si
{ {
esl_size_t reading = 0; esl_size_t reading = 0;
assert(buffer != NULL); esl_assert(buffer != NULL);
if (!buffer) { esl_assert(data != NULL);
return (esl_size_t)NULL;
}
assert(data != NULL);
if (buffer->used < 1) { if (buffer->used < 1) {
@ -218,7 +200,7 @@ ESL_DECLARE(esl_size_t) esl_buffer_packet_count(esl_buffer_t *buffer)
char *pe, *p, *e, *head = (char *) buffer->head; char *pe, *p, *e, *head = (char *) buffer->head;
esl_size_t x = 0; esl_size_t x = 0;
assert(buffer != NULL); esl_assert(buffer != NULL);
e = (head + buffer->used); e = (head + buffer->used);
@ -241,8 +223,8 @@ ESL_DECLARE(esl_size_t) esl_buffer_read_packet(esl_buffer_t *buffer, void *data,
char *pe, *p, *e, *head = (char *) buffer->head; char *pe, *p, *e, *head = (char *) buffer->head;
esl_size_t datalen = 0; esl_size_t datalen = 0;
assert(buffer != NULL); esl_assert(buffer != NULL);
assert(data != NULL); esl_assert(data != NULL);
e = (head + buffer->used); e = (head + buffer->used);
@ -268,12 +250,9 @@ ESL_DECLARE(esl_size_t) esl_buffer_write(esl_buffer_t *buffer, const void *data,
{ {
esl_size_t freespace, actual_freespace; esl_size_t freespace, actual_freespace;
assert(buffer != NULL); esl_assert(buffer != NULL);
if (!buffer) { esl_assert(data != NULL);
return (esl_size_t)NULL; esl_assert(buffer->data != NULL);
}
assert(data != NULL);
assert(buffer->data != NULL);
if (!datalen) { if (!datalen) {
return buffer->used; return buffer->used;
@ -332,11 +311,8 @@ ESL_DECLARE(esl_size_t) esl_buffer_write(esl_buffer_t *buffer, const void *data,
ESL_DECLARE(void) esl_buffer_zero(esl_buffer_t *buffer) ESL_DECLARE(void) esl_buffer_zero(esl_buffer_t *buffer)
{ {
assert(buffer != NULL); esl_assert(buffer != NULL);
if (!buffer) { esl_assert(buffer->data != NULL);
return;
}
assert(buffer->data != NULL);
buffer->used = 0; buffer->used = 0;
buffer->actually_used = 0; buffer->actually_used = 0;