Skip to content

Commit 4db16f5

Browse files
peffgitster
authored andcommitted
var: mark unused parameters in git_var callbacks
We abstract the set of variables into a table, with a "read" callback to provide the value of each. Each callback takes a "flag" argument, but most callbacks don't make use of it. This flag is a bit odd. It may be set to IDENT_STRICT, which make sense for ident-based callbacks, but is just confusing for things like GIT_EDITOR. At first glance, it seems like this is just a hack to let us directly stick the generic git_committer_info() and git_author_info() functions into our table. And we'd be better off to wrap them with local functions which pass IDENT_STRICT, and have our callbacks take no option at all. But that doesn't quite work. We pass IDENT_STRICT when the caller asks for a specific variable, but otherwise do not (so that "git var -l" does not bail if the committer ident cannot be formed). So we really do need to pass in the flag to each invocation, even if the individual callback doesn't care about it. Let's mark the unused ones so that -Wunused-parameter does not complain. And while we're here, let's rename them so that it's clear that the flag values we get will be from the IDENT_* set. That may prevent confusion for future readers of the code. Another option would be to define our own local "strict" flag for the callbacks, and then have wrappers that translate that to IDENT_STRICT where it matters. But that would be more boilerplate for little gain (most functions would still ignore the "strict" flag anyway). Signed-off-by: Jeff King <[email protected]> Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fe86abd commit 4db16f5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

builtin/var.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212

1313
static const char var_usage[] = "git var (-l | <variable>)";
1414

15-
static const char *editor(int flag)
15+
static const char *editor(int ident_flag UNUSED)
1616
{
1717
return git_editor();
1818
}
1919

20-
static const char *sequence_editor(int flag)
20+
static const char *sequence_editor(int ident_flag UNUSED)
2121
{
2222
return git_sequence_editor();
2323
}
2424

25-
static const char *pager(int flag)
25+
static const char *pager(int ident_flag UNUSED)
2626
{
2727
const char *pgm = git_pager(1);
2828

@@ -31,7 +31,7 @@ static const char *pager(int flag)
3131
return pgm;
3232
}
3333

34-
static const char *default_branch(int flag)
34+
static const char *default_branch(int ident_flag UNUSED)
3535
{
3636
return git_default_branch_name(1);
3737
}

0 commit comments

Comments
 (0)