From: Michael D. Lowis Date: Sat, 28 Sep 2019 19:37:43 +0000 (-0400) Subject: reworked code to allo NDEBUG definition X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=576517d065c9a350de0c123a46b012c723dd71d2;p=projs%2Ftide.git reworked code to allo NDEBUG definition --- diff --git a/Rsconscript b/Rsconscript index 458df24..a22c492 100644 --- a/Rsconscript +++ b/Rsconscript @@ -15,6 +15,7 @@ build do # env["LDFLAGS"] += ["-g", "-fsanitize=undefined,address"] env["CPPPATH"] += %w[. inc] env["LIBPATH"] += %w[.] + env["CFLAGS"] << "-DNDEBUG" # Build library and binaries env.Library("libtide.a", glob("src/lib/**/*.c")) diff --git a/inc/atf.h b/inc/atf.h index ca7b30a..643ecf8 100644 --- a/inc/atf.h +++ b/inc/atf.h @@ -151,6 +151,7 @@ void exit(int code) { longjmp(ExitPad, 1); } else { assert(!"Unexpected exit. Something went wrong"); + abort(); // if NDEBUG defined } } #endif diff --git a/src/lib/buf.c b/src/lib/buf.c index f4798c1..518a760 100644 --- a/src/lib/buf.c +++ b/src/lib/buf.c @@ -8,6 +8,7 @@ #include #include "config.h" +#ifndef NDEBUG static bool buf_logvalid(Log* log) { bool result = true; for (; result && log; log = log->next) { @@ -44,6 +45,7 @@ static bool buf_valid(Buf* buf) { && (buf_selvalid(buf)) ); } +#endif /* Creation, Resizing, Loading, and Saving ******************************************************************************/ diff --git a/src/lib/dbc.c b/src/lib/dbc.c index 24a4596..b6e0810 100644 --- a/src/lib/dbc.c +++ b/src/lib/dbc.c @@ -2,6 +2,8 @@ #include #include +#ifndef NDEBUG + static char ErrMsg[8192]; static char* DumpPath = NULL; static void (*DumpFn)(FILE*) = NULL; @@ -59,3 +61,5 @@ void dbc_wdtkick(void) { signal(SIGALRM, handle_signal); alarm(1); /* Start new alarm */ } + +#endif diff --git a/src/lib/shortcuts.c b/src/lib/shortcuts.c index afcb179..71724b3 100644 --- a/src/lib/shortcuts.c +++ b/src/lib/shortcuts.c @@ -46,6 +46,7 @@ void cut(char* arg) { void paste(char* arg) { int pasted = x11_sel_get(&X, CLIPBOARD, onpaste); assert(pasted); + (void)pasted; } void copy(char* arg) { diff --git a/src/lib/view.c b/src/lib/view.c index 3f7ac69..ba4a5b1 100644 --- a/src/lib/view.c +++ b/src/lib/view.c @@ -5,6 +5,7 @@ #include #include "config.h" +#ifndef NDEBUG static bool view_valid(View* view) { return ( (view->sync_flags <= 3u) @@ -15,6 +16,7 @@ static bool view_valid(View* view) { // && (view->rows != NULL) ); } +#endif /* Provided by x11.c */ extern size_t glyph_width(View* view, int c); diff --git a/src/tide.c b/src/tide.c index 26e2815..78977f8 100644 --- a/src/tide.c +++ b/src/tide.c @@ -66,7 +66,7 @@ void dumpdata(FILE* f) { fprintf(f, "\t.rows:\t\t%p\n", (void*)Regions[i].rows); fprintf(f, "\t.buffer:\n"); fprintf(f, "\t\t.status:\t%d\n", Regions[i].buffer.status); - fprintf(f, "\t\t.modtime:\t%lu\n", Regions[i].buffer.modtime); + fprintf(f, "\t\t.modtime:\t%lu\n", (unsigned long)Regions[i].buffer.modtime); fprintf(f, "\t\t.bufsize:\t%zu\n", Regions[i].buffer.bufsize); fprintf(f, "\t\t.bufstart:\t%p\n", (void*)Regions[i].buffer.bufstart); fprintf(f, "\t\t.bufend:\t%p\n", (void*)Regions[i].buffer.bufend);