Skip to content

meson: make two compiler warnings fatal

I wasted the best part of an hour this morning because I didn't notice the following warnings (from Endless's branch):

../plugins/eos-blacklist/gs-plugin-eos-blacklist.c: In function 'gs_plugin_setup':
../plugins/eos-blacklist/gs-plugin-eos-blacklist.c:193:36: warning: implicit declaration of function 'flatpak_installation_get_default_locales'; did you mean 'flatpak_installation_get_default_languages'? [-Wimplicit-function-declaration]
    priv->flatpak_default_locales = flatpak_installation_get_default_locales (priv->installation, &local_error);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                    flatpak_installation_get_default_languages
../plugins/eos-blacklist/gs-plugin-eos-blacklist.c:193:36: warning: nested extern declaration of 'flatpak_installation_get_default_locales' [-Wnested-externs]
../plugins/eos-blacklist/gs-plugin-eos-blacklist.c:193:34: warning: assignment to 'char **' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    priv->flatpak_default_locales = flatpak_installation_get_default_locales (priv->installation, &local_error);

My Flatpak headers were older than my Flatpak shared library, which did define the 'flatpak_installation_get_default_locales' symbol. The default return type, int, is narrower than a pointer on x86_64 so the pointer was truncated and this would crash at runtime.

Of course, I could have passed -Dwerror=true to Meson but I believe that implicit-function-declaration and nested-externs should always be fatal, regardless of that setting.

Another option would be to add 'werror=true' to default_options, but I think this is bad practice: a new compiler version could cause perfectly good code to stop compiling.

Merge request reports