pw_assert: Fix usage of PW_COMMA_ARGS (again)
This reverts the revert of commit:
c86c4896bb9b1f54639c08c4323e405a3326e90a.
This fix can now go in thanks to the fix to PW_COMMA_ARGS to handle more
cases that come up in practice when nesting macros.
Change-Id: I078f8d3f9a669867b371c631add1ca9024a410c6
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/16320
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Keir Mierle <keir@google.com>
diff --git a/pw_assert/public/pw_assert/internal/assert_impl.h b/pw_assert/public/pw_assert/internal/assert_impl.h
index 8d22895..573c92f 100644
--- a/pw_assert/public/pw_assert/internal/assert_impl.h
+++ b/pw_assert/public/pw_assert/internal/assert_impl.h
@@ -33,8 +33,7 @@
#endif // !defined(PW_ASSERT_ENABLE_DCHECK)
// PW_CRASH - Crash the system, with a message.
-#define PW_CRASH(message, ...) \
- PW_HANDLE_CRASH(message PW_COMMA_ARGS(__VA_ARGS__))
+#define PW_CRASH PW_HANDLE_CRASH
// PW_CHECK - If condition evaluates to false, crash. Message optional.
#define PW_CHECK(condition, ...) \
diff --git a/pw_assert_log/public/pw_assert_log/assert_log.h b/pw_assert_log/public/pw_assert_log/assert_log.h
index d13fc16..d26d339 100644
--- a/pw_assert_log/public/pw_assert_log/assert_log.h
+++ b/pw_assert_log/public/pw_assert_log/assert_log.h
@@ -25,13 +25,14 @@
// Die with a message with several attributes included. This crash frontend
// funnels everything into the logger, which must then handle the true crash
// behaviour.
-#define PW_HANDLE_CRASH(message, ...) \
- do { \
- PW_LOG(PW_LOG_LEVEL_CRITICAL, \
- PW_LOG_ASSERT_FAILED_FLAG, \
- __FILE__ ":%d: Crash: " message, \
- __LINE__ PW_COMMA_ARGS(__VA_ARGS__)); \
- PW_UNREACHABLE; \
+#define PW_HANDLE_CRASH(message, ...) \
+ do { \
+ PW_LOG(PW_LOG_LEVEL_CRITICAL, \
+ PW_LOG_ASSERT_FAILED_FLAG, \
+ __FILE__ ":%d: Crash: " message, \
+ __LINE__, \
+ __VA_ARGS__); \
+ PW_UNREACHABLE; \
} while (0)
// Die with a message with several attributes included. This assert frontend
@@ -42,7 +43,8 @@
PW_LOG(PW_LOG_LEVEL_CRITICAL, \
PW_LOG_ASSERT_FAILED_FLAG, \
__FILE__ ":%d: Check failed: " condition_string ". " message, \
- __LINE__ PW_COMMA_ARGS(__VA_ARGS__)); \
+ __LINE__, \
+ __VA_ARGS__); \
PW_UNREACHABLE; \
} while (0)
@@ -69,7 +71,7 @@
comparison_op_str " " \
arg_b_str " (=" type_fmt ")" \
". " message, \
- __LINE__, arg_a_val, arg_b_val PW_COMMA_ARGS(__VA_ARGS__)); \
+ __LINE__, arg_a_val, arg_b_val, __VA_ARGS__); \
PW_UNREACHABLE; \
} while(0)
// clang-format on