From 7b48887e49395ba2c37fc3de48d81b17a0ba0ee3 Mon Sep 17 00:00:00 2001 From: ETSound Date: Sat, 23 May 2026 12:50:23 -0700 Subject: [PATCH 1/5] feat: Add assert for debug builds that won't affect release stability --- error_sdr/error_sdr.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/error_sdr/error_sdr.h b/error_sdr/error_sdr.h index b0a907e..6e5ae0c 100644 --- a/error_sdr/error_sdr.h +++ b/error_sdr/error_sdr.h @@ -143,6 +143,20 @@ typedef struct TEXT_MESSAGE #define assert_fail_fast( condition, error ) if ( !condition ) error_fail_fast( error ) +/******************************************************************************* +* * +* MACRO: * +* debug_assert_fail_fast * +* * +* DESCRIPTION: * +* Checks condition, if false calls error_fail_fast with error. Debug * +* builds only -- release builds will do nothing. * +* * +*******************************************************************************/ +#define debug_assert_fail_fast( condition, error ) \ +if ( !condition && ( defined(DEBUG) || !defined(RELBLD) ) ) error_fail_fast( error ) + + /*------------------------------------------------------------------------------ Function Prototypes ------------------------------------------------------------------------------*/ From 5ff107b1c8c5ab892d9d0fac47b966327aeaf913 Mon Sep 17 00:00:00 2001 From: ETSound Date: Sat, 23 May 2026 12:51:35 -0700 Subject: [PATCH 2/5] change naming so we can use throughout --- error_sdr/error_sdr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/error_sdr/error_sdr.h b/error_sdr/error_sdr.h index 6e5ae0c..3a0b1a9 100644 --- a/error_sdr/error_sdr.h +++ b/error_sdr/error_sdr.h @@ -146,14 +146,14 @@ typedef struct TEXT_MESSAGE /******************************************************************************* * * * MACRO: * -* debug_assert_fail_fast * +* debug_assert * * * * DESCRIPTION: * * Checks condition, if false calls error_fail_fast with error. Debug * * builds only -- release builds will do nothing. * * * *******************************************************************************/ -#define debug_assert_fail_fast( condition, error ) \ +#define debug_assert( condition, error ) \ if ( !condition && ( defined(DEBUG) || !defined(RELBLD) ) ) error_fail_fast( error ) From cb0d9ff82fa355abf216a8400598e98b18bbf63d Mon Sep 17 00:00:00 2001 From: ETSound Date: Sat, 23 May 2026 13:37:55 -0700 Subject: [PATCH 3/5] Fix condition check --- error_sdr/error_sdr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/error_sdr/error_sdr.h b/error_sdr/error_sdr.h index 3a0b1a9..7424b0c 100644 --- a/error_sdr/error_sdr.h +++ b/error_sdr/error_sdr.h @@ -140,7 +140,7 @@ typedef struct TEXT_MESSAGE * Checks condition, if false calls error_fail_fast with error * * * *******************************************************************************/ -#define assert_fail_fast( condition, error ) if ( !condition ) error_fail_fast( error ) +#define assert_fail_fast( condition, error ) if ( !(condition) ) error_fail_fast( error ) /******************************************************************************* @@ -154,7 +154,7 @@ typedef struct TEXT_MESSAGE * * *******************************************************************************/ #define debug_assert( condition, error ) \ -if ( !condition && ( defined(DEBUG) || !defined(RELBLD) ) ) error_fail_fast( error ) +if ( !(condition) && ( defined(DEBUG) || !defined(RELBLD) ) ) error_fail_fast( error ) /*------------------------------------------------------------------------------ From eaf186dfbb61ddf9d1621717bc0a9b259f480de0 Mon Sep 17 00:00:00 2001 From: ETSound Date: Sat, 23 May 2026 13:39:18 -0700 Subject: [PATCH 4/5] Make the macro safer without binding to else branches --- error_sdr/error_sdr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/error_sdr/error_sdr.h b/error_sdr/error_sdr.h index 7424b0c..88d2baa 100644 --- a/error_sdr/error_sdr.h +++ b/error_sdr/error_sdr.h @@ -140,7 +140,7 @@ typedef struct TEXT_MESSAGE * Checks condition, if false calls error_fail_fast with error * * * *******************************************************************************/ -#define assert_fail_fast( condition, error ) if ( !(condition) ) error_fail_fast( error ) +#define assert_fail_fast( condition, error ) do { if ( !(condition) ) error_fail_fast( error ); } while(0) /******************************************************************************* @@ -154,7 +154,7 @@ typedef struct TEXT_MESSAGE * * *******************************************************************************/ #define debug_assert( condition, error ) \ -if ( !(condition) && ( defined(DEBUG) || !defined(RELBLD) ) ) error_fail_fast( error ) +do { if ( !(condition) && ( defined(DEBUG) || !defined(RELBLD) ) ) error_fail_fast( error ); } while(0) /*------------------------------------------------------------------------------ From fe006df4092c995f0192a7b391e1fc3cf2513b4d Mon Sep 17 00:00:00 2001 From: ETSound Date: Sat, 23 May 2026 14:09:43 -0700 Subject: [PATCH 5/5] Fix debug assert macro --- error_sdr/error_sdr.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/error_sdr/error_sdr.h b/error_sdr/error_sdr.h index 88d2baa..2516e7d 100644 --- a/error_sdr/error_sdr.h +++ b/error_sdr/error_sdr.h @@ -153,8 +153,13 @@ typedef struct TEXT_MESSAGE * builds only -- release builds will do nothing. * * * *******************************************************************************/ -#define debug_assert( condition, error ) \ -do { if ( !(condition) && ( defined(DEBUG) || !defined(RELBLD) ) ) error_fail_fast( error ); } while(0) +#if defined(DEBUG) || !defined(RELBLD) + #define debug_assert( condition, error ) \ + do { if ( !(condition) ) error_fail_fast( error ); } while(0) +#else + #define debug_assert( condition, error ) \ + do { } while(0) +#endif /*------------------------------------------------------------------------------