]> git.mdlowis.com Git - projs/tide.git/commitdiff
reworked code to allo NDEBUG definition
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 28 Sep 2019 19:37:43 +0000 (15:37 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 28 Sep 2019 19:37:43 +0000 (15:37 -0400)
Rsconscript
inc/atf.h
src/lib/buf.c
src/lib/dbc.c
src/lib/shortcuts.c
src/lib/view.c
src/tide.c

index 458df2459824a8ac415109d6c941edc45ee375d1..a22c492e09cf11a4cffcc8bf64d2cfb281380489 100644 (file)
@@ -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"))
index ca7b30ac169d7ad05b3a9f3a20b72921c4a17396..643ecf80619b27b21217e1aa7285f96abe25a147 100644 (file)
--- 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
index f4798c12a7cf5ffba1f60250a03fadd50f1c0ec3..518a760b48c704a842b0bdb3893085b72da8f777 100644 (file)
@@ -8,6 +8,7 @@
 #include <sys/stat.h>
 #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
  ******************************************************************************/
index 24a4596758f43ae8289e667b2a506654aba1d863..b6e08103c3ef8c153e6c733b215e2faddc156fdd 100644 (file)
@@ -2,6 +2,8 @@
 #include <stdio.h>
 #include <signal.h>
 
+#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
index afcb179ae87650c1e4bc22efe90bb497691caca3..71724b322d32967c97af50186c9b4d4e5a8f47aa 100644 (file)
@@ -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) {
index 3f7ac694315fab146fd8ec476fbfef371d77c88a..ba4a5b1412d52c2772a086518d5fd838771a7fba 100644 (file)
@@ -5,6 +5,7 @@
 #include <ctype.h>
 #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);
index 26e281585b7f772252145d7e1f3816b34d767657..78977f87707c457ba1fdcd256337154031155559 100644 (file)
@@ -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);