git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 12/12] ll-merge: mark unused parameters in callbacks
Date: Mon, 17 Oct 2022 21:10:24 -0400	[thread overview]
Message-ID: <Y039AHoGP1DWgluA@coredump.intra.peff.net> (raw)
In-Reply-To: <Y036whEorZV0rOgB@coredump.intra.peff.net>

We have a generic ll_merge_fn, but not every implementation needs every
parameter. In particular, neither binary nor ext merges care about names
(since they do not generate conflict markers), and most do not need to
look at the ll_merge_driver itself.

Ironically, neither ll_xdl_merge() nor ll_union_merge() needs to have
their driver parameter annotated (even though both are named
drv_unused!).  This is because they may fall back to calling
ll_binary_merge() directly. And even though that function won't look at
it, we still pass it along, and hence it is "used" in the caller.

We could get away with passing NULL, but that's likely more confusing
and brittle than just passing along our own driver. And we have to keep
the driver parameter in all callbacks, since ll_ext_merge() uses it.

Signed-off-by: Jeff King <peff@peff.net>
---
 ll-merge.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/ll-merge.c b/ll-merge.c
index 8955d7e1f6..a8e2db9336 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -49,14 +49,14 @@ void reset_merge_attributes(void)
 /*
  * Built-in low-levels
  */
-static enum ll_merge_result ll_binary_merge(const struct ll_merge_driver *drv_unused,
+static enum ll_merge_result ll_binary_merge(const struct ll_merge_driver *drv UNUSED,
 			   mmbuffer_t *result,
-			   const char *path,
-			   mmfile_t *orig, const char *orig_name,
-			   mmfile_t *src1, const char *name1,
-			   mmfile_t *src2, const char *name2,
+			   const char *path UNUSED,
+			   mmfile_t *orig, const char *orig_name UNUSED,
+			   mmfile_t *src1, const char *name1 UNUSED,
+			   mmfile_t *src2, const char *name2 UNUSED,
 			   const struct ll_merge_options *opts,
-			   int marker_size)
+			   int marker_size UNUSED)
 {
 	enum ll_merge_result ret;
 	mmfile_t *stolen;
@@ -183,9 +183,9 @@ static void create_temp(mmfile_t *src, char *path, size_t len)
 static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,
 			mmbuffer_t *result,
 			const char *path,
-			mmfile_t *orig, const char *orig_name,
-			mmfile_t *src1, const char *name1,
-			mmfile_t *src2, const char *name2,
+			mmfile_t *orig, const char *orig_name UNUSED,
+			mmfile_t *src1, const char *name1 UNUSED,
+			mmfile_t *src2, const char *name2 UNUSED,
 			const struct ll_merge_options *opts,
 			int marker_size)
 {
-- 
2.38.0.371.g300879f34e

      parent reply	other threads:[~2022-10-18  1:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18  1:00 [PATCH 0/12] more unused-parameter fixes / annotations Jeff King
2022-10-18  1:01 ` [PATCH 01/12] diffstat_consume(): assert non-zero length Jeff King
2022-10-18  1:02 ` [PATCH 02/12] submodule--helper: drop unused argc from module_list_compute() Jeff King
2022-10-18  1:04 ` [PATCH 03/12] update-index: drop unused argc from do_reupdate() Jeff King
2022-10-18  1:05 ` [PATCH 04/12] mark unused parameters in trivial compat functions Jeff King
2022-10-18  1:05 ` [PATCH 05/12] object-file: mark unused parameters in hash_unknown functions Jeff King
2022-10-18  1:05 ` [PATCH 06/12] string-list: mark unused callback parameters Jeff King
2022-10-18  1:05 ` [PATCH 07/12] date: mark unused parameters in handler functions Jeff King
2022-10-18  1:08 ` [PATCH 08/12] apply: mark unused parameters in handlers Jeff King
2022-10-18  1:08 ` [PATCH 09/12] apply: mark unused parameters in noop error/warning routine Jeff King
2022-10-18  1:08 ` [PATCH 10/12] convert: mark unused parameter in null stream filter Jeff King
2022-10-18  1:09 ` [PATCH 11/12] diffcore-pickaxe: mark unused parameters in pickaxe functions Jeff King
2022-10-18  1:10 ` Jeff King [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y039AHoGP1DWgluA@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).