All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 6/6] config.mak.dev: enable -Wunused-parameter by default
Date: Wed, 28 Aug 2024 00:00:49 -0400	[thread overview]
Message-ID: <20240828040049.GF3999193@coredump.intra.peff.net> (raw)
In-Reply-To: <20240828035722.GA3998881@coredump.intra.peff.net>

Having now removed or annotated all of the unused function parameters in
our code base, I found that each instance falls into one of three
categories:

  1. ignoring the parameter is a bug (e.g., a function takes a ptr/len
     pair, but ignores the length). Detecting these helps us find the
     bugs.

  2. the parameter is unnecessary (and usually left over from a
     refactoring or earlier iteration of a patches series). Removing
     these cleans up the code.

  3. the function has to conform to a specific interface (because it's
     used via a function pointer, or matches something on the other side
     of an #ifdef). These ones are annoying, but annotating them with
     UNUSED is not too bad (especially if the compiler tells you about
     the problem promptly).

Certainly instances of (3) are more common than (1), but after finding
all of these, I think there were enough cases of (1) that it justifies
the work in annotating all of the (3)s.

And since the code base is now at a spot where we compile cleanly with
-Wunused-parameter, turning it on will make it the responsibility of
individual patch writers going forward.

Signed-off-by: Jeff King <peff@peff.net>
---
 config.mak.dev | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config.mak.dev b/config.mak.dev
index 5229c35484..50026d1e0e 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -54,7 +54,6 @@ ifeq ($(filter extra-all,$(DEVOPTS)),)
 DEVELOPER_CFLAGS += -Wno-empty-body
 DEVELOPER_CFLAGS += -Wno-missing-field-initializers
 DEVELOPER_CFLAGS += -Wno-sign-compare
-DEVELOPER_CFLAGS += -Wno-unused-parameter
 endif
 endif
 
-- 
2.46.0.754.g24c813f009

  parent reply	other threads:[~2024-08-28  4:00 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 ` [PATCH 3/6] compat: disable -Wunused-parameter in 3rd-party code Jeff King
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 ` Jeff King [this message]
2024-08-28  5:56   ` [PATCH 6/6] config.mak.dev: enable -Wunused-parameter by default 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=20240828040049.GF3999193@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.