From 8aecf1492852fb1aefb78538d49a787a0ba47dcb Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Fri, 20 Dec 2019 16:23:53 +0100 Subject: [PATCH] assert: Disable line number printing together with file printing Disable printing the line number in assertions when file name has been disabled. Knowing the line number is not very useful when the name of the file is unknown. Signed-off-by: Joakim Andersson --- include/sys/__assert.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/sys/__assert.h b/include/sys/__assert.h index b24f97ea709..6a89ec6639d 100644 --- a/include/sys/__assert.h +++ b/include/sys/__assert.h @@ -28,8 +28,10 @@ #ifdef CONFIG_ASSERT_NO_FILE_INFO #define __ASSERT_FILE_INFO "" +#define __ASSERT_LINE_INFO 0 #else /* CONFIG_ASSERT_NO_FILE_INFO */ #define __ASSERT_FILE_INFO __FILE__ +#define __ASSERT_LINE_INFO __LINE__ #endif /* CONFIG_ASSERT_NO_FILE_INFO */ #ifdef CONFIG_ASSERT_NO_COND_INFO @@ -48,7 +50,7 @@ __ASSERT_PRINT("ASSERTION FAIL [%s] @ %s:%d\n", \ __ASSERT_COND_INFO(test), \ __ASSERT_FILE_INFO, \ - __LINE__) \ + __ASSERT_LINE_INFO) \ #ifdef __ASSERT_ON #if (__ASSERT_ON < 0) || (__ASSERT_ON > 2) @@ -73,7 +75,8 @@ void assert_post_action(const char *file, unsigned int line); do { \ if (!(test)) { \ __ASSERT_LOC(test); \ - assert_post_action(__ASSERT_FILE_INFO, __LINE__); \ + assert_post_action(__ASSERT_FILE_INFO, \ + __ASSERT_LINE_INFO); \ } \ } while (false) @@ -82,7 +85,8 @@ void assert_post_action(const char *file, unsigned int line); if (!(test)) { \ __ASSERT_LOC(test); \ __ASSERT_MSG_INFO(fmt, ##__VA_ARGS__); \ - assert_post_action(__ASSERT_FILE_INFO, __LINE__); \ + assert_post_action(__ASSERT_FILE_INFO, \ + __ASSERT_LINE_INFO); \ } \ } while (false)