summaryrefslogtreecommitdiffstats
path: root/gril/gril.c
diff options
context:
space:
mode:
authorAlfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>2015-10-15 18:46:58 +0200
committerDenis Kenzior <denkenz@gmail.com>2015-10-16 14:29:23 -0500
commit88601c473316f0cfaf450d0f6e48eabb8a5ca52f (patch)
treeb39bc0e30bb3d213420b5f67cb81d778d878f26c /gril/gril.c
parent7d428137e6baaf06058f3f38b7276c6c0dfc578d (diff)
downloadofono-88601c473316f0cfaf450d0f6e48eabb8a5ca52f.tar.bz2
gril: Remove asserts
Diffstat (limited to 'gril/gril.c')
-rw-r--r--gril/gril.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/gril/gril.c b/gril/gril.c
index ddedc66a..ead82062 100644
--- a/gril/gril.c
+++ b/gril/gril.c
@@ -29,7 +29,6 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
-#include <assert.h>
#include <ctype.h>
#include <errno.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)
{
- gsize count = g_queue_get_length(p->command_queue);
+ guint count = g_queue_get_length(p->command_queue);
struct ril_request *req;
gboolean found = FALSE;
guint i, len;
gint id;
- g_assert(count > 0);
-
for (i = 0; i < count; 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;
/*
- * 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:
*
- * 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
* 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
@@ -580,13 +581,11 @@ static struct ril_msg *read_fixed_record(struct ril_s *p,
if (message_len < plen)
return NULL;
- message = g_try_malloc(sizeof(struct ril_msg));
- g_assert(message != NULL);
+ message = g_malloc(sizeof(struct ril_msg));
/* allocate ril_msg->buffer */
message->buf_len = plen;
- message->buf = g_try_malloc(plen);
- g_assert(message->buf != NULL);
+ message->buf = g_malloc(plen);
/* Copy bytes into message buffer */
memmove(message->buf, (const void *) bytes, plen);