Git Mailing List Archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/14] more -Wunused-parameter annotations
@ 2023-07-03  6:43 Jeff King
  2023-07-03  6:43 ` [PATCH 01/14] test-ref-store: drop unimplemented reflog-expire command Jeff King
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:43 UTC (permalink / raw
  To: git

Here's another set of patches to silence -Wunused-parameter warnings.
With the exception of the first patch, these are all just adding
annotations (though I tried to document in each one any digging I did on
"this isn't a bug that we're not using it, right?").

So I don't think these should be controversial. But I wanted to mention
that I'll be offline for a month starting July 5th. So if there is any
substantive review after that, I'll be rather slow to respond. :)

  [01/14]: test-ref-store: drop unimplemented reflog-expire command
  [02/14]: do_for_each_ref_helper(): mark unused repository parameter
  [03/14]: http: mark unused parameters in curl callbacks
  [04/14]: http-push: mark unused parameter in xml callback
  [05/14]: am: mark unused keep_cr parameters
  [06/14]: count-objects: mark unused parameter in alternates callback
  [07/14]: revisions: drop unused "opt" parameter in "tweak" callbacks
  [08/14]: fsck: mark unused parameters in various fsck callbacks
  [09/14]: merge-tree: mark unused parameter in traverse callback
  [10/14]: replace: mark unused parameter in ref callback
  [11/14]: replace: mark unused parameter in each_mergetag_fn callback
  [12/14]: rev-parse: mark unused parameter in for_each_abbrev callback
  [13/14]: tag: mark unused parameters in each_tag_name_fn callbacks
  [14/14]: t/helper: mark unused callback void data parameters

 builtin/am.c                     |  4 ++--
 builtin/count-objects.c          |  2 +-
 builtin/diff-tree.c              |  2 +-
 builtin/fsck.c                   | 10 +++++-----
 builtin/index-pack.c             |  3 ++-
 builtin/log.c                    |  6 ++----
 builtin/merge-tree.c             |  4 +++-
 builtin/mktag.c                  |  8 ++++----
 builtin/replace.c                |  4 ++--
 builtin/rev-parse.c              |  2 +-
 builtin/tag.c                    |  4 ++--
 builtin/unpack-objects.c         |  3 ++-
 fsck.c                           |  4 ++--
 http-push.c                      |  2 +-
 http.c                           |  9 ++++++---
 object-file.c                    | 10 +++++-----
 refs.c                           |  2 +-
 revision.c                       |  2 +-
 revision.h                       |  2 +-
 t/helper/test-dump-split-index.c |  2 +-
 t/helper/test-oid-array.c        |  2 +-
 t/helper/test-ref-store.c        |  6 ------
 22 files changed, 46 insertions(+), 47 deletions(-)

-Peff

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/14] test-ref-store: drop unimplemented reflog-expire command
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
@ 2023-07-03  6:43 ` Jeff King
  2023-07-03  6:44 ` [PATCH 02/14] do_for_each_ref_helper(): mark unused repository parameter Jeff King
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:43 UTC (permalink / raw
  To: git

The reflog-expire command has been unimplemented since it was added in
80f2a6097c (t/helper: add test-ref-store to test ref-store functions,
2017-03-26). This causes -Wunused-parameter to complain, since the
function just calls die() without looking at its arguments.

We could mark these as UNUSED to silence the warning. But let's just
drop the function. It has no callers in the test suite and is not doing
anything useful, beyond perhaps reminding us that it's something we
_could_ be testing.

But since the bulk of the work in adding such tests would be the shell
bits that actually examine the reflog state before and after expiration,
this is not even a useful step in that direction. Somebody who wants to
do that work later can easily add this function back.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/helper/test-ref-store.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index fb18831ec2..aa900cbfab 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -268,11 +268,6 @@ static int cmd_delete_reflog(struct ref_store *refs, const char **argv)
 	return refs_delete_reflog(refs, refname);
 }
 
-static int cmd_reflog_expire(struct ref_store *refs, const char **argv)
-{
-	die("not supported yet");
-}
-
 static int cmd_delete_ref(struct ref_store *refs, const char **argv)
 {
 	const char *msg = notnull(*argv++, "msg");
@@ -326,7 +321,6 @@ static struct command commands[] = {
 	{ "reflog-exists", cmd_reflog_exists },
 	{ "create-reflog", cmd_create_reflog },
 	{ "delete-reflog", cmd_delete_reflog },
-	{ "reflog-expire", cmd_reflog_expire },
 	/*
 	 * backend transaction functions can't be tested separately
 	 */
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 02/14] do_for_each_ref_helper(): mark unused repository parameter
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
  2023-07-03  6:43 ` [PATCH 01/14] test-ref-store: drop unimplemented reflog-expire command Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 03/14] http: mark unused parameters in curl callbacks Jeff King
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

