Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


When we made the original OOo code base warning-clean a number of years ago, many warnings about unused parameters were silenced by removing the parameter name, instead of actually fixing the code by dropping the unused parameter. Of course, dropping an unused parameter is not always the right fix, e.g., in virtual functions (where some overrides require the parameter and others don't, so it consistently needs to be present in all overrides).

That gave me the idea of writing a GCC plugin (as a gcc-python-plugin script, see <https://fedorahosted.org/gcc-python-plugin/>) that looks for unused, unnamed parameters (so that they can be revisited now, deciding on a proper fix), but takes into account patterns where the parameter is likely legitimately unused (like in the case of virtual functions). (In turn, I wrote that script mainly to have something to present as <http://fosdem.org/2012/schedule/event/libocompiler> "Analysing LibreOffice with Compiler plugins.")

However, there are still a number of legitimately unused function parameters that the script does not catch (think about functions that need to adhere to a certain signature, so their addresses can be assigned to function pointers of given type). So I started to annotate those cases with GCC's __attribute__ ((unused)), wrapped in a newly introduced SAL_UNUSED_PARAMETER (sal/types.h), in the LO source code (and let the script ignore those). Unfortunately, I also needed to add __attribute__ ((unused)) annotations to a number of headers from external modules included in the LO code base (I did that with specific new patches that are only relevant when running the plugin script, and are only applied to the external source when building with GCC).

The work turned out to be more tedious than anticipated, with many legitimately unused parameters having to be annotated, and not that many spectacular cases where removing a truly unused parameter has a rippling effect of allowing to also remove sizeable chunks of code that supplied values for that parameter in calls of the given function. Anyway, I carried along up into somewhere in svl, the result is <http://cgit.freedesktop.org/libreoffice/core/commit/?id=7c704c78d3c652504c064b4ac7af55a2c1ee49bb> "Removed some unused parameters; added SAL_UNUSED_PARAMETER." Maybe carrying this further up into the higher modules will lead to more satisfying results... I'll see if I can extract an easy hack from this.

So, just in case you stumble across a newly introduced SAL_UNUSED_PARAMETER, you know what it is there for. The GCC plugin script itself is detailed at <https://fedorahosted.org/pipermail/gcc-python-plugin/2012-January/000157.html> "Additions for C++."

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.