summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-01-27 07:35:26 +0700
committerJunio C Hamano <gitster@pobox.com>2019-01-27 16:28:18 -0800
commitbf3ff338a25b7353ec6d39d31e14d081be9e3471 (patch)
tree125e179fe673c3b09cebbdeb105d7049ddd97498 /parse-options.c
parentf62470c650e0db9536f32b9e1ecbe7d25f759031 (diff)
downloadgit-bf3ff338a25b7353ec6d39d31e14d081be9e3471.tar.gz
parse-options: stop abusing 'callback' for lowlevel callbacks
Lowlevel callbacks have different function signatures. Add a new field in 'struct option' with the right type for lowlevel callbacks. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/parse-options.c b/parse-options.c
index 62d94ca2e0..37a56d079a 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -93,7 +93,7 @@ static int get_value(struct parse_opt_ctx_t *p,
switch (opt->type) {
case OPTION_LOWLEVEL_CALLBACK:
- return (*(parse_opt_ll_cb *)opt->callback)(p, opt, unset);
+ return opt->ll_callback(p, opt, unset);
case OPTION_BIT:
if (unset)
@@ -408,6 +408,19 @@ static void parse_options_check(const struct option *opts)
if ((opts->flags & PARSE_OPT_OPTARG) ||
!(opts->flags & PARSE_OPT_NOARG))
err |= optbug(opts, "should not accept an argument");
+ break;
+ case OPTION_CALLBACK:
+ if (!opts->callback)
+ BUG("OPTION_CALLBACK needs a callback");
+ if (opts->ll_callback)
+ BUG("OPTION_CALLBACK needs no ll_callback");
+ break;
+ case OPTION_LOWLEVEL_CALLBACK:
+ if (!opts->ll_callback)
+ BUG("OPTION_LOWLEVEL_CALLBACK needs a callback");
+ if (opts->callback)
+ BUG("OPTION_LOWLEVEL_CALLBACK needs no high level callback");
+ break;
default:
; /* ok. (usually accepts an argument) */
}