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

[PATCH 2/3] imap-send: drop unused parameter from imap_cmd_cb callback

From
Jeff King <peff@peff.net>
Date
Jul 3, 2023, 06:34 UTC
Message-ID
<20230703063402.GB3524421@coredump.intra.peff.net>
In-Reply-To
<20230703063247.GA3524302@coredump.intra.peff.net>

There's a generic callback mechanism for handling plus-continuation of IMAP commands. It takes the imap_cmd struct itself as an argument. That seems reasonable, and in a larger imap-using program it might be used. But in imap-send, we have only one such callback (auth_cram_md5) and it doesn't use this value, triggering -Wunused-parameter warnings.

We could just mark the parameter as UNUSED. But since this is the only such function, and because we are not likely to share code with the upstream isync anymore, we can just simplify the interface to remove this parameter.

Signed-off-by: Jeff King <peff@peff.net>
---
 imap-send.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index 0afd88de44..81a87f434b 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -137,7 +137,7 @@ struct imap_store {
 };
 
 struct imap_cmd_cb {
-	int (*cont)(struct imap_store *ctx, struct imap_cmd *cmd, const char *prompt);
+	int (*cont)(struct imap_store *ctx, const char *prompt);
 	void (*done)(struct imap_store *ctx, struct imap_cmd *cmd, int response);
 	void *ctx;
 	char *data;
@@ -786,7 +786,7 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
 				if (n != (int)cmdp->cb.dlen)
 					return RESP_BAD;
 			} else if (cmdp->cb.cont) {
-				if (cmdp->cb.cont(ctx, cmdp, cmd))
+				if (cmdp->cb.cont(ctx, cmd))
 					return RESP_BAD;
 			} else {
 				fprintf(stderr, "IMAP error: unexpected command continuation request\n");
@@ -917,7 +917,7 @@ static char *cram(const char *challenge_64, const char *user, const char *pass)
 
 #endif
 
-static int auth_cram_md5(struct imap_store *ctx, struct imap_cmd *cmd, const char *prompt)
+static int auth_cram_md5(struct imap_store *ctx, const char *prompt)
 {
 	int ret;
 	char *response;
-- 
2.41.0.586.g3c0cc15bc7
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 7 in “imap-send: some -Wunused-parameter cleanups”
  1. 0/3 imap-send: some -Wunused-parameter cleanupsJeff King, Jul 3, 2023
  2. 1/3 imap-send: use server conf argument in setup_curl()Jeff King, Jul 3, 2023
  3. Junio C HamanoJul 5, 2023
  4. 2/3 imap-send: drop unused parameter from imap_cmd_cb callbackJeff King, Jul 3, 2023
  5. Junio C HamanoJul 5, 2023
  6. 3/3 imap-send: drop unused fields from imap_cmd_cbJeff King, Jul 3, 2023
  7. Junio C HamanoJul 5, 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.