Open joerchan opened 2 weeks ago
why not just use __maybe_unused
, even if it does not carry any information on why it may not be used? This is used in quite a few places, eg, on regulator drivers.
why not just use
__maybe_unused
, even if it does not carry any information on why it may not be used? This is used in quite a few places, eg, on regulator drivers.
I think this is a clean approach as well.
Introduction
Add a macro to that adds __unused attribute to a function unless a specific Kconfig is enabled.
Problem description
Some of the zephyr utility macros take a function as input, but may end up not referencing the function based on certain Kconfig symbols being enabled. There should be an easy way to fix this warning to avoid having to ifdef the function and everything else that function may reference.
Proposed change
Add macro: UNUSED_UNLESS (or something similar) that can be added to functions that may end up being compiled out by other utility macros.
Alternatively macro specific to the macro that can end up not referencing the function that would be add the __unused attribute when needed.
Detailed RFC
Some of the zephyr utility macros take a function as input, but may end up not referencing the function based on certain Kconfig symbols being enabled. There should be an easy way to fix this warning to avoid having to ifdef the function and everything else that function may reference. The function that ends up not being used can reference other functions that only have that as a reference, and it ends up with cascading ifdef code to find all possible combinations of a static function being referenced or not.
For example:
Here
enter_dpd
needs to beifdef
, butexit_dpd
has other references. If the other reference toexit_depd
is also ifdef then we need an ifdef A || B on this function.Proposed change (Detailed)
Add macro: UNUSED_UNLESS (or something similar) that can be added to functions that may end up being compiled out by other utility macros.
Usage:
Alternatively macro specific to the macro that can end up not referencing the function that would be add the __unused attribute when needed.
Usage:
Dependencies
None
Concerns and Unresolved Questions
Not sure where exactly the UNUSED_UNLESS define belongs.
Alternatives
RFC lists 2 alternatives.