diff options
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) |
