]> git.feebdaed.xyz Git - 0xmirror/radare2.git/commitdiff
Disable runtime warnings for R_CHECKS_LEVEL == 0
authorOle André Vadla Ravnås <oleavr@frida.re>
Mon, 22 Dec 2025 18:20:04 +0000 (19:20 +0100)
committerpancake <pancake@nowsecure.com>
Mon, 22 Dec 2025 18:36:09 +0000 (19:36 +0100)
libr/include/r_util/r_assert.h

index 40c4bf9a307a269efc9a21072ae64d5cc5aa5633..ede9cd5a09adde87dc879830a0bc58b6237a52f1 100644 (file)
@@ -22,6 +22,25 @@ R_API void r_assert_log(RLogLevel level, const char *origin, const char *fmt, ..
 #define R_FUNCTION ((const char*) ("???"))
 #endif
 
+/*
+ * R_CHECKS_LEVEL determines the behaviour of the R_RETURN_* set of functions.
+ *
+ * 0: completely disable every function and make them like no-operation
+ * 1: silently enable checks. Check expressions and do return, but do not log anything
+ * 2: enable checks and logging (DEFAULT)
+ * 3: transform them into real assertion
+ */
+#ifndef R_CHECKS_LEVEL
+#define R_CHECKS_LEVEL 2
+#endif
+
+#if R_CHECKS_LEVEL == 0
+
+#define R_WARN_IF_REACHED() do { ; } while(0)
+#define R_WARN_IF_FAIL(expr) do { ; } while(0)
+
+#else
+
 #define R_WARN_IF_REACHED() \
        do { \
                r_assert_log (R_LOG_LEVEL_WARN, R_LOG_ORIGIN, "(%s:%d):%s%s code should not be reached", \
@@ -36,16 +55,6 @@ R_API void r_assert_log(RLogLevel level, const char *origin, const char *fmt, ..
                } \
        } while (0)
 
-/*
- * R_CHECKS_LEVEL determines the behaviour of the R_RETURN_* set of functions.
- *
- * 0: completely disable every function and make them like no-operation
- * 1: silently enable checks. Check expressions and do return, but do not log anything
- * 2: enable checks and logging (DEFAULT)
- * 3: transform them into real assertion
- */
-#ifndef R_CHECKS_LEVEL
-#define R_CHECKS_LEVEL 2
 #endif
 
 #if R_CHECKS_LEVEL == 0