]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mark "argv" as unused when we check argc
authorJeff King <peff@peff.net>
Tue, 28 Mar 2023 20:57:04 +0000 (16:57 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Mar 2023 21:11:24 +0000 (14:11 -0700)
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/diff.c
builtin/get-tar-commit-id.c
scalar.c

index 26f1e532c66b173fb4b29d220564fcd90c03d0d2..bc9da7bcb605af4be72c306634889d894afdfe63 100644 (file)
@@ -74,7 +74,7 @@ static void stuff_change(struct diff_options *opt,
 }
 
 static int builtin_diff_b_f(struct rev_info *revs,
-                           int argc, const char **argv,
+                           int argc, const char **argv UNUSED,
                            struct object_array_entry **blob)
 {
        /* Blob vs file in the working tree*/
@@ -109,7 +109,7 @@ static int builtin_diff_b_f(struct rev_info *revs,
 }
 
 static int builtin_diff_blobs(struct rev_info *revs,
-                             int argc, const char **argv,
+                             int argc, const char **argv UNUSED,
                              struct object_array_entry **blob)
 {
        const unsigned mode = canon_mode(S_IFREG | 0644);
@@ -209,7 +209,7 @@ static int builtin_diff_tree(struct rev_info *revs,
 }
 
 static int builtin_diff_combined(struct rev_info *revs,
-                                int argc, const char **argv,
+                                int argc, const char **argv UNUSED,
                                 struct object_array_entry *ent,
                                 int ents, int first_non_parent)
 {
index 8f8f2ac3e68046b0fd3a4d12d5374bebe2c5c7ec..4324d39fb491c44a3b2778a8d14f1a2583283f5a 100644 (file)
@@ -14,7 +14,7 @@ static const char builtin_get_tar_commit_id_usage[] =
 #define RECORDSIZE     (512)
 #define HEADERSIZE (2 * RECORDSIZE)
 
-int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
+int cmd_get_tar_commit_id(int argc, const char **argv UNUSED, const char *prefix)
 {
        char buffer[HEADERSIZE];
        struct ustar_header *header = (struct ustar_header *)buffer;
index ca19b95ce46cfdaa6f501eb487d4ba869fd0c5bd..c7b8c16c8eedc271653853f52981e865c9f934e3 100644 (file)
--- a/scalar.c
+++ b/scalar.c
@@ -563,7 +563,7 @@ static int cmd_diagnose(int argc, const char **argv)
        return res;
 }
 
-static int cmd_list(int argc, const char **argv)
+static int cmd_list(int argc, const char **argv UNUSED)
 {
        if (argc != 1)
                die(_("`scalar list` does not take arguments"));