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

[PATCH 8/9] list-objects-filter: mark unused parameters in virtual functions

From
Jeff King <peff@peff.net>
Date
Dec 13, 2022, 11:14 UTC
Message-ID
<Y5hej4EQU3l68rgT@coredump.intra.peff.net>
In-Reply-To
<Y5hdvpbLpXySHFRz@coredump.intra.peff.net>

The "struct filter" abstract type defines several virtual function pointers. Not all of the concrete functions need every parameter, but they have to conform to the generic interface. Mark unused ones to silence -Wunused-parameter.

Signed-off-by: Jeff King <peff@peff.net>
---
 list-objects-filter.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/list-objects-filter.c b/list-objects-filter.c
index b9543545ca..2bbac622be 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -70,13 +70,13 @@ struct filter {
 };
 
 static enum list_objects_filter_result filter_blobs_none(
-	struct repository *r,
+	struct repository *r UNUSED,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
-	const char *pathname,
-	const char *filename,
+	const char *pathname UNUSED,
+	const char *filename UNUSED,
 	struct oidset *omits,
-	void *filter_data_)
+	void *filter_data_ UNUSED)
 {
 	switch (filter_situation) {
 	default:
@@ -112,7 +112,7 @@ static enum list_objects_filter_result filter_blobs_none(
 }
 
 static void filter_blobs_none__init(
-	struct list_objects_filter_options *filter_options,
+	struct list_objects_filter_options *filter_options UNUSED,
 	struct filter *filter)
 {
 	filter->filter_object_fn = filter_blobs_none;
@@ -159,11 +159,11 @@ static int filter_trees_update_omits(
 }
 
 static enum list_objects_filter_result filter_trees_depth(
-	struct repository *r,
+	struct repository *r UNUSED,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
-	const char *pathname,
-	const char *filename,
+	const char *pathname UNUSED,
+	const char *filename UNUSED,
 	struct oidset *omits,
 	void *filter_data_)
 {
@@ -274,8 +274,8 @@ static enum list_objects_filter_result filter_blobs_limit(
 	struct repository *r,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
-	const char *pathname,
-	const char *filename,
+	const char *pathname UNUSED,
+	const char *filename UNUSED,
 	struct oidset *omits,
 	void *filter_data_)
 {
@@ -554,12 +554,12 @@ struct filter_object_type_data {
 };
 
 static enum list_objects_filter_result filter_object_type(
-	struct repository *r,
+	struct repository *r UNUSED,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
-	const char *pathname,
-	const char *filename,
-	struct oidset *omits,
+	const char *pathname UNUSED,
+	const char *filename UNUSED,
+	struct oidset *omits UNUSED,
 	void *filter_data_)
 {
 	struct filter_object_type_data *filter_data = filter_data_;
@@ -675,7 +675,7 @@ static enum list_objects_filter_result filter_combine(
 	struct object *obj,
 	const char *pathname,
 	const char *filename,
-	struct oidset *omits,
+	struct oidset *omits UNUSED,
 	void *filter_data)
 {
 	struct combine_filter_data *d = filter_data;
-- 
2.39.0.546.g5ea984bc66
Previous: Jeff KingNext: Jeff King
Message 9 of 11 in “more -Wunused-parameter fixes/annotations”
  1. 0/9 more -Wunused-parameter fixes/annotationsJeff King, Dec 13, 2022
  2. 1/9 ls-refs: use repository parameter to iterate refsJeff King, Dec 13, 2022
  3. 2/9 blob: drop unused parts of parse_blob_buffer()Jeff King, Dec 13, 2022
  4. 3/9 list-objects: drop process_gitlink() functionJeff King, Dec 13, 2022
  5. 4/9 ws: drop unused parameter from ws_blank_line()Jeff King, Dec 13, 2022
  6. 5/9 xdiff: drop unused parameter in def_ff()Jeff King, Dec 13, 2022
  7. 6/9 xdiff: mark unused parameter in xdl_call_hunk_func()Jeff King, Dec 13, 2022
  8. 7/9 diff: mark unused parameters in callbacksJeff King, Dec 13, 2022
  9. 8/9 list-objects-filter: mark unused parameters in virtual functionsJeff King, Dec 13, 2022
  10. 9/9 userdiff: mark unused parameter in internal callbackJeff King, Dec 13, 2022
  11. Junio C HamanoDec 14, 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.