Make sure that assert() expressions do not have side effects
[fio.git] / debug.h
diff --git a/debug.h b/debug.h
index e3aa3f183875ba37a67d80542d7afd110325f6ea..b8718ddc225f894c68d981e50c4fd2bff5e85f83 100644 (file)
--- a/debug.h
+++ b/debug.h
@@ -2,6 +2,7 @@
 #define FIO_DEBUG_H
 
 #include <assert.h>
+#include "lib/types.h"
 #include "log.h"
 
 enum {
@@ -26,7 +27,24 @@ enum {
        FD_DEBUG_MAX,
 };
 
-extern unsigned int fio_debug_jobno, *fio_debug_jobp;
+extern unsigned int fio_debug_jobno, *fio_debug_jobp, *fio_warned;
+
+static inline bool fio_did_warn(unsigned int mask)
+{
+       if (*fio_warned & mask)
+               return true;
+
+       *fio_warned |= mask;
+       return false;
+}
+
+enum {
+       FIO_WARN_ROOT_FLUSH     = 1,
+       FIO_WARN_VERIFY_BUF     = 2,
+       FIO_WARN_ZONED_BUG      = 4,
+       FIO_WARN_IOLOG_DROP     = 8,
+       FIO_WARN_FADVISE        = 16,
+};
 
 #ifdef FIO_INC_DEBUG
 struct debug_level {
@@ -35,7 +53,7 @@ struct debug_level {
        unsigned long shift;
        unsigned int jobno;
 };
-extern struct debug_level debug_levels[];
+extern const struct debug_level debug_levels[];
 
 extern unsigned long fio_debug;