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

[PATCH 03/14] http: mark unused parameters in curl callbacks

From
Jeff King <peff@peff.net>
Date
Jul 3, 2023, 06:44 UTC
Message-ID
<20230703064405.GC3537614@coredump.intra.peff.net>
In-Reply-To
<20230703064347.GA3524892@coredump.intra.peff.net>

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
Previous: Jeff KingNext: Jeff King
Message 4 of 15 in “more -Wunused-parameter annotations”
  1. 0/14 more -Wunused-parameter annotationsJeff King, Jul 3, 2023
  2. 01/14 test-ref-store: drop unimplemented reflog-expire commandJeff King, Jul 3, 2023
  3. 02/14 do_for_each_ref_helper(): mark unused repository parameterJeff King, Jul 3, 2023
  4. 03/14 http: mark unused parameters in curl callbacksJeff King, Jul 3, 2023
  5. 04/14 http-push: mark unused parameter in xml callbackJeff King, Jul 3, 2023
  6. 05/14 am: mark unused keep_cr parametersJeff King, Jul 3, 2023
  7. 06/14 count-objects: mark unused parameter in alternates callbackJeff King, Jul 3, 2023
  8. 07/14 revisions: drop unused "opt" parameter in "tweak" callbacksJeff King, Jul 3, 2023
  9. 08/14 fsck: mark unused parameters in various fsck callbacksJeff King, Jul 3, 2023
  10. 09/14 merge-tree: mark unused parameter in traverse callbackJeff King, Jul 3, 2023
  11. 10/14 replace: mark unused parameter in ref callbackJeff King, Jul 3, 2023
  12. 11/14 replace: mark unused parameter in each_mergetag_fn callbackJeff King, Jul 3, 2023
  13. 12/14 rev-parse: mark unused parameter in for_each_abbrev callbackJeff King, Jul 3, 2023
  14. 13/14 tag: mark unused parameters in each_tag_name_fn callbacksJeff King, Jul 3, 2023
  15. 14/14 t/helper: mark unused callback void data parametersJeff King, Jul 3, 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.