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

[PATCH 3/4] http: mark unused parameter in fill_active_slot() callbacks

From
Jeff King <peff@peff.net>
Date
Mar 17, 2023, 19:17 UTC
Message-ID
<ZBS8tD4KjwQ8aYov@coredump.intra.peff.net>
In-Reply-To
<ZBS77VYL9ZrxKtCN@coredump.intra.peff.net>

We have a generic "fill" function that is used by both the dumb http push and fetch code paths. It takes a void parameter in case the caller wants to pass along extra data, but (since the previous commit) neither does so.

So we could simply drop the extra parameter. But since it's good practice to provide a void pointer for in callback functions, we'll leave it here for the future, and just annotate it as unused (to appease -Wunused-parameter).

While we're marking it, let's also fix the type in http-walker's function to have the correct "void" type. The original had to cast the function pointer and was technically undefined behavior (though generally OK in practice).

Signed-off-by: Jeff King <peff@peff.net>
---
Every time I touch these files I dream of just deleting all of the
dumb-http completely.
 http-push.c   | 2 +-
 http-walker.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/http-push.c b/http-push.c
index 7f71316456c..8eaba6ddf0a 100644
--- a/http-push.c
+++ b/http-push.c
@@ -601,7 +601,7 @@ static void finish_request(struct transfer_request *request)
 }
 
 static int is_running_queue;
-static int fill_active_slot(void *unused)
+static int fill_active_slot(void *data UNUSED)
 {
 	struct transfer_request *request;
 
diff --git a/http-walker.c b/http-walker.c
index 6b9bdb529b5..32369aa2d74 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -126,7 +126,7 @@ static void release_object_request(struct object_request *obj_req)
 	free(obj_req);
 }
 
-static int fill_active_slot(struct walker *walker)
+static int fill_active_slot(void *data UNUSED)
 {
 	struct object_request *obj_req;
 	struct list_head *pos, *tmp, *head = &object_queue_head;
@@ -612,7 +612,7 @@ struct walker *get_http_walker(const char *url)
 	walker->cleanup = cleanup;
 	walker->data = data;
 
-	add_fill_function(walker, (int (*)(void *)) fill_active_slot);
+	add_fill_function(NULL, fill_active_slot);
 
 	return walker;
 }
-- 
2.40.0.581.g8d688c70eca
Previous: Jeff KingNext: Jeff King
Message 6 of 8 in “more unused-parameter fixes”
  1. 0/4 more unused-parameter fixesJeff King, Mar 17, 2023
  2. 1/4 mailmap: drop debugging codeJeff King, Mar 17, 2023
  3. Eric SunshineMar 17, 2023
  4. Jeff KingMar 17, 2023
  5. 2/4 http: drop unused parameter from start_object_request()Jeff King, Mar 17, 2023
  6. 3/4 http: mark unused parameter in fill_active_slot() callbacksJeff King, Mar 17, 2023
  7. 4/4 transport: mark unused parameters in fetch_refs_from_bundle()Jeff King, Mar 17, 2023
  8. Junio C HamanoMar 17, 2023

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.