gril: Remove asserts

This commit is contained in:
Alfonso Sanchez-Beato 2015-10-15 18:46:58 +02:00 committed by Denis Kenzior
parent 7d428137e6
commit 88601c4733
3 changed files with 14 additions and 14 deletions

View File

@ -29,7 +29,6 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <sys/socket.h> #include <sys/socket.h>
@ -358,14 +357,12 @@ static void io_disconnect(gpointer user_data)
static void handle_response(struct ril_s *p, struct ril_msg *message) static void handle_response(struct ril_s *p, struct ril_msg *message)
{ {
gsize count = g_queue_get_length(p->command_queue); guint count = g_queue_get_length(p->command_queue);
struct ril_request *req; struct ril_request *req;
gboolean found = FALSE; gboolean found = FALSE;
guint i, len; guint i, len;
gint id; gint id;
g_assert(count > 0);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
req = g_queue_peek_nth(p->command_queue, i); req = g_queue_peek_nth(p->command_queue, i);
@ -560,16 +557,20 @@ static struct ril_msg *read_fixed_record(struct ril_s *p,
bytes += 4; bytes += 4;
/* /*
* TODO: Verify that 4k is the max message size from rild. * TODO: Verify that 8k is the max message size from rild.
* *
* These conditions shouldn't happen. If it does * This condition shouldn't happen. If it does
* there are three options: * there are three options:
* *
* 1) ASSERT; ofono will restart via DBus * 1) Exit; ofono will restart via DBus (this is what we do now)
* 2) Consume the bytes & continue * 2) Consume the bytes & continue
* 3) force a disconnect * 3) force a disconnect
*/ */
g_assert(plen >= 8 && plen <= 4092); if (plen > GRIL_BUFFER_SIZE - 4) {
ofono_error("ERROR RIL parcel bigger than buffer (%u), exiting",
plen);
exit(1);
}
/* /*
* If we don't have the whole fixed record in the ringbuffer * If we don't have the whole fixed record in the ringbuffer
@ -580,13 +581,11 @@ static struct ril_msg *read_fixed_record(struct ril_s *p,
if (message_len < plen) if (message_len < plen)
return NULL; return NULL;
message = g_try_malloc(sizeof(struct ril_msg)); message = g_malloc(sizeof(struct ril_msg));
g_assert(message != NULL);
/* allocate ril_msg->buffer */ /* allocate ril_msg->buffer */
message->buf_len = plen; message->buf_len = plen;
message->buf = g_try_malloc(plen); message->buf = g_malloc(plen);
g_assert(message->buf != NULL);
/* Copy bytes into message buffer */ /* Copy bytes into message buffer */
memmove(message->buf, (const void *) bytes, plen); memmove(message->buf, (const void *) bytes, plen);

View File

@ -27,7 +27,6 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
@ -206,7 +205,7 @@ static GRilIO *create_io(GIOChannel *channel, GIOFlags flags)
io->use_write_watch = FALSE; io->use_write_watch = FALSE;
} }
io->buf = ring_buffer_new(8192); io->buf = ring_buffer_new(GRIL_BUFFER_SIZE);
if (!io->buf) if (!io->buf)
goto error; goto error;

View File

@ -29,6 +29,8 @@ extern "C" {
#include "gfunc.h" #include "gfunc.h"
#define GRIL_BUFFER_SIZE 8192
struct _GRilIO; struct _GRilIO;
typedef struct _GRilIO GRilIO; typedef struct _GRilIO GRilIO;