]> git.ipfire.org Git - thirdparty/git.git/commitdiff
parse-options: mark unused "opt" parameter in callbacks
authorJeff King <peff@peff.net>
Thu, 31 Aug 2023 21:21:28 +0000 (17:21 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Sep 2023 21:48:17 +0000 (14:48 -0700)
The previous commit argued that parse-options callbacks should try to
use opt->value rather than touching globals directly. In some cases,
however, that's awkward to do. Some callbacks touch multiple variables,
or may even just call into an abstracted function that does so.

In some of these cases we _could_ convert them by stuffing the multiple
variables into a single struct and passing the struct pointer through
opt->value. But that may make other parts of the code less readable,
as the struct relationship has to be mentioned everywhere.

Let's just accept that these cases are special and leave them as-is. But
we do need to mark their "opt" parameters to satisfy -Wunused-parameter.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c
builtin/log.c
builtin/merge.c
builtin/pack-objects.c
builtin/read-tree.c
builtin/update-index.c

index 1f53b66c7b639bd8311ee44e008bfa1ed83b167e..5cfc178c7ba555889996676fc1ae6f7841e2f00f 100644 (file)
@@ -1403,7 +1403,7 @@ static void initialize_task_config(int schedule)
        strbuf_release(&config_name);
 }
 
-static int task_option_parse(const struct option *opt,
+static int task_option_parse(const struct option *opt UNUSED,
                             const char *arg, int unset)
 {
        int i, num_selected = 0;
index fb90d43717e3f7d1cb37ac7d8e1089c8ff5ff880..3599063554b6628509e61aff9afc9f5db81dc89e 100644 (file)
@@ -118,8 +118,8 @@ static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
 static struct string_list decorate_refs_exclude_config = STRING_LIST_INIT_NODUP;
 static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
 
-static int clear_decorations_callback(const struct option *opt,
-                                           const char *arg, int unset)
+static int clear_decorations_callback(const struct option *opt UNUSED,
+                                     const char *arg, int unset)
 {
        string_list_clear(&decorate_refs_include, 0);
        string_list_clear(&decorate_refs_exclude, 0);
@@ -127,7 +127,8 @@ static int clear_decorations_callback(const struct option *opt,
        return 0;
 }
 
-static int decorate_callback(const struct option *opt, const char *arg, int unset)
+static int decorate_callback(const struct option *opt UNUSED, const char *arg,
+                            int unset)
 {
        if (unset)
                decoration_style = 0;
@@ -1555,7 +1556,8 @@ static int inline_callback(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
-static int header_callback(const struct option *opt, const char *arg, int unset)
+static int header_callback(const struct option *opt UNUSED, const char *arg,
+                          int unset)
 {
        if (unset) {
                string_list_clear(&extra_hdr, 0);
index 21363b7985b05ee19c1eed48788f2fb7bb92f958..0436986dab45e9b1e00b4b688663a93088803b0b 100644 (file)
@@ -231,7 +231,7 @@ static void append_strategy(struct strategy *s)
        use_strategies[use_strategies_nr++] = s;
 }
 
-static int option_parse_strategy(const struct option *opt,
+static int option_parse_strategy(const struct option *opt UNUSED,
                                 const char *name, int unset)
 {
        if (unset)
index 492372ee5dea727c33c21a39aff464328ad1d161..91b4b7c17724922cbb10742cf4c3cdebbc89c166 100644 (file)
@@ -3739,7 +3739,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,
        show_object(obj, name, data);
 }
 
-static int option_parse_missing_action(const struct option *opt,
+static int option_parse_missing_action(const struct option *opt UNUSED,
                                       const char *arg, int unset)
 {
        assert(arg);
@@ -4150,7 +4150,7 @@ static int option_parse_index_version(const struct option *opt,
        return 0;
 }
 
-static int option_parse_unpack_unreachable(const struct option *opt,
+static int option_parse_unpack_unreachable(const struct option *opt UNUSED,
                                           const char *arg, int unset)
 {
        if (unset) {
@@ -4165,7 +4165,7 @@ static int option_parse_unpack_unreachable(const struct option *opt,
        return 0;
 }
 
-static int option_parse_cruft_expiration(const struct option *opt,
+static int option_parse_cruft_expiration(const struct option *opt UNUSED,
                                         const char *arg, int unset)
 {
        if (unset) {
index 1fec702a04fa9b9785d767c4e8b44e50d0e3a89c..8196ca9dd85828890cf5e7088d19e51990a00c66 100644 (file)
@@ -49,7 +49,7 @@ static const char * const read_tree_usage[] = {
        NULL
 };
 
-static int index_output_cb(const struct option *opt, const char *arg,
+static int index_output_cb(const struct option *opt UNUSED, const char *arg,
                                 int unset)
 {
        BUG_ON_OPT_NEG(unset);
index aee3cb8cbd3a03cedaf0c3e317e8c860049dbb74..59acae333612a4e27dca7a0809961ac7b74ce994 100644 (file)
@@ -856,7 +856,7 @@ static int chmod_callback(const struct option *opt,
        return 0;
 }
 
-static int resolve_undo_clear_callback(const struct option *opt,
+static int resolve_undo_clear_callback(const struct option *opt UNUSED,
                                const char *arg, int unset)
 {
        BUG_ON_OPT_NEG(unset);
@@ -890,7 +890,7 @@ static int parse_new_style_cacheinfo(const char *arg,
 }
 
 static enum parse_opt_result cacheinfo_callback(
-       struct parse_opt_ctx_t *ctx, const struct option *opt,
+       struct parse_opt_ctx_t *ctx, const struct option *opt UNUSED,
        const char *arg, int unset)
 {
        struct object_id oid;