From 7f68698142507faecdf74e0a572f2e526b8ffcd3 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Tue, 14 Aug 2012 12:43:23 -0400 Subject: Fix cppcheck warning, and add explicit Flash init names --- globals.c | 5 ++++- instr-daemon.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/globals.c b/globals.c index 1dbfb87..15f210b 100644 --- a/globals.c +++ b/globals.c @@ -2,7 +2,10 @@ GlobalStruct globals = { .ChannelState = {0.0}, - .Flash = { "FIXME", (int)1, (char)0, (char)0 }, + .Flash = { .aux_error_message="FIXME", + .channels = (int)1, + .enable_avrq_extra_ampls = (char)0, + .ChanKey_frequency = (char)0 }, .error_queue = {0}, .number_of_errors = 0 }; diff --git a/instr-daemon.c b/instr-daemon.c index ff43579..f4bd0b2 100644 --- a/instr-daemon.c +++ b/instr-daemon.c @@ -41,6 +41,11 @@ stdinAvailable (GIOChannel *source, GIOCondition condition, gpointer data) if(!strncmp(tmp, "..", size-1)) { //final reallocation of the buffer to accomodate the whole string buffer=realloc(buffer,allocated+1); + if(buffer==NULL) + { + g_printerr("realloc FAILED! Exiting!"); + exit(-1); + } buffer[allocated] = '\0'; g_print_debug("Got the buffer: \"%s\", tid: %p\n", buffer, g_thread_self()); @@ -70,6 +75,11 @@ stdinAvailable (GIOChannel *source, GIOCondition condition, gpointer data) //allocate on the heap. buffer is NULL the first time buffer=realloc(buffer, allocated+size); + if(buffer==NULL) + { + g_printerr("realloc FAILED! Exiting!"); + exit(-1); + } memcpy(buffer+allocated, tmp, size); allocated += size; //keep track of allocation -- cgit