-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include: When defining NDEBUG, assert will implement alignment standards #12303
Conversation
@Gary-Hobson after your modification microADB is failing here:
Seems like you need to replace "#define assert(f) (0)" with something like "#define assert(f) (f && 0)". This is strange because UNUSED() should avoid the issue, but is not working! |
I thought that the internal assertions, like Also before Is this changed now? |
No, DEBUGASSERT is controlled by CONFIG_DEBUG_ASSERTIONS. ASSERT, VERIFY and assert are controlled by NDEBUG.
this patch doesn't change the assertion behavior, only the warning of unused variable may generate in the new patch if you use assert, but it's required by spec. |
can't not, since the spec require that assert shouldn't reference f when NDEBUG is defined
Yes. @Gary-Hobson please find the reason why UNUSED doesn't work as expect. |
This is not correct. Please see how the If But as it has been discussed before in the mailing list, it is considered beneficial for the kernel to have its own assertion macros, and have the ability to control them independently from the apps. |
Sorry, I checked again the code and it seems that I am wrong. Indeed the behavior is not changing now. As I understand this change has already happened here. However, the rest of the points I think that still hold. What is the value of having both |
ASSERT() is an internal api, so we can always reference the argument and avoid use UNUSED macro in many places. |
There is no UNUSED in the source code of microADB. After I added it to the code, the compilation warning disappeared. This PR ignores the compilation warning in microADB. This warning has been fixed in the latest version of microADB |
@Gary-Hobson let's update microADB in apps to the last version. |
baa5fa2
to
9f5c0f3
Compare
As defined by the C standard, if NDEBUG is defined, assert should do nothing but be simply defined as: #define assert(ignore) ((void)0) Reference link: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/assert.h.html Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Summary
As defined by the C standard, if NDEBUG is defined, assert should do nothing but be simply defined as:
#define assert(ignore) ((void)0)
Reference link:
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/assert.h.html
Impact
Testing