diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-01-05 23:42:00 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-05 23:42:00 -0800 |
commit | 29fb15152584455590905726cb5a0e26ea26e9eb (patch) | |
tree | 569e053cec17633825c9f7bd8df042c88b0600e3 /parse-options.c | |
parent | 946a5aee3e896aa12cb9d4d21079c6e299baad81 (diff) | |
parent | a469a1019352b8efc4bd7003b0bd59eb60fc428c (diff) | |
download | git-29fb15152584455590905726cb5a0e26ea26e9eb.tar.gz git-29fb15152584455590905726cb5a0e26ea26e9eb.tar.xz |
Merge branch 'jk/error-const-return'
Help compilers' flow analysis by making it more explicit that
error() always returns -1, to reduce false "variable used
uninitialized" warnings. Looks somewhat ugly but not too much.
* jk/error-const-return:
silence some -Wuninitialized false positives
make error()'s constant return value more visible
Diffstat (limited to 'parse-options.c')
-rw-r--r-- | parse-options.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/parse-options.c b/parse-options.c index c1c66bd40..67e98a632 100644 --- a/parse-options.c +++ b/parse-options.c @@ -18,15 +18,6 @@ int optbug(const struct option *opt, const char *reason) return error("BUG: switch '%c' %s", opt->short_name, reason); } -int opterror(const struct option *opt, const char *reason, int flags) -{ - if (flags & OPT_SHORT) - return error("switch `%c' %s", opt->short_name, reason); - if (flags & OPT_UNSET) - return error("option `no-%s' %s", opt->long_name, reason); - return error("option `%s' %s", opt->long_name, reason); -} - static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt, int flags, const char **arg) { @@ -594,3 +585,12 @@ static int parse_options_usage(struct parse_opt_ctx_t *ctx, return usage_with_options_internal(ctx, usagestr, opts, 0, err); } +#undef opterror +int opterror(const struct option *opt, const char *reason, int flags) +{ + if (flags & OPT_SHORT) + return error("switch `%c' %s", opt->short_name, reason); + if (flags & OPT_UNSET) + return error("option `no-%s' %s", opt->long_name, reason); + return error("option `%s' %s", opt->long_name, reason); +} |