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

[PATCH 8/8] run-command: mark unused parameters in start_bg_wait callbacks

From
Jeff King <peff@peff.net>
Date
Sep 18, 2023, 22:33 UTC
Message-ID
<20230918223343.GH2659298@coredump.intra.peff.net>
In-Reply-To
<20230918222908.GA2659096@coredump.intra.peff.net>

The start_bg_command() function takes a callback to tell when the background-ed process is "ready". The callback receives the child_process struct as well as an extra void pointer. But curiously, neither of the two users of this interface look at either parameter!

This makes some sense. The only non-test user of the API is fsmonitor, which uses fsmonitor_ipc__get_state() to connect to a single global fsmonitor daemon (i.e., the one we just started!).

So we could just drop these parameters entirely. But it seems like a pretty reasonable interface for the "wait" callback to have access to the details of the spawned process, and to have room for passing extra data through a void pointer. So let's leave these in place but mark the unused ones so that -Wunused-parameter does not complain.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/fsmonitor--daemon.c | 3 ++-
 t/helper/test-simple-ipc.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index ce511c3ed6..5d01db5c02 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -1443,7 +1443,8 @@ static int try_to_run_foreground_daemon(int detach_console MAYBE_UNUSED)
 
 static start_bg_wait_cb bg_wait_cb;
 
-static int bg_wait_cb(const struct child_process *cp, void *cb_data)
+static int bg_wait_cb(const struct child_process *cp UNUSED,
+		      void *cb_data UNUSED)
 {
 	enum ipc_active_state s = fsmonitor_ipc__get_state();
 
diff --git a/t/helper/test-simple-ipc.c b/t/helper/test-simple-ipc.c
index 3d1436da59..941ae7e3bc 100644
--- a/t/helper/test-simple-ipc.c
+++ b/t/helper/test-simple-ipc.c
@@ -278,7 +278,8 @@ static int daemon__run_server(void)
 
 static start_bg_wait_cb bg_wait_cb;
 
-static int bg_wait_cb(const struct child_process *cp, void *cb_data)
+static int bg_wait_cb(const struct child_process *cp UNUSED,
+		      void *cb_data UNUSED)
 {
 	int s = ipc_get_active_state(cl_args.path);
 
-- 
2.42.0.671.g43fbf3903a
Previous: Jeff KingNext: Jeff Hostetler
Message 9 of 11 in “fsmonitor unused parameter cleanups”
  1. 0/8 fsmonitor unused parameter cleanupsJeff King, Sep 18, 2023
  2. 1/8 fsmonitor: prefer repo_git_path() to git_pathdup()Jeff King, Sep 18, 2023
  3. 2/8 fsmonitor/win32: drop unused parametersJeff King, Sep 18, 2023
  4. 3/8 fsmonitor: mark some maybe-unused parametersJeff King, Sep 18, 2023
  5. 4/8 fsmonitor/win32: mark unused parameter in fsm_os__incompatible()Jeff King, Sep 18, 2023
  6. 5/8 fsmonitor: mark unused parameters in stub functionsJeff King, Sep 18, 2023
  7. 6/8 fsmonitor/darwin: mark unused parameters in system callbackJeff King, Sep 18, 2023
  8. 7/8 fsmonitor: mark unused hashmap callback parametersJeff King, Sep 18, 2023
  9. 8/8 run-command: mark unused parameters in start_bg_wait callbacksJeff King, Sep 18, 2023
  10. Jeff HostetlerSep 19, 2023
  11. Junio C HamanoSep 19, 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.