-
Notifications
You must be signed in to change notification settings - Fork 804
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
Fix release build warning ('lfs_mlist_isopen' defined but not used) #994
base: master
Are you sure you want to change the base?
Fix release build warning ('lfs_mlist_isopen' defined but not used) #994
Conversation
Hi @bmcdonnell-fb, thanks for creating a PR. I don't think this works in the case where LFS_ASSERT is defined to do something different than the standard assert/NDEBUG. LFS_ASSERT is currently disk-dependent so this is not unreasonable. To be honest, these unused warnings have been getting a bit more than annoying, and will only get worse if we adopt more compile-time configurations... Is is possible to just disable this warning with I'm struggling to come up with an actual programmer mistake this warning protects against... |
@geky thanks for the constructive criticism.
Good point. Since you want to keep
I try to avoid disabling warnings; they are useful. This one helps developers to be sure to remove or use things they may have forgotten about. |
Or looks like they could put it in their |
This wouldn't be required if compiling with I'm thinking a bit more long term. My concern is as littlefs is maturing there is more interest in niche configurations that will chop up the internals more (hypothetical: LFS_READONLY, LFS_2BLOCK, LFS_NO_DIRS, LFS_NO_SEEK, etc). Staying on top of increasingly complicated ifdefs with Worst case, any unused code will be dropped at link time. |
TL;DR: IMO, disabling warnings is a code smell. As I said, I aim for 0 warnings in anything I'm working on. A build with 0 warnings is easy to check at a glance. Anytime there's a warning, it takes time to spot and interpret. If it's a persistent warning that someone has deemed not a problem, that's repeated developer bandwidth to see, recall, and move on every time. And it makes it easier to miss other warnings.
Correct. You could document that as another option for littlefs users. But please don't only present that option. IMO it should be 2nd choice.
IDK that I have a magic bullet for you, but I hope you and any other contributors will maintain that aspect, and a 0-warning build. The warning catches potential mistakes, and proper
Catching some possible mistakes (in this category) is better than catching none of them. I don't think that's the worst case, though. Like if you forget to use some code that you meant to. Or if application developers disable that warning in their entire application (not just for littlefs), and they forget to use some code. etc. |
I hope we can agree the worst option is a warning that is neither fixed nor disabled.
If the warning is counter-productive or unfixable, disabling the warning is warranted. For the same reason you want 0 warnings in the first place. The more useless warnings there are, the less value useful warnings are given. This is not the first time an issue has been created for an untested configuration warning on 'lfs_mlist_isopen' defined but not used.
This is the goal, but we'll have to see how CI keeps up with the number of possible build configurations growing
Point taken.
That's what testing is for. If not calling a vital function goes unnoticed, you probably need more tests. Or you don't actually need to call the function?
I'd strongly suggest separate warnings for the application and third-party libraries for the simple reason that you don't control what warnings libraries are developed under. Choosing the lowest-common denominator probably means you're missing out on useful warnings. |
Depends on how you disable it, IMO. If a specific warning is disabled on a line-by-line basis w/ Otherwise... maybe not.
Should be line-by-line, IMO.
But isn't that what the warnings are for? It can help you catch things without even any tests, or which may be orthogonal to your tests.
I'm not entirely sure what I think about this in general; I don't recall ever personally disabling a warning at the application level. But I do agree that the lowest common denominator would be a problem. |
Since we've zoomed out to discussing how to deal w/ warnings in general, I'll zoom back in for a moment, to highlight my above suggestion of what to do about this PR:
|
This is not a bad idea. My gut says #pragmas would bring portability issues, but I guess compilers are good at ignoring unknown pragmas... We just may end up with a lot of noise for various compilers. Unfortunately #pragmas are not very macro-able...
Maybe I just have PTSD from Java's serialVersionUID warnings :) I was probably being too aggressive, but this will be revisited when looking at how littlefs can be chopped up into smaller builds. We'll probably need some robust/repeatable rules/patterns around unused functions to prevent things from getting too messy. |
You could maybe |
Ahh, I was not aware of |
No description provided.