diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-16 12:52:07 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-16 12:52:07 +0100 |
| commit | 83322562ce0c33a8026611471dc7b1b3241bce64 (patch) | |
| tree | c7702f33b02e7eb639eb26c8708030e46e4e52fe /src/util/fatal_error.h | |
| parent | f03f3428991499e0701cce5eacc2bb943fde9d8e (diff) | |
refactor: invert FATAL_CHECK logic to standard assertion style
- Inverted FATAL_CHECK macro to crash if condition is FALSE (standard assertion)
- Updated all call sites in audio, GPU, and CNN subsystems
- Updated documentation and examples
- Recorded completion in doc/COMPLETED.md
Diffstat (limited to 'src/util/fatal_error.h')
| -rw-r--r-- | src/util/fatal_error.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/util/fatal_error.h b/src/util/fatal_error.h index aaeba26..c0f7c65 100644 --- a/src/util/fatal_error.h +++ b/src/util/fatal_error.h @@ -43,9 +43,9 @@ // ============================================================================== // Conditional fatal error check with formatted message -// Usage: FATAL_CHECK(x >= max, "x out of bounds: %d >= %d\n", x, max); +// Usage: FATAL_CHECK(x < max, "x out of bounds: %d >= %d\n", x, max); // -// If condition is TRUE (error detected): +// If condition is FALSE (assertion failed): // - Prints "FATAL: <message> [file.cc:line]" to stderr // - Calls abort() // @@ -54,7 +54,7 @@ // [ring_buffer.cc:57] #define FATAL_CHECK(cond, ...) \ do { \ - if (cond) { \ + if (!(cond)) { \ fprintf(stderr, "FATAL: " __VA_ARGS__); \ fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \ abort(); \ @@ -126,9 +126,9 @@ // // FATAL_CHECK(cond, msg, ...): // - Most common use case (90% of error checks) -// - Bounds checking: FATAL_CHECK(idx >= size, "Index %d >= %d\n", idx, size) -// - Null checking: FATAL_CHECK(ptr == nullptr, "Null pointer: %s\n", name) -// - Range validation: FATAL_CHECK(x < min || x > max, "Out of range\n") +// - Bounds checking: FATAL_CHECK(idx < size, "Index %d >= %d\n", idx, size) +// - Null checking: FATAL_CHECK(ptr != nullptr, "Null pointer: %s\n", name) +// - Range validation: FATAL_CHECK(x >= min && x <= max, "Out of range\n") // // FATAL_ERROR(msg, ...): // - Unconditional errors (should-never-happen cases) |
