From 1711be955b54b9d12431b341ea290bad406023cc Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Fri, 17 Aug 2012 18:32:56 +0200 Subject: fixed all the errors that the clang static analayzer found --- src/base/system.c | 4 +++- src/base/system.h | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/system.c b/src/base/system.c index a849e807..410cb699 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -80,7 +80,7 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg) void dbg_break() { - *((unsigned*)0) = 0x0; + *((volatile unsigned*)0) = 0x0; } void dbg_msg(const char *sys, const char *fmt, ...) @@ -166,6 +166,8 @@ void *mem_alloc_debug(const char *filename, int line, unsigned size, unsigned al MEMTAIL *tail; MEMHEADER *header = (struct MEMHEADER *)malloc(size+sizeof(MEMHEADER)+sizeof(MEMTAIL)); dbg_assert(header != 0, "mem_alloc failure"); + if(!header) + return NULL; tail = (struct MEMTAIL *)(((char*)(header+1))+size); header->size = size; header->filename = filename; diff --git a/src/base/system.h b/src/base/system.h index 032cf785..7ba0c0a0 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -33,6 +33,13 @@ void dbg_assert(int test, const char *msg); #define dbg_assert(test,msg) dbg_assert_imp(__FILE__, __LINE__, test, msg) void dbg_assert_imp(const char *filename, int line, int test, const char *msg); + +#ifdef __clang_analyzer__ +#include +#undef dbg_assert +#define dbg_assert(test,msg) assert(test) +#endif + /* Function: dbg_break Breaks into the debugger. -- cgit 1.4.1