Re: consider -Wmissing-variable-declarations
Peter Eisentraut <peter@eisentraut.org>
I have committed the first few of these. (The compiler warning flag itself is not activated yet.) This should allow you to proceed with your patches that add various const qualifiers. I'll come back to the rest later. On 18.06.24 17:02, Andres Freund wrote: >> diff --git a/src/bin/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c >> index 07bf356b70c..5a124385b7c 100644 >> --- a/src/bin/pg_archivecleanup/pg_archivecleanup.c >> +++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c >> @@ -19,17 +19,18 @@ >> #include "common/logging.h" >> #include "getopt_long.h" >> >> -const char *progname; >> +static const char *progname; > > Hm, this one I'm not so sure about. The backend version is explicitly globally > visible, and I don't see why we shouldn't do the same for other binaries. We have in various programs a mix of progname with static linkage and with external linkage. AFAICT, this is merely determined by whether there are multiple source files that need it, not by some higher-level scheme. >> From d89312042eb76c879d699380a5e2ed0bc7956605 Mon Sep 17 00:00:00 2001 >> From: Peter Eisentraut <peter@eisentraut.org> >> Date: Sun, 16 Jun 2024 23:52:06 +0200 >> Subject: [PATCH v2 05/10] Fix warnings from -Wmissing-variable-declarations >> under EXEC_BACKEND >> >> The NON_EXEC_STATIC variables need a suitable declaration in a header >> file under EXEC_BACKEND. >> >> Also fix the inconsistent application of the volatile qualifier for >> PMSignalState, which was revealed by this change. > > I'm very very unenthused about adding volatile to more places. It's rarely > correct and often slow. But I guess this doesn't really make it any worse. Yeah, it's not always clear with volatile, but in this one case it's probably better to keep it consistent rather than having to cast it away or something. >> +#ifdef TRACE_SYNCSCAN >> +#include "access/syncscan.h" >> +#endif > > I'd just include it unconditionally. My thinking here was that if we apply an include file cleaner (like iwyu) sometime, it would flag this include as unused. This way it's clearer what it's for.
Commits
-
Use CXXFLAGS instead of CFLAGS for linking C++ code
- b9f7ceabd820 16.14 landed
- b6b7e96365eb 17.10 landed
- 41d75b9a4a1c 15.18 landed
- 231570d33581 14.23 landed
- 365b5a345b26 18.0 landed
-
Add -Wmissing-variable-declarations to the standard compilation flags
- 66188912566b 18.0 landed
-
Include bison header files into implementation files
- 9fb855fe1ae0 18.0 landed
-
Fix -Wmissing-variable-declarations warnings for float.c special case
- 37c6923cf3d8 18.0 landed
-
Add extern declarations for Bison global variables
- ab61c40bfa2b 18.0 landed
-
Move all extern declarations for GUC variables to header files
- 774d47b6c01a 18.0 landed
-
Move extern declarations for EXEC_BACKEND to header files
- d3cc5ffe81f6 18.0 landed
-
Get rid of a global variable
- 935e675f3c9e 18.0 landed
-
Add missing includes for some global variables
- 881455e57b12 18.0 landed
-
Convert some extern variables to static
- 720b0eaae9b8 18.0 landed
-
Improve some global variable declarations
- 8f8bcb88833e 18.0 landed
-
Remove useless extern keywords
- 3fb59e789dd9 18.0 landed