-
Notifications
You must be signed in to change notification settings - Fork 1.5k
assert: change the do-while of assert to a conditional expression #11734
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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>
xiaoxiang781216
approved these changes
Feb 21, 2024
jerpelea
approved these changes
Feb 21, 2024
These variables will trigger variable 'ret' set but not used warnings due to different configurations. Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
acassis
approved these changes
Feb 21, 2024
Contributor
|
I encountered a build error with qemu-armv8a:netnsh_smp_hv |
Contributor
|
rv-virt:nsh esp32-devkitc:smp |
Contributor
|
I think we should revert this PR and fix all warnings before merging this PR. |
Contributor
|
@acassis the ci doesn't pass yet:(. |
Contributor
Author
|
@masayuki2009 I submitted a repair patch, which involves two repositories |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
assert: change the do-while of assert to a conditional expression
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.
Impact
Testing
sim