Skip to content

Commit

Permalink
Merge branch 'jk/fsmonitor-unused-parameter' into next
Browse files Browse the repository at this point in the history
Unused parameters in fsmonitor related code paths have been marked
as such.

* jk/fsmonitor-unused-parameter:
  run-command: mark unused parameters in start_bg_wait callbacks
  fsmonitor: mark unused hashmap callback parameters
  fsmonitor/darwin: mark unused parameters in system callback
  fsmonitor: mark unused parameters in stub functions
  fsmonitor/win32: mark unused parameter in fsm_os__incompatible()
  fsmonitor: mark some maybe-unused parameters
  fsmonitor/win32: drop unused parameters
  fsmonitor: prefer repo_git_path() to git_pathdup()
  • Loading branch information
gitster committed Sep 19, 2023
2 parents 0565b0b + 72da983 commit bd06505
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 36 deletions.
10 changes: 6 additions & 4 deletions builtin/fsmonitor--daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ struct fsmonitor_cookie_item {
enum fsmonitor_cookie_item_result result;
};

static int cookies_cmp(const void *data, const struct hashmap_entry *he1,
const struct hashmap_entry *he2, const void *keydata)
static int cookies_cmp(const void *data UNUSED,
const struct hashmap_entry *he1,
const struct hashmap_entry *he2, const void *keydata)
{
const struct fsmonitor_cookie_item *a =
container_of(he1, const struct fsmonitor_cookie_item, entry);
Expand Down Expand Up @@ -1412,7 +1413,7 @@ static int fsmonitor_run_daemon(void)
return err;
}

static int try_to_run_foreground_daemon(int detach_console)
static int try_to_run_foreground_daemon(int detach_console MAYBE_UNUSED)
{
/*
* Technically, we don't need to probe for an existing daemon
Expand Down Expand Up @@ -1442,7 +1443,8 @@ static int try_to_run_foreground_daemon(int detach_console)

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
8 changes: 4 additions & 4 deletions compat/fsmonitor/fsm-health-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
#include "fsm-health.h"
#include "fsmonitor--daemon.h"

int fsm_health__ctor(struct fsmonitor_daemon_state *state)
int fsm_health__ctor(struct fsmonitor_daemon_state *state UNUSED)
{
return 0;
}

void fsm_health__dtor(struct fsmonitor_daemon_state *state)
void fsm_health__dtor(struct fsmonitor_daemon_state *state UNUSED)
{
return;
}

void fsm_health__loop(struct fsmonitor_daemon_state *state)
void fsm_health__loop(struct fsmonitor_daemon_state *state UNUSED)
{
return;
}

void fsm_health__stop_async(struct fsmonitor_daemon_state *state)
void fsm_health__stop_async(struct fsmonitor_daemon_state *state UNUSED)
{
}
2 changes: 1 addition & 1 deletion compat/fsmonitor/fsm-ipc-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
const char *fsmonitor_ipc__get_path(struct repository *r) {
static char *ret;
if (!ret)
ret = git_pathdup("fsmonitor--daemon.ipc");
ret = repo_git_path(r, "fsmonitor--daemon.ipc");
return ret;
}
4 changes: 2 additions & 2 deletions compat/fsmonitor/fsm-listen-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ static void my_add_path(struct fsmonitor_batch *batch, const char *path)
}


static void fsevent_callback(ConstFSEventStreamRef streamRef,
static void fsevent_callback(ConstFSEventStreamRef streamRef UNUSED,
void *ctx,
size_t num_of_events,
void *event_paths,
const FSEventStreamEventFlags event_flags[],
const FSEventStreamEventId event_ids[])
const FSEventStreamEventId event_ids[] UNUSED)
{
struct fsmonitor_daemon_state *state = ctx;
struct fsm_listen_data *data = state->listen_data;
Expand Down
24 changes: 10 additions & 14 deletions compat/fsmonitor/fsm-listen-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
SetEvent(state->listen_data->hListener[LISTENER_SHUTDOWN]);
}

static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,
const char *path)
static struct one_watch *create_watch(const char *path)
{
struct one_watch *watch = NULL;
DWORD desired_access = FILE_LIST_DIRECTORY;
Expand Down Expand Up @@ -361,8 +360,7 @@ static void destroy_watch(struct one_watch *watch)
free(watch);
}

static int start_rdcw_watch(struct fsm_listen_data *data,
struct one_watch *watch)
static int start_rdcw_watch(struct one_watch *watch)
{
DWORD dwNotifyFilter =
FILE_NOTIFY_CHANGE_FILE_NAME |
Expand Down Expand Up @@ -735,11 +733,11 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)

state->listen_error_code = 0;

if (start_rdcw_watch(data, data->watch_worktree) == -1)
if (start_rdcw_watch(data->watch_worktree) == -1)
goto force_error_stop;

if (data->watch_gitdir &&
start_rdcw_watch(data, data->watch_gitdir) == -1)
start_rdcw_watch(data->watch_gitdir) == -1)
goto force_error_stop;

for (;;) {
Expand All @@ -755,15 +753,15 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
}
if (result == -2) {
/* retryable error */
if (start_rdcw_watch(data, data->watch_worktree) == -1)
if (start_rdcw_watch(data->watch_worktree) == -1)
goto force_error_stop;
continue;
}