This function gets a repository parameter because it's a callback for
do_for_each_repo_ref_iterator(). But it's just a wrapper that passes
along each call to a regular each_ref_fn callback, and the latter
doesn't accept a repository argument.

Probably in the long run all of the each_ref_fn callbacks should get a
repository parameter, too. But changing that now would require updates
all over the code base. Until that happens, let's annotate this wrapper
callback to quiet the compiler's -Wunused-parameter warning.

Signed-off-by: Jeff King <peff@peff.net>
---
 refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/refs.c b/refs.c
index c029f64982..edeae90ebb 100644
--- a/refs.c
+++ b/refs.c
@@ -1588,7 +1588,7 @@ struct do_for_each_ref_help {
 	void *cb_data;
 };
 
-static int do_for_each_ref_helper(struct repository *r,
+static int do_for_each_ref_helper(struct repository *r UNUSED,
 				  const char *refname,
 				  const struct object_id *oid,
 				  int flags,
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 03/14] http: mark unused parameters in curl callbacks
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
  2023-07-03  6:43 ` [PATCH 01/14] test-ref-store: drop unimplemented reflog-expire command Jeff King
  2023-07-03  6:44 ` [PATCH 02/14] do_for_each_ref_helper(): mark unused repository parameter Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 04/14] http-push: mark unused parameter in xml callback Jeff King
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

These functions are all used as callbacks for curl, so they have to
conform to a particular interface. But they don't need all of their
parameters:

  - fwrite_null() throws away the input, so it doesn't look at most
    parameters

  - fwrite_wwwauth() in theory could take the auth struct in its void
    pointer, but instead we just access it as the global http_auth
    (matching the rest of the code in this file)

  - curl_trace() always writes via the trace mechanism, so it doesn't
    need its void pointer to know where to send things. Likewise, it
    ignores the CURL parameter, since nothing we trace requires querying
    the handle.

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

diff --git a/http.c b/http.c
index 5772c8ced3..5b8e9c8c48 100644
--- a/http.c
+++ b/http.c
@@ -196,7 +196,7 @@ static inline int is_hdr_continuation(const char *ptr, const size_t size)
 	return size && (*ptr == ' ' || *ptr == '\t');
 }
 
-static size_t fwrite_wwwauth(char *ptr, size_t eltsize, size_t nmemb, void *p)
+static size_t fwrite_wwwauth(char *ptr, size_t eltsize, size_t nmemb, void *p UNUSED)
 {
 	size_t size = eltsize * nmemb;
 	struct strvec *values = &http_auth.wwwauth_headers;
@@ -295,7 +295,8 @@ static size_t fwrite_wwwauth(char *ptr, size_t eltsize, size_t nmemb, void *p)
 	return size;
 }
 
-size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf)
+size_t fwrite_null(char *ptr UNUSED, size_t eltsize UNUSED, size_t nmemb,
+		   void *data UNUSED)
 {
 	return nmemb;
 }
@@ -820,7 +821,9 @@ static void curl_dump_info(char *data, size_t size)
 	strbuf_release(&buf);
 }
 
-static int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size, void *userp)
+static int curl_trace(CURL *handle UNUSED, curl_infotype type,
+		      char *data, size_t size,
+		      void *userp UNUSED)
 {
 	const char *text;
 	enum { NO_FILTER = 0, DO_FILTER = 1 };
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 04/14] http-push: mark unused parameter in xml callback
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (2 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 03/14] http: mark unused parameters in curl callbacks Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 05/14] am: mark unused keep_cr parameters Jeff King
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

