Skip to content
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 compilation error bad-function-cast. #609

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

opilat
Copy link
Contributor

@opilat opilat commented Nov 8, 2021

Fix compilation error bad-function-cast.

error: cast from function call of type '_Bool' to non-matching type 'unsigned int' [-Werror=bad-function-cast]

error: cast from function call of type '_Bool' to non-matching type 'unsigned int' [-Werror=bad-function-cast]
@opilat opilat force-pushed the Fix_compilation_error_GCC_10_3_0 branch from c237d93 to 98cf9d0 Compare November 8, 2021 12:57
@geky geky added the lint label Mar 20, 2022
@geky
Copy link
Member

geky commented Mar 21, 2022

Hi @opilat, thanks for creating a PR.

I'm not sure I really see the value of this warning, at least for littlefs, and it doesn't seem to be present in -Wall or -Wextra. Have you considered just disabling this warning for littlefs in your build system?

@opilat
Copy link
Contributor Author

opilat commented Mar 21, 2022 via email

@geky
Copy link
Member

geky commented Mar 23, 2022

The proposed change is more defensive code style and still worth of
merge. What if /lfs_gstate_hasorphans/ changes its return value?

I'm less concerned with the current code and more concerned with future changes. littlefs is still being developed and some of the more aggressive warnings we accepted have caused more problems than benefits (mostly -Wshadow).

I'm also struggling to understand the defensive value of this warning, from reading up on it seem to be for catching implicitly defined functions, but this is something modern version of GCC have an explicit warning for.


Disabling specific warnings for parts of build make configuration slightly confusing.

On the other hand it makes it easier to upgrade your compiler, since a compiler upgrade no longer risks needing to fix warnings in depended projects. Just from my small experience external warnings quickly get too time-consuming to fix when you have many dependencies.

@vonj
Copy link

vonj commented Mar 23, 2022 via email

@geky
Copy link
Member

geky commented Dec 5, 2022

@vonj that sounds reasonable. Assuming you are not using -Wall and instead have the warning list explicit (which sounds doable).

I'd still advocate for separate warning flags for the code you are working on and for dependencies. You want to know as much information about the code you are working on to know possible sources of errors. But for dependencies this approaches noise. And any code change carries its own risk of unintentionally introducing a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants