[PATCH] staging: vchiq: add 'static' to function definition
Scott J. Crouch
scottjcrouch at gmail.com
Sat Oct 29 19:43:46 PDT 2022
On 28/10/22 01:08, Arnd Bergmann wrote:
> On Sat, Oct 22, 2022, at 10:07, Greg Kroah-Hartman wrote:
>> On Sat, Oct 22, 2022 at 03:35:48PM +1100, Scott J. Crouch wrote:
>
>> Nice try, but this breaks the build in a very horrible and strange way
>> that no one has been able to figure out yet:
>
> I got curious and figured out what happens:
>
> Without CONFIG_OF, of_match_node() always returns NULL, so
> vchiq_probe() returns -EINVAL unconditionally before calling
> vchiq_platform_init().
>
> If vchiq_platform_init() is marked 'static', gcc's dead code
> elimination then eliminates it, which in turn means that
> 'g_fragments_base' is never initialized and gets replaced
> with a NULL pointer.
Good spotting. Actually, I was clumsily learning how to run sparse on the
staging directory and wasn't sure what config to use that didn't involve
enabling everything manually. But from what I can tell, it's OF_OVERLAY (or
something downstream of that) that gets rid of the warning. BCM2835_VCHIQ
requires BCM_VIDEOCORE which already depends on OF. I'm confused because I
don't actually know how to reproduce the gcc warning without manually enabling
the module such that OF is enabled but OF_OVERLAY isn't, since allmodconfig
enables both -- maybe there's a way to do that.
I'm also confused why devm_rpi_firmware_get() doesn't have the same problem as
of_match_node() just above it -- it returns NULL when RASPBERRYPI_FIRMWARE is
unset, but gcc still builds without the warning.
Scott.
More information about the linux-rpi-kernel
mailing list