-
Notifications
You must be signed in to change notification settings - Fork 1.9k
cmd/zpool cstyle issues #17885
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
base: master
Are you sure you want to change the base?
cmd/zpool cstyle issues #17885
Conversation
add missing headers. usage() is no-return, so anything after call to it is unreachable code. use (void) cast where we do ignore return value. Signed-off-by: Toomas Soome <[email protected]>
|
What's the rationale for the |
The reason is that by using (void) cast we acknowledge that we do ignore the return value knowingly and they do silence 'unused return value' warnings. (Also they sometimes do make people to ask if it is really good idea to ignore the return value in some places where it should not be ignored;) we are getting those warnings with smatch. |
Which compiler & version are you using for this? If that were true we should have all hell breaking loose in CI, but I've never seen it making a difference there or locally.
If a return outright must not be returned, it can be annotated with To be clear, I'm not against more safety; I'm just don't know where it realistically does anything, and its a big readability hit. If we are going to do it, then I want to do it everywhere. |
as I wrote, we do get them with smatch (static analyzer).
we can not annotate OS API;)
readability hit is already there, the code is mixture of (void) casts used in inherited code and not used in updated code;) I did create pull req for cmd/zpool because I havent got through next ones yet;) |
|
Sorry, I missed that you'd said smatch. Can you silence it? I haven't seen this regularly with other analyzers I've used (though perhaps they can be configured that way). This seems like a lot of clutter to add for one tool.
Yeah, I've been low-key removing them as I modify stuff. Obviously, I'm not convinced, because they don't regularly silence anything in any of the compilers and tests we use. That's my opinion of course, and others might not agree. But I think if we are going to do this, I want a cstyle lint and/or compiler flags that will cause a compile error any time we miss one. Otherwise, its just going to fall out of sync again. |
yes we can silence it.
Well yes, essentially it is a question if we want to get notified about unhandled return values or not. |
|
I've been mulling this over for a while now. Where I finally landed is I think it is reasonable to require a Where I think we all agree is we need to pick a style and enforce it. Otherwise we'll simply fall out of sync again. It sounds like if we were to add a |
add missing headers.
usage() is no-return, so anything after call to it is unreachable code.
use (void) cast where we do ignore return value.
Motivation and Context
fix errors and warnings in case the build system is checking the error cases listed above.
Description
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by.