From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 3/6] compat: disable -Wunused-parameter in 3rd-party code
Date: Tue, 27 Aug 2024 23:58:55 -0400 [thread overview]
Message-ID: <20240828035855.GC3999193@coredump.intra.peff.net> (raw)
In-Reply-To: <20240828035722.GA3998881@coredump.intra.peff.net>
We carry some vendored 3rd-party code in compat/ that does not build
cleanly with -Wunused-parameters. We could mark these with UNUSED, but
there are two reasons not to:
1. This is code imported from elsewhere, so we'd prefer to avoid
modifying it in an invasive way that could create conflicts if we
tried to pull in a new version.
2. These files don't include git-compat-util.h at all, so we'd need to
factor out (or repeat) our UNUSED macro.
In theory we could modify the build process to invoke the compiler with
the extra warning disabled for these files, but there are tricky corner
cases there (e.g., for NO_REGEX we cannot assume that the compiler
understands -Wno-unused-parameter as an option, so we'd have to use our
detect-compiler script).
Instead, let's rely on the gcc diagnostic #pragma. This is horribly
unportable, of course, but it should do what we want. Compilers which
don't understand this particular pragma should ignore it (per the
standard), and compilers which do care about "-Wunused-parameter" will
hopefully respect it, even if they are not gcc (e.g., clang does).
Signed-off-by: Jeff King <peff@peff.net>
---
compat/nedmalloc/nedmalloc.c | 2 ++
compat/regex/regcomp.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/compat/nedmalloc/nedmalloc.c b/compat/nedmalloc/nedmalloc.c
index 2c0ace7075..145255da43 100644
--- a/compat/nedmalloc/nedmalloc.c
+++ b/compat/nedmalloc/nedmalloc.c
@@ -31,6 +31,8 @@ DEALINGS IN THE SOFTWARE.
/*#pragma optimize("a", on)*/
#endif
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+
/*#define FULLSANITYCHECKS*/
#include "nedmalloc.h"
diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c
index 6c5d455e92..8d93a9b93f 100644
--- a/compat/regex/regcomp.c
+++ b/compat/regex/regcomp.c
@@ -17,6 +17,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+
#if defined __TANDEM
/* This is currently duplicated from git-compat-utils.h */
# ifdef NO_INTPTR_T
--
2.46.0.754.g24c813f009
next prev parent reply other threads:[~2024-08-28 3:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 3:57 [PATCH 0/6] unused parameters: the final countdown Jeff King
2024-08-28 3:57 ` [PATCH 1/6] gc: mark unused config parameter in virtual functions Jeff King
2024-08-28 3:57 ` [PATCH 2/6] t-reftable-readwrite: mark unused parameter in callback function Jeff King
2024-08-28 3:58 ` Jeff King [this message]
2024-08-28 3:59 ` [PATCH 4/6] compat: disable -Wunused-parameter in win32/headless.c Jeff King
2024-08-28 4:00 ` [PATCH 5/6] compat: mark unused parameters in win32/mingw functions Jeff King
2024-08-28 4:00 ` [PATCH 6/6] config.mak.dev: enable -Wunused-parameter by default Jeff King
2024-08-28 5:56 ` Eric Sunshine
2024-08-28 8:21 ` Patrick Steinhardt
2024-08-28 14:48 ` [PATCH 7/6] CodingGuidelines: mention -Wunused-parameter and UNUSED Jeff King
2024-08-28 19:53 ` Eric Sunshine
2024-08-28 15:17 ` [PATCH 6/6] config.mak.dev: enable -Wunused-parameter by default Junio C Hamano
2024-08-28 4:12 ` [PATCH 0/6] unused parameters: the final countdown Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240828035855.GC3999193@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.