parse-options: mark unused "opt" parameter in callbacks

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>
This commit is contained in:
Jeff King
2023-08-31 17:21:28 -04:00
committed by Junio C Hamano
parent 66e3309294
commit 34bf44f2d5
6 changed files with 14 additions and 12 deletions

View 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) {