Enable -Wstrict-prototypes and -Wold-style-definition by default

Started by Bertrand Drouvotabout 12 hours ago1 messages
Jump to latest
#1Bertrand Drouvot
bertranddrouvot.pg@gmail.com

Hi hackers,

PFA a patch to $SUBJECT. The idea is to avoid having to chase those warnings
manually like 11171fe1fc8, cdf4b9aff2, 0e72b9d440, 7069dbcc31, f1283ed6cc,
7b66e2c086, e95126cf04 and 9f7c527af3 have done.

The idea has been discussed in [1]/messages/by-id/262909b8-3f4b-42ce-acd7-bdd4a6897990@eisentraut.org and [2]/messages/by-id/aTJ9T8HyJN3D024w@ip-10-97-1-34.eu-west-3.compute.internal.

The patch is divided in 2 parts:

0001: Prevent -Wstrict-prototypes and -Wold-style-definition warnings

It fixes the remaining warnings that those new flags would generate.

0002: Enable -Wstrict-prototypes and -Wold-style-definition by default

Those are available in all gcc and clang versions that support C11 and as C11
is required as of f5e0186f865c, then we can add them without capability test.

The new flags are moved in configure.ac late enough to avoid any error (for
example, PGAC_PRINTF_ARCHETYPE which uses -Werror and would fail to detect
gnu_printf if -Wstrict-prototypes is active) leading to mingw_cross_warning CI
task failing.

Also, readline headers trigger a lot of warnings with -Wstrict-prototypes, so
we make use of the system_header pragma to hide the warnings (as discussed in
[3]: /messages/by-id/1049756.1764861448@sss.pgh.pa.us

[1]: /messages/by-id/262909b8-3f4b-42ce-acd7-bdd4a6897990@eisentraut.org
[2]: /messages/by-id/aTJ9T8HyJN3D024w@ip-10-97-1-34.eu-west-3.compute.internal
[3]: /messages/by-id/1049756.1764861448@sss.pgh.pa.us

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachments:

v1-0001-Prevent-Wstrict-prototypes-and-Wold-style-definit.patchtext/x-diff; charset=us-asciiDownload+49-50
v1-0002-Enable-Wstrict-prototypes-and-Wold-style-definiti.patchtext/x-diff; charset=us-asciiDownload+27-1