/* have data */
if (process_worktree_events(state) == LISTENER_SHUTDOWN)
goto force_shutdown;
if (start_rdcw_watch(data, data->watch_worktree) == -1)
if (start_rdcw_watch(data->watch_worktree) == -1)
goto force_error_stop;
continue;
}
Expand All @@ -776,15 +774,15 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
}
if (result == -2) {
/* retryable error */
if (start_rdcw_watch(data, data->watch_gitdir) == -1)
if (start_rdcw_watch(data->watch_gitdir) == -1)
goto force_error_stop;
continue;
}

/* have data */
if (process_gitdir_events(state) == LISTENER_SHUTDOWN)
goto force_shutdown;
if (start_rdcw_watch(data, data->watch_gitdir) == -1)
if (start_rdcw_watch(data->watch_gitdir) == -1)
goto force_error_stop;
continue;
}
Expand Down Expand Up @@ -821,16 +819,14 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)

data->hEventShutdown = CreateEvent(NULL, TRUE, FALSE, NULL);

data->watch_worktree = create_watch(state,
state->path_worktree_watch.buf);
data->watch_worktree = create_watch(state->path_worktree_watch.buf);
if (!data->watch_worktree)
goto failed;

check_for_shortnames(data->watch_worktree);

if (state->nr_paths_watching > 1) {
data->watch_gitdir = create_watch(state,
state->path_gitdir_watch.buf);
data->watch_gitdir = create_watch(state->path_gitdir_watch.buf);
if (!data->watch_gitdir)
goto failed;
}
Expand Down
7 changes: 4 additions & 3 deletions compat/fsmonitor/fsm-path-utils-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@ int fsmonitor__is_fs_remote(const char *path)
/*
* No-op for now.
*/
int fsmonitor__get_alias(const char *path, struct alias_info *info)
int fsmonitor__get_alias(const char *path UNUSED,
struct alias_info *info UNUSED)
{
return 0;
}

/*
* No-op for now.
*/
char *fsmonitor__resolve_alias(const char *path,
const struct alias_info *info)
char *fsmonitor__resolve_alias(const char *path UNUSED,
const struct alias_info *info UNUSED)
{
return NULL;
}
2 changes: 1 addition & 1 deletion compat/fsmonitor/fsm-settings-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static enum fsmonitor_reason check_vfs4git(struct repository *r)
return FSMONITOR_REASON_OK;
}

enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc)
enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc UNUSED)
{
enum fsmonitor_reason reason;

Expand Down
10 changes: 5 additions & 5 deletions fsmonitor-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int fsmonitor_ipc__is_supported(void)
return 0;
}

const char *fsmonitor_ipc__get_path(struct repository *r)
const char *fsmonitor_ipc__get_path(struct repository *r UNUSED)
{
return NULL;
}
Expand All @@ -30,14 +30,14 @@ enum ipc_active_state fsmonitor_ipc__get_state(void)
return IPC_STATE__OTHER_ERROR;
}

int fsmonitor_ipc__send_query(const char *since_token,
struct strbuf *answer)
int fsmonitor_ipc__send_query(const char *since_token UNUSED,
struct strbuf *answer UNUSED)
{
return -1;
}

int fsmonitor_ipc__send_command(const char *command,
struct strbuf *answer)
int fsmonitor_ipc__send_command(const char *command UNUSED,
struct strbuf *answer UNUSED)
{
return -1;
}
Expand Down
3 changes: 2 additions & 1 deletion fsmonitor-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ static enum fsmonitor_reason check_remote(struct repository *r)
}
#endif

static enum fsmonitor_reason check_for_incompatible(struct repository *r, int ipc)
static enum fsmonitor_reason check_for_incompatible(struct repository *r,
int ipc MAYBE_UNUSED)
{
if (!r->worktree) {
/*
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 bd06505

Please sign in to comment.