The xml_start_tag() function is passed the expat library's
XML_SetElementHandler() function, so it has to conform to the
expected interface. But we don't actually care about the attributes
list. Mark it so that -Wunused-parameter does not complain.

Signed-off-by: Jeff King <peff@peff.net>
---
 http-push.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/http-push.c b/http-push.c
index 9ab2383d2b..a704f490fd 100644
--- a/http-push.c
+++ b/http-push.c
@@ -783,7 +783,7 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)
 static void one_remote_ref(const char *refname);
 
 static void
-xml_start_tag(void *userData, const char *name, const char **atts)
+xml_start_tag(void *userData, const char *name, const char **atts UNUSED)
 {
 	struct xml_ctx *ctx = (struct xml_ctx *)userData;
 	const char *c = strchr(name, ':');
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 05/14] am: mark unused keep_cr parameters
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (3 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 04/14] http-push: mark unused parameter in xml callback Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 06/14] count-objects: mark unused parameter in alternates callback Jeff King
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

When parsing the input, we have a "keep_cr" parameter to tell us how to
handle line endings. But this doesn't apply to stgit or hg patches
(which are not mailbox formats where we have to worry about that), so we
ignore the parameter entirely in those functions.

Let's mark these as unused so that -Wunused-parameter does not complain
about them.

Note that we could just drop these parameters entirely. They are
necessary to conform to the mail_conv_fn interface used by
split_mail_conv(), but these two callbacks are the only ones used with
that function. The other formats (which _do_ care about keep_cr) use
split_mail_mbox(). But it's conceivable that we'd eventually add another
format that does care about this option, so let's leave it as part of
the generic interface.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/am.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index a78daa6971..8451f5e423 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -787,7 +787,7 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,
  * A split_mail_conv() callback that converts an StGit patch to an RFC2822
  * message suitable for parsing with git-mailinfo.
  */
-static int stgit_patch_to_mail(FILE *out, FILE *in, int keep_cr)
+static int stgit_patch_to_mail(FILE *out, FILE *in, int keep_cr UNUSED)
 {
 	struct strbuf sb = STRBUF_INIT;
 	int subject_printed = 0;
@@ -870,7 +870,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
  * A split_patches_conv() callback that converts a mercurial patch to a RFC2822
  * message suitable for parsing with git-mailinfo.
  */
-static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr)
+static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr UNUSED)
 {
 	struct strbuf sb = STRBUF_INIT;
 	int rc = 0;
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 06/14] count-objects: mark unused parameter in alternates callback
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (4 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 05/14] am: mark unused keep_cr parameters Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 07/14] revisions: drop unused "opt" parameter in "tweak" callbacks Jeff King
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

Callbacks to for_each_altodb() get a void data pointer, but we don't
need it here. Mark it as unused to silence -Wunused-parameter.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/count-objects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index 97cdfb0ac5..2d4bb5e8d0 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -82,7 +82,7 @@ static int count_cruft(const char *basename UNUSED, const char *path,
 	return 0;
 }
 
-static int print_alternate(struct object_directory *odb, void *data)
+static int print_alternate(struct object_directory *odb, void *data UNUSED)
 {
 	printf("alternate: ");
 	quote_c_style(odb->path, NULL, stdout, 0);
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 07/14] revisions: drop unused "opt" parameter in "tweak" callbacks
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (5 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 06/14] count-objects: mark unused parameter in alternates callback Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 08/14] fsck: mark unused parameters in various fsck callbacks Jeff King
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

The setup_revision_opt struct has a "tweak" function pointer, which can
be used to adjust parameters after setup_revisions() parses arguments,
but before it finalizes setup. In addition to the rev_info struct, the
callback receives a pointer to the setup_revision_opt, as well.

But none of the existing callbacks looks at the extra "opt" parameter,
leading to -Wunused-parameter warnings.

