diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-10-08 19:07:39 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-10-08 21:13:11 (GMT) |
commit | 352e761388b5fa41bf40e7c04edf3cb07d888d94 (patch) | |
tree | 42e71438337eff815e66e988fa934f92369e99a5 /parse-options.h | |
parent | 3f9ab7ccdea91b8312a14d39ce752b4d6685d067 (diff) | |
download | git-352e761388b5fa41bf40e7c04edf3cb07d888d94.zip git-352e761388b5fa41bf40e7c04edf3cb07d888d94.tar.gz git-352e761388b5fa41bf40e7c04edf3cb07d888d94.tar.bz2 |
parse-options.[ch]: consistently use "enum parse_opt_result"
Use the "enum parse_opt_result" instead of an "int flags" as the
return value of the applicable functions in parse-options.c.
This will help catch future bugs, such as the missing "case" arms in
the two existing users of the API in "blame.c" and "shortlog.c". A
third caller in 309be813c9b (update-index: migrate to parse-options
API, 2010-12-01) was already checking for these.
As can be seen when trying to sort through the deluge of warnings
produced when compiling this with CC=g++ (mostly unrelated to this
change) we're not consistently using "enum parse_opt_result" even now,
i.e. we'll return error() and "return 0;". See f41179f16ba
(parse-options: avoid magic return codes, 2019-01-27) for a commit
which started changing some of that.
I'm not doing any more of that exhaustive migration here, and it's
probably not worthwhile past the point of being able to check "enum
parse_opt_result" in switch().
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.h')
-rw-r--r-- | parse-options.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/parse-options.h b/parse-options.h index 2e8798d..a1c7c86 100644 --- a/parse-options.h +++ b/parse-options.h @@ -211,10 +211,11 @@ struct option { * untouched and parse_options() returns the number of options * processed. */ -int parse_options(int argc, const char **argv, const char *prefix, - const struct option *options, - const char * const usagestr[], - enum parse_opt_flags flags); +enum parse_opt_result parse_options(int argc, const char **argv, + const char *prefix, + const struct option *options, + const char * const usagestr[], + enum parse_opt_flags flags); NORETURN void usage_with_options(const char * const *usagestr, const struct option *options); @@ -274,9 +275,9 @@ void parse_options_start(struct parse_opt_ctx_t *ctx, const struct option *options, enum parse_opt_flags flags); -int parse_options_step(struct parse_opt_ctx_t *ctx, - const struct option *options, - const char * const usagestr[]); +enum parse_opt_result parse_options_step(struct parse_opt_ctx_t *ctx, + const struct option *options, + const char * const usagestr[]); int parse_options_end(struct parse_opt_ctx_t *ctx); |