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

[PATCH v2 16/22] imap-send: mark unused parameters with NO_OPENSSL

From
Jeff King <peff@peff.net>
Date
Aug 29, 2023, 23:45 UTC
Message-ID
<20230829234533.GN227214@coredump.intra.peff.net>
In-Reply-To
<20230829234305.GA226944@coredump.intra.peff.net>

Earlier patches annotating unused parameters in imap-send missed a few cases in code that is compiled only with NO_OPENSSL. These need to retain the extra parameters to match the interfaces used when we compile with openssl support.

Note in the case of socket_perror() that the function declaration and parts of its code are shared between the two cases, and only the openssl code looks at "sock". So we can't simply mark the parameter as always unused. Instead, we can add a noop statement that references it. This is ugly, but should be portable.

Signed-off-by: Jeff King <peff@peff.net>
---
 imap-send.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index 06386e0b3b..996651e4f8 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -206,10 +206,14 @@ static void socket_perror(const char *func, struct imap_socket *sock, int ret)
 		else
 			fprintf(stderr, "%s: unexpected EOF\n", func);
 	}
+	/* mark as used to appease -Wunused-parameter with NO_OPENSSL */
+	(void)sock;
 }
 
 #ifdef NO_OPENSSL
-static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int verify)
+static int ssl_socket_connect(struct imap_socket *sock UNUSED,
+			      int use_tls_only UNUSED,
+			      int verify UNUSED)
 {
 	fprintf(stderr, "SSL requested but SSL support not compiled in\n");
 	return -1;
@@ -904,7 +908,9 @@ static char *cram(const char *challenge_64, const char *user, const char *pass)
 
 #else
 
-static char *cram(const char *challenge_64, const char *user, const char *pass)
+static char *cram(const char *challenge_64 UNUSED,
+		  const char *user UNUSED,
+		  const char *pass UNUSED)
 {
 	die("If you want to use CRAM-MD5 authenticate method, "
 	    "you have to build git-imap-send with OpenSSL library.");
-- 
2.42.0.528.g7950723a09
Previous: Jeff KingNext: Jeff King
Message 52 of 59 in “YAUPS: Yet Another Unused Parameter Series”
  1. 0/22 YAUPS: Yet Another Unused Parameter SeriesJeff King, Aug 28, 2023
  2. 01/22 sequencer: use repository parameter in short_commit_name()Jeff King, Aug 28, 2023
  3. Junio C HamanoAug 28, 2023
  4. Taylor BlauAug 28, 2023
  5. Jeff KingAug 29, 2023
  6. Junio C HamanoAug 29, 2023
  7. 02/22 sequencer: mark repository argument as unusedJeff King, Aug 28, 2023
  8. Taylor BlauAug 28, 2023
  9. Phillip WoodAug 29, 2023
  10. Jeff KingAug 29, 2023
  11. Phillip WoodAug 30, 2023
  12. 04/22 pack-bitmap: mark unused parameters in show_object callbackJeff King, Aug 28, 2023
  13. 03/22 ref-filter: mark unused parameters in parser callbacksJeff King, Aug 28, 2023
  14. 08/22 stash: mark unused parameter in diff callbackJeff King, Aug 28, 2023
  15. 05/22 worktree: mark unused parameters in each_ref_fn callbackJeff King, Aug 28, 2023
  16. 06/22 commit-graph: mark unused data parameters in generation callbacksJeff King, Aug 28, 2023
  17. Taylor BlauAug 28, 2023
  18. Jeff KingAug 29, 2023
  19. 07/22 ls-tree: mark unused parameter in callbackJeff King, Aug 28, 2023
  20. 09/22 trace2: mark unused us_elapsed_absolute parametersJeff King, Aug 28, 2023
  21. 11/22 test-trace2: mark unused argv/argc parametersJeff King, Aug 28, 2023
  22. 12/22 grep: mark unused parameter in output functionJeff King, Aug 28, 2023
  23. 14/22 negotiator/noop: mark unused callback parametersJeff King, Aug 28, 2023
  24. 10/22 trace2: mark unused config callback parameterJeff King, Aug 28, 2023
  25. 13/22 add-interactive: mark unused callback parametersJeff King, Aug 28, 2023
  26. 15/22 worktree: mark unused parameters in noop repair callbackJeff King, Aug 28, 2023
  27. 16/22 imap-send: mark unused parameters with NO_OPENSSLJeff King, Aug 28, 2023
  28. 17/22 grep: mark unused parmaeters in pcre fallbacksJeff King, Aug 28, 2023
  29. 18/22 credential: mark unused parameter in urlmatch callbackJeff King, Aug 28, 2023
  30. 19/22 fetch: mark unused parameter in ref_transaction callbackJeff King, Aug 28, 2023
  31. 20/22 bundle-uri: mark unused parameters in callbacksJeff King, Aug 28, 2023
  32. 22/22 update-ref: mark unused parameter in parser callbacksJeff King, Aug 28, 2023
  33. 21/22 gc: mark unused descriptors in scheduler callbacksJeff King, Aug 28, 2023
  34. Taylor BlauAug 28, 2023
  35. 0/22 Yet Another Unused Parameter SeriesJeff King, Aug 29, 2023
  36. 01/22 sequencer: use repository parameter in short_commit_name()Jeff King, Aug 29, 2023
  37. Phillip WoodAug 30, 2023
  38. 02/22 sequencer: mark repository argument as unusedJeff King, Aug 29, 2023
  39. 03/22 ref-filter: mark unused parameters in parser callbacksJeff King, Aug 29, 2023
  40. 04/22 pack-bitmap: mark unused parameters in show_object callbackJeff King, Aug 29, 2023
  41. 06/22 commit-graph: mark unused data parameters in generation callbacksJeff King, Aug 29, 2023
  42. 07/22 ls-tree: mark unused parameter in callbackJeff King, Aug 29, 2023
  43. 05/22 worktree: mark unused parameters in each_ref_fn callbackJeff King, Aug 29, 2023
  44. 08/22 stash: mark unused parameter in diff callbackJeff King, Aug 29, 2023
  45. 10/22 trace2: mark unused config callback parameterJeff King, Aug 29, 2023
  46. 09/22 trace2: mark unused us_elapsed_absolute parametersJeff King, Aug 29, 2023
  47. 11/22 test-trace2: mark unused argv/argc parametersJeff King, Aug 29, 2023
  48. 12/22 grep: mark unused parameter in output functionJeff King, Aug 29, 2023
  49. 13/22 add-interactive: mark unused callback parametersJeff King, Aug 29, 2023
  50. 14/22 negotiator/noop: mark unused callback parametersJeff King, Aug 29, 2023
  51. 15/22 worktree: mark unused parameters in noop repair callbackJeff King, Aug 29, 2023
  52. 16/22 imap-send: mark unused parameters with NO_OPENSSLJeff King, Aug 29, 2023
  53. 17/22 grep: mark unused parmaeters in pcre fallbacksJeff King, Aug 29, 2023
  54. 19/22 fetch: mark unused parameter in ref_transaction callbackJeff King, Aug 29, 2023
  55. 18/22 credential: mark unused parameter in urlmatch callbackJeff King, Aug 29, 2023
  56. 21/22 gc: mark unused descriptors in scheduler callbacksJeff King, Aug 29, 2023
  57. 20/22 bundle-uri: mark unused parameters in callbacksJeff King, Aug 29, 2023
  58. 22/22 update-ref: mark unused parameter in parser callbacksJeff King, Aug 29, 2023
  59. Junio C HamanoAug 30, 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.