According to the standard definition, assert should return a void expression
https://pubs.opengroup.org/onlinepubs/007904875/basedefs/assert.h.html
This patch involves two changes:
If you define the NDEBUG macro, assert does not use any parameters and directly returns a void expression.
assert should return a void expression and cannot use do-while statements.
If the following code , a compilation error will occur.
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
Requirement of nuttx as a minimum scheduler os.
Test build on Cortex-R52, fvp-armv8r-aarch32/nsh
Disable CONFIG_DEBUG_ASSERTIONS and without this change:
$ size nuttx
text data bss dec hex filename
19484 104 1092 20680 50c8 nuttx
Disable CONFIG_DEBUG_ASSERTIONS and with this change:
$ size nuttx
text data bss dec hex filename
17604 80 848 18532 4864 nuttx
Signed-off-by: chao an <anchao@lixiang.com>
The implementation of assert in linux is as follows:
define assert(expr) (__ASSERT_VOID_CAST (0))
After defining NDEBUG in sqlite, some variables will be undefined,
and referencing variables in assert will cause compilation errors.
sqlite3.c:28729:23: error: ‘mutexIsInit’ undeclared (first use in this function)
28729 | assert( GLOBAL(int, mutexIsInit) );
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
According to the standard definition, assert should return a void expression
https://pubs.opengroup.org/onlinepubs/007904875/basedefs/assert.h.html
This patch involves two changes:
If you define the NDEBUG macro, assert does not use any parameters and directly returns a void expression.
assert should return a void expression and cannot use do-while statements.
If the following code , a compilation error will occur.
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
The definition of __ASSERT has special define in some OS and librarys,
rename to __ASSERT__ to avoid conflict
Signed-off-by: chao an <anchao@xiaomi.com>
Test on sim/nsh:
(CONFIG_DEBUG_ASSERTIONS=y CONFIG_DEFAULT_SMALL=y)
text data bss dec hex filename
423626 27152 4128 454906 6f0fa nuttx /* before */
417010 27152 4128 448290 6d722 nuttx /* after */
-6616
Signed-off-by: chao an <anchao@xiaomi.com>
CURRENT_REGS may change during assert handling, so pass
in the 'regs' parameter at the entry point of _assert.
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
_assert is a kernel procedure, entered via system call to make the core
dump in privileged mode.
Running exit() from this context is not OK as it runs the registered
exit functions and flushes streams, which must not be done
from privileged mode as it is a security hole.
Thus, implement assert() into user space (again) and remove the exit()
call from the kernel procedure.
Gregory Nutt has submitted the SGA
Omni Hoverboards has submitted the SGA
Paul Alexander Patience has submitted the ICLA
as a result we can migrate the licenses to Apache.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
since exit will be only callable from userspace and change
the 1st argument from "const uint8_t *" to "const char *"
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I86487d57210ab63109148232da71dbc4d60a563b