Skip to content

Commit 6ba21fa

Browse files
peffgitster
authored andcommitted
mark "argv" as unused when we check argc
A few commands don't take any options at all, and confirm this by checking argc. After that they have no need to look at argv, but we're still stuck with it by convention. Let's annotate these cases so that the compiler doesn't complain with -Wunused-parameter. Note that in scalar and get-tar-commit-id, we're forced to keep argv by calling convention (the functions must match cmd_main() and builtin cmd_foo() conventions, respectively). In diff, these are subcommand modes that we call individually, so we _could_ just drop the argv parameters entirely. But it's weird to pass argc without argv, and it implies that the caller knows that the subcommands aren't interested in further arguments. It's less confusing to just keep them and silence the compiler warning. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5247b76 commit 6ba21fa

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

builtin/diff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void stuff_change(struct diff_options *opt,
7474
}
7575

7676
static int builtin_diff_b_f(struct rev_info *revs,
77-
int argc, const char **argv,
77+
int argc, const char **argv UNUSED,
7878
struct object_array_entry **blob)
7979
{
8080
/* Blob vs file in the working tree*/
@@ -109,7 +109,7 @@ static int builtin_diff_b_f(struct rev_info *revs,
109109
}
110110

111111
static int builtin_diff_blobs(struct rev_info *revs,
112-
int argc, const char **argv,
112+
int argc, const char **argv UNUSED,
113113
struct object_array_entry **blob)
114114
{
115115
const unsigned mode = canon_mode(S_IFREG | 0644);
@@ -209,7 +209,7 @@ static int builtin_diff_tree(struct rev_info *revs,
209209
}
210210

211211
static int builtin_diff_combined(struct rev_info *revs,
212-
int argc, const char **argv,
212+
int argc, const char **argv UNUSED,
213213
struct object_array_entry *ent,
214214
int ents, int first_non_parent)
215215
{

builtin/get-tar-commit-id.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static const char builtin_get_tar_commit_id_usage[] =
1414
#define RECORDSIZE (512)
1515
#define HEADERSIZE (2 * RECORDSIZE)
1616

17-
int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
17+
int cmd_get_tar_commit_id(int argc, const char **argv UNUSED, const char *prefix)
1818
{
1919
char buffer[HEADERSIZE];
2020
struct ustar_header *header = (struct ustar_header *)buffer;

scalar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ static int cmd_diagnose(int argc, const char **argv)
563563
return res;
564564
}
565565

566-
static int cmd_list(int argc, const char **argv)
566+
static int cmd_list(int argc, const char **argv UNUSED)
567567
{
568568
if (argc != 1)
569569
die(_("`scalar list` does not take arguments"));

0 commit comments

Comments
 (0)