You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2023/03/24 19:13:51 UTC

[nuttx] branch master updated: assert.h: Replace NULL with 0 to avoid including stddef.h

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new c9b917bcee assert.h: Replace NULL with 0 to avoid including stddef.h
c9b917bcee is described below

commit c9b917bcee0b9c1493093e695536903fe7d2dff9
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Mar 23 10:46:53 2023 +0800

    assert.h: Replace NULL with 0 to avoid including stddef.h
    
    Fix error: 'NULL' undeclared if user include assert.h only
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 include/assert.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/assert.h b/include/assert.h
index 2520d15b8e..88bdec6380 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -43,7 +43,7 @@
 #undef DEBUGVERIFY  /* Like VERIFY, but only if CONFIG_DEBUG_ASSERTIONS is defined */
 
 #ifndef CONFIG_HAVE_FILENAME
-#  define __FILE__ NULL
+#  define __FILE__ 0
 #  define __LINE__ 0
 #endif
 
@@ -66,20 +66,20 @@
     }                                     \
   while (0)
 #else
-#  define ASSERT(f)                         \
-  do                                        \
-    {                                       \
-      if (predict_false(!(f)))              \
-        __assert(__FILE__, __LINE__, NULL); \
-    }                                       \
+#  define ASSERT(f)                       \
+  do                                      \
+    {                                     \
+      if (predict_false(!(f)))            \
+        __assert(__FILE__, __LINE__, 0);  \
+    }                                     \
   while (0)
 
-#  define VERIFY(f)                         \
-  do                                        \
-    {                                       \
-      if (predict_false((f) < 0))           \
-        __assert(__FILE__, __LINE__, NULL); \
-    }                                       \
+#  define VERIFY(f)                       \
+  do                                      \
+    {                                     \
+      if (predict_false((f) < 0))         \
+        __assert(__FILE__, __LINE__, 0);  \
+    }                                     \
   while (0)
 #endif