git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 09/11] mark unused read_tree_recursive() callback parameters

From
Jeff King <peff@peff.net>
Date
Aug 19, 2022, 10:08 UTC
Message-ID
<Yv9hMTaIwk2Ui6/7@coredump.intra.peff.net>
In-Reply-To
<Yv9gxqH6nK2KYnNj@coredump.intra.peff.net>

We pass a callback to read_tree_recursive(), but not every callback needs every parameter. Let's mark the unused ones to satisfy -Wunused-parameter.

Signed-off-by: Jeff King <peff@peff.net>
---
 archive-tar.c      |  2 +-
 archive-zip.c      |  2 +-
 archive.c          |  3 ++-
 builtin/checkout.c |  2 +-
 builtin/log.c      |  7 ++++---
 builtin/ls-tree.c  | 13 ++++++++-----
 merge-recursive.c  |  2 +-
 7 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/archive-tar.c b/archive-tar.c
index 45e5d91407..0d66a1e0a8 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -421,7 +421,7 @@ static int git_tar_config(const char *var, const char *value, void *cb)
 	return tar_filter_config(var, value, cb);
 }
 
-static int write_tar_archive(const struct archiver *ar,
+static int write_tar_archive(const struct archiver *UNUSED(ar),
 			     struct archiver_args *args)
 {
 	int err = 0;
diff --git a/archive-zip.c b/archive-zip.c
index 854bceb018..d63782dc31 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -618,7 +618,7 @@ static int archive_zip_config(const char *var, const char *value,
 	return userdiff_config(var, value);
 }
 
-static int write_zip_archive(const struct archiver *ar,
+static int write_zip_archive(const struct archiver *UNUSED(ar),
 			     struct archiver_args *args)
 {
 	int err;
diff --git a/archive.c b/archive.c
index d5109abb89..8b165e935b 100644
--- a/archive.c
+++ b/archive.c
@@ -382,7 +382,8 @@ struct path_exists_context {
 	struct archiver_args *args;
 };
 
-static int reject_entry(const struct object_id *oid, struct strbuf *base,
+static int reject_entry(const struct object_id *UNUSED(oid),
+			struct strbuf *base,
 			const char *filename, unsigned mode,
 			void *context)
 {
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 713410ce2c..d18c8c886e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -125,7 +125,7 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm
 }
 
 static int update_some(const struct object_id *oid, struct strbuf *base,
-		const char *pathname, unsigned mode, void *context)
+		       const char *pathname, unsigned mode, void *UNUSED(context))
 {
 	int len;
 	struct cache_entry *ce;
diff --git a/builtin/log.c b/builtin/log.c
index 9b937d59b8..79a2e4d0bb 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -645,9 +645,10 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
 	return 0;
 }
 
-static int show_tree_object(const struct object_id *oid,
-		struct strbuf *base,
-		const char *pathname, unsigned mode, void *context)
+static int show_tree_object(const struct object_id *UNUSED(oid),
+			    struct strbuf *UNUSED(base),
+			    const char *pathname, unsigned mode,
+			    void *context)
 {
 	FILE *file = context;
 	fprintf(file, "%s%s\n", pathname, S_ISDIR(mode) ? "/" : "");
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index e279be8bb6..48df337605 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -142,7 +142,7 @@ static int show_recursive(const char *base, size_t baselen, const char *pathname
 }
 
 static int show_tree_fmt(const struct object_id *oid, struct strbuf *base,
-			 const char *pathname, unsigned mode, void *context)
+			 const char *pathname, unsigned mode, void *UNUSED(context))
 {
 	size_t baselen;
 	int recurse = 0;
@@ -213,7 +213,7 @@ static void show_tree_common_default_long(struct strbuf *base,
 
 static int show_tree_default(const struct object_id *oid, struct strbuf *base,
 			     const char *pathname, unsigned mode,
-			     void *context)
+			     void *UNUSED(context))
 {
 	int early;
 	int recurse;
@@ -230,7 +230,8 @@ static int show_tree_default(const struct object_id *oid, struct strbuf *base,
 }
 
 static int show_tree_long(const struct object_id *oid, struct strbuf *base,
-			  const char *pathname, unsigned mode, void *context)
+			  const char *pathname, unsigned mode,
+			  void *UNUSED(context))
 {
 	int early;
 	int recurse;
@@ -259,7 +260,8 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
 }
 
 static int show_tree_name_only(const struct object_id *oid, struct strbuf *base,
-			       const char *pathname, unsigned mode, void *context)
+			       const char *pathname, unsigned mode,
+			       void *UNUSED(context))
 {
 	int early;
 	int recurse;
@@ -279,7 +281,8 @@ static int show_tree_name_only(const struct object_id *oid, struct strbuf *base,
 }
 
 static int show_tree_object(const struct object_id *oid, struct strbuf *base,
-			    const char *pathname, unsigned mode, void *context)
+			    const char *pathname, unsigned mode,
+			    void *UNUSED(context))
 {
 	int early;
 	int recurse;
diff --git a/merge-recursive.c b/merge-recursive.c
index 775ebe2182..08c1c36d33 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -456,7 +456,7 @@ static void unpack_trees_finish(struct merge_options *opt)
 	clear_unpack_trees_porcelain(&opt->priv->unpack_opts);
 }
 
-static int save_files_dirs(const struct object_id *oid,
+static int save_files_dirs(const struct object_id *UNUSED(oid),
 			   struct strbuf *base, const char *path,
 			   unsigned int mode, void *context)
 {
-- 
2.37.2.928.g0821088f4a
Previous: Jeff KingNext: Jeff King
Message 10 of 22 in “annotating unused function parameters”
  1. 0/11 annotating unused function parametersJeff King, Aug 19, 2022
  2. 01/11 git-compat-util: add UNUSED macroJeff King, Aug 19, 2022
  3. 02/11 refs: mark unused each_ref_fn parametersJeff King, Aug 19, 2022
  4. 03/11 refs: mark unused reflog callback parametersJeff King, Aug 19, 2022
  5. 04/11 refs: mark unused virtual method parametersJeff King, Aug 19, 2022
  6. 05/11 transport: mark bundle transport_options as unusedJeff King, Aug 19, 2022
  7. 06/11 streaming: mark unused virtual method parametersJeff King, Aug 19, 2022
  8. 07/11 config: mark unused callback parametersJeff King, Aug 19, 2022
  9. 08/11 hashmap: mark unused callback parametersJeff King, Aug 19, 2022
  10. 09/11 mark unused read_tree_recursive() callback parametersJeff King, Aug 19, 2022
  11. 10/11 run-command: mark unused async callback parametersJeff King, Aug 19, 2022
  12. 11/11 is_path_owned_by_current_uid(): mark "report" parameter as unusedJeff King, Aug 19, 2022
  13. Ævar Arnfjörð BjarmasonAug 19, 2022
  14. Derrick StoleeAug 19, 2022
  15. Ævar Arnfjörð BjarmasonAug 19, 2022
  16. Jeff KingAug 20, 2022
  17. Junio C HamanoAug 20, 2022
  18. Derrick StoleeAug 22, 2022
  19. Ævar Arnfjörð BjarmasonAug 25, 2022
  20. Jeff KingAug 26, 2022
  21. Phillip WoodAug 26, 2022
  22. Junio C HamanoAug 26, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.