Skip to content

Commit

Permalink
run-command: mark unused parameters in start_bg_wait callbacks
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Sep 18, 2023
1 parent 1fe4194 commit 72da983
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion builtin/fsmonitor--daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 2 additions & 1 deletion t/helper/test-simple-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 72da983

Please sign in to comment.