We could mark it as UNUSED, but instead let's remove it entirely. It's
conceivable that it could be useful for a callback to have access to the
"opt" struct. But in the 13 years that this mechanism has existed,
nobody has used it. So let's just drop it in the name of simplifying.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/diff-tree.c | 2 +-
 builtin/log.c       | 6 ++----
 revision.c          | 2 +-
 revision.h          | 2 +-
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index d62caa6c8b..c9ba35f143 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -99,7 +99,7 @@ static const char diff_tree_usage[] =
 "  --root        include the initial commit as diff against /dev/null\n"
 COMMON_DIFF_OPTIONS_HELP;
 
-static void diff_tree_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt)
+static void diff_tree_tweak_rev(struct rev_info *rev)
 {
 	if (!rev->diffopt.output_format) {
 		if (rev->dense_combined_merges)
diff --git a/builtin/log.c b/builtin/log.c
index 89442dceda..91bc7d967e 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -718,8 +718,7 @@ static int show_tree_object(const struct object_id *oid UNUSED,
 	return 0;
 }
 
-static void show_setup_revisions_tweak(struct rev_info *rev,
-				       struct setup_revision_opt *opt)
+static void show_setup_revisions_tweak(struct rev_info *rev)
 {
 	if (rev->first_parent_only)
 		diff_merges_default_to_first_parent(rev);
@@ -862,8 +861,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
 	return cmd_log_deinit(cmd_log_walk(&rev), &rev);
 }
 
-static void log_setup_revisions_tweak(struct rev_info *rev,
-				      struct setup_revision_opt *opt)
+static void log_setup_revisions_tweak(struct rev_info *rev)
 {
 	if (rev->diffopt.flags.default_follow_renames &&
 	    diff_check_follow_pathspec(&rev->prune_data, 0))
diff --git a/revision.c b/revision.c
index 84768565ce..73f8c7e2e0 100644
--- a/revision.c
+++ b/revision.c
@@ -2955,7 +2955,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 	if (!revs->def)
 		revs->def = opt ? opt->def : NULL;
 	if (opt && opt->tweak)
-		opt->tweak(revs, opt);
+		opt->tweak(revs);
 	if (revs->show_merge)
 		prepare_show_merge(revs);
 	if (revs->def && !revs->pending.nr && !revs->rev_input_given) {
diff --git a/revision.h b/revision.h
index 25776af381..18f49565c2 100644
--- a/revision.h
+++ b/revision.h
@@ -428,7 +428,7 @@ void repo_init_revisions(struct repository *r,
  */
 struct setup_revision_opt {
 	const char *def;
-	void (*tweak)(struct rev_info *, struct setup_revision_opt *);
+	void (*tweak)(struct rev_info *);
 	unsigned int	assume_dashdash:1,
 			allow_exclude_promisor_objects:1,
 			free_removed_argv_elements:1;
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 08/14] fsck: mark unused parameters in various fsck callbacks
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (6 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 07/14] revisions: drop unused "opt" parameter in "tweak" callbacks Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 09/14] merge-tree: mark unused parameter in traverse callback Jeff King
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

There are a few callback functions which are used with the fsck code,
but it's natural that not all callbacks need all parameters. For
reporting, even something as obvious as "the oid of the object which had
a problem" is not always used, as some callers are only checking a
single object in the first place. And for both reporting and walking,
things like void data pointers and the fsck_options aren't always
necessary.

But since each such parameter is used by _some_ callback, we have to
keep them in the interface. Mark the unused ones in specific callbacks
to avoid triggering -Wunused-parameter.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/fsck.c           | 10 +++++-----
 builtin/index-pack.c     |  3 ++-
 builtin/mktag.c          |  8 ++++----
 builtin/unpack-objects.c |  3 ++-
 fsck.c                   |  4 ++--
 object-file.c            | 10 +++++-----
 6 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index fa26462337..9af71a4e03 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -92,11 +92,11 @@ static int objerror(struct object *obj, const char *err)
 	return -1;
 }
 
-static int fsck_error_func(struct fsck_options *o,
+static int fsck_error_func(struct fsck_options *o UNUSED,
 			   const struct object_id *oid,
 			   enum object_type object_type,
 			   enum fsck_msg_type msg_type,
-			   enum fsck_msg_id msg_id,
+			   enum fsck_msg_id msg_id UNUSED,
 			   const char *message)
 {
 	switch (msg_type) {
@@ -121,7 +121,7 @@ static int fsck_error_func(struct fsck_options *o,
 static struct object_array pending;
 
 static int mark_object(struct object *obj, enum object_type type,
-		       void *data, struct fsck_options *options)
+		       void *data, struct fsck_options *options UNUSED)
 {
 	struct object *parent = data;
 
@@ -206,8 +206,8 @@ static int traverse_reachable(void)
 	return !!result;
 }
 
-static int mark_used(struct object *obj, enum object_type object_type,
-		     void *data, struct fsck_options *options)
+static int mark_used(struct object *obj, int type UNUSED,
+		     void *data UNUSED, struct fsck_options *options UNUSED)
 {
 	if (!obj)
 		return 1;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index c1250b070f..f6c2f0909d 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -223,7 +223,8 @@ static void cleanup_thread(void)
 }
 
 static int mark_link(struct object *obj, enum object_type type,
-		     void *data, struct fsck_options *options)
+		     void *data UNUSED,
+		     struct fsck_options *options UNUSED)
 {
 	if (!obj)
 		return -1;
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 43e2766db4..d8e0b5afc0 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -18,11 +18,11 @@ static int option_strict = 1;
 
 static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
 
-static int mktag_fsck_error_func(struct fsck_options *o,
-				 const struct object_id *oid,
-				 enum object_type object_type,
+static int mktag_fsck_error_func(struct fsck_options *o UNUSED,
+				 const struct object_id *oid UNUSED,
+				 enum object_type object_type UNUSED,
 				 enum fsck_msg_type msg_type,
-				 enum fsck_msg_id msg_id,
+				 enum fsck_msg_id msg_id UNUSED,
 				 const char *message)
 {
 	switch (msg_type) {
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 1979532a9d..558b8485ba 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -214,7 +214,8 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
  * Verify its reachability and validity recursively and write it out.
  */
 static int check_object(struct object *obj, enum object_type type,
-			void *data, struct fsck_options *options)
+			void *data UNUSED,
+			struct fsck_options *options UNUSED)
 {
 	struct obj_buffer *obj_buf;
 
diff --git a/fsck.c b/fsck.c
index a219d6f2c0..feba5239a4 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1307,9 +1307,9 @@ int fsck_buffer(const struct object_id *oid, enum object_type type,
 
 int fsck_error_function(struct fsck_options *o,
 			const struct object_id *oid,
-			enum object_type object_type,
+			enum object_type object_type UNUSED,
 			enum fsck_msg_type msg_type,
-			enum fsck_msg_id msg_id,
+			enum fsck_msg_id msg_id UNUSED,
 			const char *message)
 {
 	if (msg_type == FSCK_WARN) {
diff --git a/object-file.c b/object-file.c
index 8d87720dd5..68a2397e33 100644
--- a/object-file.c
+++ b/object-file.c
@@ -2308,11 +2308,11 @@ int repo_has_object_file(struct repository *r,
  * report the minimal fsck error here, and rely on the caller to
  * give more context.
  */
-static int hash_format_check_report(struct fsck_options *opts,
-				     const struct object_id *oid,
-				     enum object_type object_type,
-				     enum fsck_msg_type msg_type,
-				     enum fsck_msg_id msg_id,
+static int hash_format_check_report(struct fsck_options *opts UNUSED,
+				     const struct object_id *oid UNUSED,
+				     enum object_type object_type UNUSED,
+				     enum fsck_msg_type msg_type UNUSED,
+				     enum fsck_msg_id msg_id UNUSED,
 				     const char *message)
 {
 	error(_("object fails fsck: %s"), message);
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 09/14] merge-tree: mark unused parameter in traverse callback
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (7 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 08/14] fsck: mark unused parameters in various fsck callbacks Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 10/14] replace: mark unused parameter in ref callback Jeff King
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

Our threeway_callback() does not bother to look at its "n" parameter. It
is static in this file and used only by trivial_merge_trees(), which
always passes 3 trees (hence the name "threeway"). It also does not look
at "dirmask". This is OK, as it handles directories specifically by
looking at the mode bits.

Other traverse_info callbacks need these, so we can't get drop them from
the interface. But let's annotate these ones to avoid complaints from
-Wunused-parameter.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/merge-tree.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 6f7db436d2..0de42aecf4 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -324,7 +324,9 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
  * The successful merge rules are the same as for the three-way merge
  * in git-read-tree.
  */
-static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *info)
+static int threeway_callback(int n UNUSED, unsigned long mask,
+			     unsigned long dirmask UNUSED,
+			     struct name_entry *entry, struct traverse_info *info)
 {
 	/* Same in both? */
 	if (same_entry(entry+1, entry+2) || both_empty(entry+1, entry+2)) {
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 10/14] replace: mark unused parameter in ref callback
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (8 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 09/14] merge-tree: mark unused parameter in traverse callback Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 11/14] replace: mark unused parameter in each_mergetag_fn callback Jeff King
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

We don't look at the "flags" parameter, which is natural for something
that is just printing the contents of the replace refs. But let's mark
it to appease -Wunused-parameter.

This probably should have been part of 63e14ee2d6 (refs: mark unused
each_ref_fn parameters, 2022-08-19), but I missed it as this one is a
repo_each_ref_fn, which takes an extra repository argument.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/replace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/replace.c b/builtin/replace.c
index 9ceaa25233..17b75229d2 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -49,7 +49,7 @@ struct show_data {
 
 static int show_reference(struct repository *r, const char *refname,
 			  const struct object_id *oid,
-			  int flag, void *cb_data)
+			  int flag UNUSED, void *cb_data)
 {
 	struct show_data *data = cb_data;
 
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 11/14] replace: mark unused parameter in each_mergetag_fn callback
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (9 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 10/14] replace: mark unused parameter in ref callback Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 12/14] rev-parse: mark unused parameter in for_each_abbrev callback Jeff King
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

We don't look at the "commit" parameter to our callback, as our
"mergetag_data" pointer contains the original name "ref", which we use
instead. But we can't get rid of it, since other for_each_mergetag
callbacks do use it. Let's mark the parameter to avoid
-Wunused-parameter warnings.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/replace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/replace.c b/builtin/replace.c
index 17b75229d2..da59600ad2 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -409,7 +409,7 @@ struct check_mergetag_data {
 	const char **argv;
 };
 
-static int check_one_mergetag(struct commit *commit,
+static int check_one_mergetag(struct commit *commit UNUSED,
 			       struct commit_extra_header *extra,
 			       void *data)
 {
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 12/14] rev-parse: mark unused parameter in for_each_abbrev callback
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (10 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 11/14] replace: mark unused parameter in each_mergetag_fn callback Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 13/14] tag: mark unused parameters in each_tag_name_fn callbacks Jeff King
  2023-07-03  6:44 ` [PATCH 14/14] t/helper: mark unused callback void data parameters Jeff King
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

We don't need to use the "data" parameter in this instance. Let's mark
it to avoid -Wunused-parameter warnings.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/rev-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 3e2ee44177..075e2c5aa4 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -226,7 +226,7 @@ static int anti_reference(const char *refname, const struct object_id *oid,
 	return 0;
 }
 
-static int show_abbrev(const struct object_id *oid, void *cb_data)
+static int show_abbrev(const struct object_id *oid, void *cb_data UNUSED)
 {
 	show_rev(NORMAL, oid, NULL);
 	return 0;
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 13/14] tag: mark unused parameters in each_tag_name_fn callbacks
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (11 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 12/14] rev-parse: mark unused parameter in for_each_abbrev callback Jeff King
@ 2023-07-03  6:44 ` Jeff King
  2023-07-03  6:44 ` [PATCH 14/14] t/helper: mark unused callback void data parameters Jeff King
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

We iterate over the set of input tag names using callbacks. But not all
operations need the same inputs, so some parameters go unused (but of
course not the same ones for each operation). Mark the unused ones to
avoid -Wunused-parameter warnings.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/tag.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/tag.c b/builtin/tag.c
index e63bee8eab..81ca3fa19a 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -121,7 +121,7 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,
 	return had_error;
 }
 
-static int collect_tags(const char *name, const char *ref,
+static int collect_tags(const char *name UNUSED, const char *ref,
 			const struct object_id *oid, void *cb_data)
 {
 	struct string_list *ref_list = cb_data;
@@ -155,7 +155,7 @@ static int delete_tags(const char **argv)
 	return result;
 }
 
-static int verify_tag(const char *name, const char *ref,
+static int verify_tag(const char *name, const char *ref UNUSED,
 		      const struct object_id *oid, void *cb_data)
 {
 	int flags;
-- 
2.41.0.586.g3c0cc15bc7


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 14/14] t/helper: mark unused callback void data parameters
  2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
                   ` (12 preceding siblings ...)
  2023-07-03  6:44 ` [PATCH 13/14] tag: mark unused parameters in each_tag_name_fn callbacks Jeff King
@ 2023-07-03  6:44 ` Jeff King
  13 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2023-07-03  6:44 UTC (permalink / raw
  To: git

Many callback interfaces have an extra void data parameter, but we don't
always need it (especially for dumping functions like the ones in test
helpers). Mark them as unused to avoid -Wunused-parameter warnings.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/helper/test-dump-split-index.c | 2 +-
 t/helper/test-oid-array.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c
index 5cf0b26dca..f29d18ef94 100644
--- a/t/helper/test-dump-split-index.c
+++ b/t/helper/test-dump-split-index.c
@@ -7,7 +7,7 @@
 #include "split-index.h"
 #include "ewah/ewok.h"
 
-static void show_bit(size_t pos, void *data)
+static void show_bit(size_t pos, void *data UNUSED)
 {
 	printf(" %d", (int)pos);
 }
diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c
index eef68833b7..aafe398ef0 100644
--- a/t/helper/test-oid-array.c
+++ b/t/helper/test-oid-array.c
@@ -4,7 +4,7 @@
 #include "setup.h"
 #include "strbuf.h"
 
-static int print_oid(const struct object_id *oid, void *data)
+static int print_oid(const struct object_id *oid, void *data UNUSED)
 {
 	puts(oid_to_hex(oid));
 	return 0;
-- 
2.41.0.586.g3c0cc15bc7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-07-03  6:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-03  6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
2023-07-03  6:43 ` [PATCH 01/14] test-ref-store: drop unimplemented reflog-expire command Jeff King
2023-07-03  6:44 ` [PATCH 02/14] do_for_each_ref_helper(): mark unused repository parameter Jeff King
2023-07-03  6:44 ` [PATCH 03/14] http: mark unused parameters in curl callbacks Jeff King
2023-07-03  6:44 ` [PATCH 04/14] http-push: mark unused parameter in xml callback Jeff King
2023-07-03  6:44 ` [PATCH 05/14] am: mark unused keep_cr parameters Jeff King
2023-07-03  6:44 ` [PATCH 06/14] count-objects: mark unused parameter in alternates callback Jeff King
2023-07-03  6:44 ` [PATCH 07/14] revisions: drop unused "opt" parameter in "tweak" callbacks Jeff King
2023-07-03  6:44 ` [PATCH 08/14] fsck: mark unused parameters in various fsck callbacks Jeff King
2023-07-03  6:44 ` [PATCH 09/14] merge-tree: mark unused parameter in traverse callback Jeff King
2023-07-03  6:44 ` [PATCH 10/14] replace: mark unused parameter in ref callback Jeff King
2023-07-03  6:44 ` [PATCH 11/14] replace: mark unused parameter in each_mergetag_fn callback Jeff King
2023-07-03  6:44 ` [PATCH 12/14] rev-parse: mark unused parameter in for_each_abbrev callback Jeff King
2023-07-03  6:44 ` [PATCH 13/14] tag: mark unused parameters in each_tag_name_fn callbacks Jeff King
2023-07-03  6:44 ` [PATCH 14/14] t/helper: mark unused callback void data parameters Jeff King

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).