{"thread":{"id":"60242","subject":"[PATCH 0/8] fsmonitor unused parameter cleanups","startedAt":"2023-09-18T22:29:12Z","lastAt":"2023-09-19T18:09:11Z","messageCount":11,"participants":["Jeff King","Jeff Hostetler","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"481986","messageId":"20230918222908.GA2659096@coredump.intra.peff.net","threadId":"60242","inReplyTo":null,"subject":"[PATCH 0/8] fsmonitor unused parameter cleanups","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:29:08Z","receivedAt":"2023-09-18T22:29:12Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Here are a few cleanups of the fsmonitor code to remove or annotate\nunused parameters (working towards my goal of making us compile clean\nwith -Wunused-parameter). I think they should all be pretty\nnon-controversial, but I'm cc-ing folks active in the area in case patch\n2 steps on the toes of any unpublished works in progress.\n\n  [1/8]: fsmonitor: prefer repo_git_path() to git_pathdup()\n  [2/8]: fsmonitor/win32: drop unused parameters\n  [3/8]: fsmonitor: mark some maybe-unused parameters\n  [4/8]: fsmonitor/win32: mark unused parameter in fsm_os__incompatible()\n  [5/8]: fsmonitor: mark unused parameters in stub functions\n  [6/8]: fsmonitor/darwin: mark unused parameters in system callback\n  [7/8]: fsmonitor: mark unused hashmap callback parameters\n  [8/8]: run-command: mark unused parameters in start_bg_wait callbacks\n\n builtin/fsmonitor--daemon.c             | 10 ++++++----\n compat/fsmonitor/fsm-health-darwin.c    |  8 ++++----\n compat/fsmonitor/fsm-ipc-win32.c        |  2 +-\n compat/fsmonitor/fsm-listen-darwin.c    |  4 ++--\n compat/fsmonitor/fsm-listen-win32.c     | 24 ++++++++++--------------\n compat/fsmonitor/fsm-path-utils-win32.c |  7 ++++---\n compat/fsmonitor/fsm-settings-win32.c   |  2 +-\n fsmonitor-ipc.c                         | 10 +++++-----\n fsmonitor-settings.c                    |  3 ++-\n t/helper/test-simple-ipc.c              |  3 ++-\n 10 files changed, 37 insertions(+), 36 deletions(-)\n\n-Peff\n"},{"id":"481987","messageId":"20230918222940.GA2659298@coredump.intra.peff.net","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"[PATCH 1/8] fsmonitor: prefer repo_git_path() to git_pathdup()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:29:40Z","receivedAt":"2023-09-18T22:29:43Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The fsmonitor_ipc__get_path() function ignores its repository argument.\nIt should use it when constructing repo paths (though in practice, it is\nunlikely anything but the_repository is ever passed, so this is cleanup\nand future proofing, not a bug fix).\n\nNote that despite the lack of \"dup\" in the name, repo_git_path() behaves\nlike git_pathdup() and returns an allocated string.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n compat/fsmonitor/fsm-ipc-win32.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c\nindex 8928fa93ce..41984ea48e 100644\n--- a/compat/fsmonitor/fsm-ipc-win32.c\n+++ b/compat/fsmonitor/fsm-ipc-win32.c\n@@ -6,6 +6,6 @@\n const char *fsmonitor_ipc__get_path(struct repository *r) {\n \tstatic char *ret;\n \tif (!ret)\n-\t\tret = git_pathdup(\"fsmonitor--daemon.ipc\");\n+\t\tret = repo_git_path(r, \"fsmonitor--daemon.ipc\");\n \treturn ret;\n }\n-- \n2.42.0.671.g43fbf3903a\n\n"},{"id":"481988","messageId":"20230918223001.GB2659298@coredump.intra.peff.net","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"[PATCH 2/8] fsmonitor/win32: drop unused parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:30:01Z","receivedAt":"2023-09-18T22:30:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"A few helper functions (centered around file-watch events) take extra\nfsmonitor state parameters that they don't use. These are static helpers\nlocal to the win32 implementation, and don't need to conform to any\nparticular interface. We can just drop the extra parameters, which\nsimplifies the code and silences -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n compat/fsmonitor/fsm-listen-win32.c | 24 ++++++++++--------------\n 1 file changed, 10 insertions(+), 14 deletions(-)\n\ndiff --git a/compat/fsmonitor/fsm-listen-win32.c b/compat/fsmonitor/fsm-listen-win32.c\nindex a361a7db20..90a2412284 100644\n--- a/compat/fsmonitor/fsm-listen-win32.c\n+++ b/compat/fsmonitor/fsm-listen-win32.c\n@@ -289,8 +289,7 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)\n \tSetEvent(state->listen_data->hListener[LISTENER_SHUTDOWN]);\n }\n \n-static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,\n-\t\t\t\t      const char *path)\n+static struct one_watch *create_watch(const char *path)\n {\n \tstruct one_watch *watch = NULL;\n \tDWORD desired_access = FILE_LIST_DIRECTORY;\n@@ -361,8 +360,7 @@ static void destroy_watch(struct one_watch *watch)\n \tfree(watch);\n }\n \n-static int start_rdcw_watch(struct fsm_listen_data *data,\n-\t\t\t    struct one_watch *watch)\n+static int start_rdcw_watch(struct one_watch *watch)\n {\n \tDWORD dwNotifyFilter =\n \t\tFILE_NOTIFY_CHANGE_FILE_NAME |\n@@ -735,11 +733,11 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)\n \n \tstate->listen_error_code = 0;\n \n-\tif (start_rdcw_watch(data, data->watch_worktree) == -1)\n+\tif (start_rdcw_watch(data->watch_worktree) == -1)\n \t\tgoto force_error_stop;\n \n \tif (data->watch_gitdir &&\n-\t    start_rdcw_watch(data, data->watch_gitdir) == -1)\n+\t    start_rdcw_watch(data->watch_gitdir) == -1)\n \t\tgoto force_error_stop;\n \n \tfor (;;) {\n@@ -755,15 +753,15 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)\n \t\t\t}\n \t\t\tif (result == -2) {\n \t\t\t\t/* retryable error */\n-\t\t\t\tif (start_rdcw_watch(data, data->watch_worktree) == -1)\n+\t\t\t\tif (start_rdcw_watch(data->watch_worktree) == -1)\n \t\t\t\t\tgoto force_error_stop;\n \t\t\t\tcontinue;\n \t\t\t}\n \n \t\t\t/* have data */\n \t\t\tif (process_worktree_events(state) == LISTENER_SHUTDOWN)\n \t\t\t\tgoto force_shutdown;\n-\t\t\tif (start_rdcw_watch(data, data->watch_worktree) == -1)\n+\t\t\tif (start_rdcw_watch(data->watch_worktree) == -1)\n \t\t\t\tgoto force_error_stop;\n \t\t\tcontinue;\n \t\t}\n@@ -776,15 +774,15 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)\n \t\t\t}\n \t\t\tif (result == -2) {\n \t\t\t\t/* retryable error */\n-\t\t\t\tif (start_rdcw_watch(data, data->watch_gitdir) == -1)\n+\t\t\t\tif (start_rdcw_watch(data->watch_gitdir) == -1)\n \t\t\t\t\tgoto force_error_stop;\n \t\t\t\tcontinue;\n \t\t\t}\n \n \t\t\t/* have data */\n \t\t\tif (process_gitdir_events(state) == LISTENER_SHUTDOWN)\n \t\t\t\tgoto force_shutdown;\n-\t\t\tif (start_rdcw_watch(data, data->watch_gitdir) == -1)\n+\t\t\tif (start_rdcw_watch(data->watch_gitdir) == -1)\n \t\t\t\tgoto force_error_stop;\n \t\t\tcontinue;\n \t\t}\n@@ -821,16 +819,14 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)\n \n \tdata->hEventShutdown = CreateEvent(NULL, TRUE, FALSE, NULL);\n \n-\tdata->watch_worktree = create_watch(state,\n-\t\t\t\t\t    state->path_worktree_watch.buf);\n+\tdata->watch_worktree = create_watch(state->path_worktree_watch.buf);\n \tif (!data->watch_worktree)\n \t\tgoto failed;\n \n \tcheck_for_shortnames(data->watch_worktree);\n \n \tif (state->nr_paths_watching > 1) {\n-\t\tdata->watch_gitdir = create_watch(state,\n-\t\t\t\t\t\t  state->path_gitdir_watch.buf);\n+\t\tdata->watch_gitdir = create_watch(state->path_gitdir_watch.buf);\n \t\tif (!data->watch_gitdir)\n \t\t\tgoto failed;\n \t}\n-- \n2.42.0.671.g43fbf3903a\n\n"},{"id":"481989","messageId":"20230918223148.GC2659298@coredump.intra.peff.net","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"[PATCH 3/8] fsmonitor: mark some maybe-unused parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:31:48Z","receivedAt":"2023-09-18T22:31:52Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"There's a bit of conditionally-compiled code in fsmonitor, so some\nfunction parameters may be unused depending on the build options:\n\n  - in fsmonitor--daemon.c's try_to_run_foreground_daemon(), we take a\n    detach_console argument, but it's only used on Windows. This seems\n    intentional (and not mistakenly missing other platforms) based on\n    the discussion in c284e27ba7 (fsmonitor--daemon: implement 'start'\n    command, 2022-03-25), which introduced it.\n\n  - in fsmonitor-setting.c's check_for_incompatible(), we pass the \"ipc\"\n    flag down to the system-specific fsm_os__incompatible() helper. But\n    we can only do so if our platform has such a helper.\n\nIn both cases we can mark the argument as MAYBE_UNUSED. That annotates\nit enough to suppress the compiler's -Wunused-parameter warning, but\nwithout making it impossible to use the variable, as a regular UNUSED\nannotation would.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nFor a similar case in 2c3c3d88fc (imap-send: mark unused parameters with\nNO_OPENSSL, 2023-08-29), I used the old:\n\n  (void)some_parameter_that_might_not_be_used;\n\ntrick. But I realized while writing this one that MAYBE_UNUSED fits the\nbill a little more nicely, and I don't see any reason we would have\nportability problems with it.\n\n builtin/fsmonitor--daemon.c | 2 +-\n fsmonitor-settings.c        | 3 ++-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c\nindex 7e99c4d61b..7c4130c981 100644\n--- a/builtin/fsmonitor--daemon.c\n+++ b/builtin/fsmonitor--daemon.c\n@@ -1412,7 +1412,7 @@ static int fsmonitor_run_daemon(void)\n \treturn err;\n }\n \n-static int try_to_run_foreground_daemon(int detach_console)\n+static int try_to_run_foreground_daemon(int detach_console MAYBE_UNUSED)\n {\n \t/*\n \t * Technically, we don't need to probe for an existing daemon\ndiff --git a/fsmonitor-settings.c b/fsmonitor-settings.c\nindex b62acf44ae..a6a9e6bc19 100644\n--- a/fsmonitor-settings.c\n+++ b/fsmonitor-settings.c\n@@ -62,7 +62,8 @@ static enum fsmonitor_reason check_remote(struct repository *r)\n }\n #endif\n \n-static enum fsmonitor_reason check_for_incompatible(struct repository *r, int ipc)\n+static enum fsmonitor_reason check_for_incompatible(struct repository *r,\n+\t\t\t\t\t\t    int ipc MAYBE_UNUSED)\n {\n \tif (!r->worktree) {\n \t\t/*\n-- \n2.42.0.671.g43fbf3903a\n\n"},{"id":"481990","messageId":"20230918223205.GD2659298@coredump.intra.peff.net","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"[PATCH 4/8] fsmonitor/win32: mark unused parameter in fsm_os__incompatible()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:32:05Z","receivedAt":"2023-09-18T22:32:09Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We never look at the \"ipc\" argument we receive. It was added in\n8f44976882 (fsmonitor: avoid socket location check if using hook,\n2022-10-04) to support the darwin fsmonitor code. The win32 code has to\nmatch the same interface, but we should use an annotation to silence\n-Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n compat/fsmonitor/fsm-settings-win32.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/fsmonitor/fsm-settings-win32.c b/compat/fsmonitor/fsm-settings-win32.c\nindex b6f6744494..0f2aa321f6 100644\n--- a/compat/fsmonitor/fsm-settings-win32.c\n+++ b/compat/fsmonitor/fsm-settings-win32.c\n@@ -25,7 +25,7 @@ static enum fsmonitor_reason check_vfs4git(struct repository *r)\n \treturn FSMONITOR_REASON_OK;\n }\n \n-enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc)\n+enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc UNUSED)\n {\n \tenum fsmonitor_reason reason;\n \n-- \n2.42.0.671.g43fbf3903a\n\n"},{"id":"481991","messageId":"20230918223238.GE2659298@coredump.intra.peff.net","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"[PATCH 5/8] fsmonitor: mark unused parameters in stub functions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:32:38Z","receivedAt":"2023-09-18T22:32:42Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The fsmonitor code has some platform-specific functions for which one or\nmore platforms implement noop or stub functions. We can't get rid of\nthese functions nor change their interface, since the point is to match\ntheir equivalents in other platforms. But let's annotate their\nparameters to quiet the compiler's -Wunused-parameter warning.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n compat/fsmonitor/fsm-health-darwin.c    |  8 ++++----\n compat/fsmonitor/fsm-path-utils-win32.c |  7 ++++---\n fsmonitor-ipc.c                         | 10 +++++-----\n 3 files changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/compat/fsmonitor/fsm-health-darwin.c b/compat/fsmonitor/fsm-health-darwin.c\nindex 5b1709d63f..c2afcbe6c8 100644\n--- a/compat/fsmonitor/fsm-health-darwin.c\n+++ b/compat/fsmonitor/fsm-health-darwin.c\n@@ -4,21 +4,21 @@\n #include \"fsm-health.h\"\n #include \"fsmonitor--daemon.h\"\n \n-int fsm_health__ctor(struct fsmonitor_daemon_state *state)\n+int fsm_health__ctor(struct fsmonitor_daemon_state *state UNUSED)\n {\n \treturn 0;\n }\n \n-void fsm_health__dtor(struct fsmonitor_daemon_state *state)\n+void fsm_health__dtor(struct fsmonitor_daemon_state *state UNUSED)\n {\n \treturn;\n }\n \n-void fsm_health__loop(struct fsmonitor_daemon_state *state)\n+void fsm_health__loop(struct fsmonitor_daemon_state *state UNUSED)\n {\n \treturn;\n }\n \n-void fsm_health__stop_async(struct fsmonitor_daemon_state *state)\n+void fsm_health__stop_async(struct fsmonitor_daemon_state *state UNUSED)\n {\n }\ndiff --git a/compat/fsmonitor/fsm-path-utils-win32.c b/compat/fsmonitor/fsm-path-utils-win32.c\nindex c8a3e9dcdb..f4f9cc1f33 100644\n--- a/compat/fsmonitor/fsm-path-utils-win32.c\n+++ b/compat/fsmonitor/fsm-path-utils-win32.c\n@@ -132,16 +132,17 @@ int fsmonitor__is_fs_remote(const char *path)\n /*\n  * No-op for now.\n  */\n-int fsmonitor__get_alias(const char *path, struct alias_info *info)\n+int fsmonitor__get_alias(const char *path UNUSED,\n+\t\t\t struct alias_info *info UNUSED)\n {\n \treturn 0;\n }\n \n /*\n  * No-op for now.\n  */\n-char *fsmonitor__resolve_alias(const char *path,\n-\tconst struct alias_info *info)\n+char *fsmonitor__resolve_alias(const char *path UNUSED,\n+\t\t\t       const struct alias_info *info UNUSED)\n {\n \treturn NULL;\n }\ndiff --git a/fsmonitor-ipc.c b/fsmonitor-ipc.c\nindex 88575aa54c..153918cf76 100644\n--- a/fsmonitor-ipc.c\n+++ b/fsmonitor-ipc.c\n@@ -20,7 +20,7 @@ int fsmonitor_ipc__is_supported(void)\n \treturn 0;\n }\n \n-const char *fsmonitor_ipc__get_path(struct repository *r)\n+const char *fsmonitor_ipc__get_path(struct repository *r UNUSED)\n {\n \treturn NULL;\n }\n@@ -30,14 +30,14 @@ enum ipc_active_state fsmonitor_ipc__get_state(void)\n \treturn IPC_STATE__OTHER_ERROR;\n }\n \n-int fsmonitor_ipc__send_query(const char *since_token,\n-\t\t\t      struct strbuf *answer)\n+int fsmonitor_ipc__send_query(const char *since_token UNUSED,\n+\t\t\t      struct strbuf *answer UNUSED)\n {\n \treturn -1;\n }\n \n-int fsmonitor_ipc__send_command(const char *command,\n-\t\t\t\tstruct strbuf *answer)\n+int fsmonitor_ipc__send_command(const char *command UNUSED,\n+\t\t\t\tstruct strbuf *answer UNUSED)\n {\n \treturn -1;\n }\n-- \n2.42.0.671.g43fbf3903a\n\n"},{"id":"481992","messageId":"20230918223256.GF2659298@coredump.intra.peff.net","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"[PATCH 6/8] fsmonitor/darwin: mark unused parameters in system callback","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:32:56Z","receivedAt":"2023-09-18T22:32:59Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We pass fsevent_callback() to the system FSEventStreamCreate() function\nas a callback. So we must match the expected function signature, even\nthough we don't care about all of the parameters. Mark the unused ones\nto satisfy -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n compat/fsmonitor/fsm-listen-darwin.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c\nindex 36c7e13281..11b56d3ef1 100644\n--- a/compat/fsmonitor/fsm-listen-darwin.c\n+++ b/compat/fsmonitor/fsm-listen-darwin.c\n@@ -191,12 +191,12 @@ static void my_add_path(struct fsmonitor_batch *batch, const char *path)\n }\n \n \n-static void fsevent_callback(ConstFSEventStreamRef streamRef,\n+static void fsevent_callback(ConstFSEventStreamRef streamRef UNUSED,\n \t\t\t     void *ctx,\n \t\t\t     size_t num_of_events,\n \t\t\t     void *event_paths,\n \t\t\t     const FSEventStreamEventFlags event_flags[],\n-\t\t\t     const FSEventStreamEventId event_ids[])\n+\t\t\t     const FSEventStreamEventId event_ids[] UNUSED)\n {\n \tstruct fsmonitor_daemon_state *state = ctx;\n \tstruct fsm_listen_data *data = state->listen_data;\n-- \n2.42.0.671.g43fbf3903a\n\n"},{"id":"481993","messageId":"20230918223314.GG2659298@coredump.intra.peff.net","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"[PATCH 7/8] fsmonitor: mark unused hashmap callback parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:33:14Z","receivedAt":"2023-09-18T22:33:19Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Like many hashmap comparison functions, our cookies_cmp() does not look\nat its extra void data parameter. This should have been annotated in\n02c3c59e62 (hashmap: mark unused callback parameters, 2022-08-19), but\nthis new case was added around the same time (plus fsmonitor is not\nbuilt at all on Linux, so it is easy to miss there).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/fsmonitor--daemon.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c\nindex 7c4130c981..ce511c3ed6 100644\n--- a/builtin/fsmonitor--daemon.c\n+++ b/builtin/fsmonitor--daemon.c\n@@ -129,8 +129,9 @@ struct fsmonitor_cookie_item {\n \tenum fsmonitor_cookie_item_result result;\n };\n \n-static int cookies_cmp(const void *data, const struct hashmap_entry *he1,\n-\t\t     const struct hashmap_entry *he2, const void *keydata)\n+static int cookies_cmp(const void *data UNUSED,\n+\t\t       const struct hashmap_entry *he1,\n+\t\t       const struct hashmap_entry *he2, const void *keydata)\n {\n \tconst struct fsmonitor_cookie_item *a =\n \t\tcontainer_of(he1, const struct fsmonitor_cookie_item, entry);\n-- \n2.42.0.671.g43fbf3903a\n\n"},{"id":"481994","messageId":"20230918223343.GH2659298@coredump.intra.peff.net","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"[PATCH 8/8] run-command: mark unused parameters in start_bg_wait callbacks","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-09-18T22:33:43Z","receivedAt":"2023-09-18T22:33:46Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The start_bg_command() function takes a callback to tell when the\nbackground-ed process is \"ready\". The callback receives the\nchild_process struct as well as an extra void pointer. But curiously,\nneither of the two users of this interface look at either parameter!\n\nThis makes some sense. The only non-test user of the API is fsmonitor,\nwhich uses fsmonitor_ipc__get_state() to connect to a single global\nfsmonitor daemon (i.e., the one we just started!).\n\nSo we could just drop these parameters entirely. But it seems like a\npretty reasonable interface for the \"wait\" callback to have access to\nthe details of the spawned process, and to have room for passing extra\ndata through a void pointer. So let's leave these in place but mark the\nunused ones so that -Wunused-parameter does not complain.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/fsmonitor--daemon.c | 3 ++-\n t/helper/test-simple-ipc.c  | 3 ++-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c\nindex ce511c3ed6..5d01db5c02 100644\n--- a/builtin/fsmonitor--daemon.c\n+++ b/builtin/fsmonitor--daemon.c\n@@ -1443,7 +1443,8 @@ static int try_to_run_foreground_daemon(int detach_console MAYBE_UNUSED)\n \n static start_bg_wait_cb bg_wait_cb;\n \n-static int bg_wait_cb(const struct child_process *cp, void *cb_data)\n+static int bg_wait_cb(const struct child_process *cp UNUSED,\n+\t\t      void *cb_data UNUSED)\n {\n \tenum ipc_active_state s = fsmonitor_ipc__get_state();\n \ndiff --git a/t/helper/test-simple-ipc.c b/t/helper/test-simple-ipc.c\nindex 3d1436da59..941ae7e3bc 100644\n--- a/t/helper/test-simple-ipc.c\n+++ b/t/helper/test-simple-ipc.c\n@@ -278,7 +278,8 @@ static int daemon__run_server(void)\n \n static start_bg_wait_cb bg_wait_cb;\n \n-static int bg_wait_cb(const struct child_process *cp, void *cb_data)\n+static int bg_wait_cb(const struct child_process *cp UNUSED,\n+\t\t      void *cb_data UNUSED)\n {\n \tint s = ipc_get_active_state(cl_args.path);\n \n-- \n2.42.0.671.g43fbf3903a\n"},{"id":"482012","messageId":"7356bb25-12aa-dc6a-9b32-87d13c49994c@jeffhostetler.com","threadId":"60242","inReplyTo":"20230918222908.GA2659096@coredump.intra.peff.net","subject":"Re: [PATCH 0/8] fsmonitor unused parameter cleanups","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2023-09-19T13:34:07Z","receivedAt":"2023-09-19T13:34:12Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 9/18/23 6:29 PM, Jeff King wrote:\n> Here are a few cleanups of the fsmonitor code to remove or annotate\n> unused parameters (working towards my goal of making us compile clean\n> with -Wunused-parameter). I think they should all be pretty\n> non-controversial, but I'm cc-ing folks active in the area in case patch\n> 2 steps on the toes of any unpublished works in progress.\n> \n>    [1/8]: fsmonitor: prefer repo_git_path() to git_pathdup()\n>    [2/8]: fsmonitor/win32: drop unused parameters\n>    [3/8]: fsmonitor: mark some maybe-unused parameters\n>    [4/8]: fsmonitor/win32: mark unused parameter in fsm_os__incompatible()\n>    [5/8]: fsmonitor: mark unused parameters in stub functions\n>    [6/8]: fsmonitor/darwin: mark unused parameters in system callback\n>    [7/8]: fsmonitor: mark unused hashmap callback parameters\n>    [8/8]: run-command: mark unused parameters in start_bg_wait callbacks\n> \n>   builtin/fsmonitor--daemon.c             | 10 ++++++----\n>   compat/fsmonitor/fsm-health-darwin.c    |  8 ++++----\n>   compat/fsmonitor/fsm-ipc-win32.c        |  2 +-\n>   compat/fsmonitor/fsm-listen-darwin.c    |  4 ++--\n>   compat/fsmonitor/fsm-listen-win32.c     | 24 ++++++++++--------------\n>   compat/fsmonitor/fsm-path-utils-win32.c |  7 ++++---\n>   compat/fsmonitor/fsm-settings-win32.c   |  2 +-\n>   fsmonitor-ipc.c                         | 10 +++++-----\n>   fsmonitor-settings.c                    |  3 ++-\n>   t/helper/test-simple-ipc.c              |  3 ++-\n>   10 files changed, 37 insertions(+), 36 deletions(-)\n> \n> -Peff\n\nLGTM\n\nThanks,\nJeff\n"},{"id":"482023","messageId":"xmqqttrqf329.fsf@gitster.g","threadId":"60242","inReplyTo":"7356bb25-12aa-dc6a-9b32-87d13c49994c@jeffhostetler.com","subject":"Re: [PATCH 0/8] fsmonitor unused parameter cleanups","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-09-19T18:09:02Z","receivedAt":"2023-09-19T18:09:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Hostetler <git@jeffhostetler.com> writes:\n\n> On 9/18/23 6:29 PM, Jeff King wrote:\n>> Here are a few cleanups of the fsmonitor code to remove or annotate\n>> unused parameters (working towards my goal of making us compile clean\n> ...\n> LGTM\n>\n> Thanks,\n> Jeff\n\nThanks, both.  Let's merge it down.\n\n"}]}