summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/check_return.h2
-rw-r--r--src/util/fatal_error.h12
2 files changed, 7 insertions, 7 deletions
diff --git a/src/util/check_return.h b/src/util/check_return.h
index 89ed4bc..bfdadf5 100644
--- a/src/util/check_return.h
+++ b/src/util/check_return.h
@@ -138,7 +138,7 @@
// - Programming errors (assertion failures, invariant violations)
// - Corrupted state that cannot be recovered
// - Internal consistency checks
-// - Example: FATAL_CHECK(idx >= size, "Index out of bounds: %d >= %d", idx,
+// - Example: FATAL_CHECK(idx < size, "Index out of bounds: %d >= %d", idx,
// size)
//
// Use CHECK_RETURN for:
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)