Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> writes: > The compiler reports this because show_gitcomp() never actually > returns a value: > > "parse-options.c", line 520: warning: Function has no return > statement : show_gitcomp > > The function calls exit() and will never return. Update and mark it > NORETURN. Yuck. This should do for now, but I am not impressed by the choice to hook show_gitcomp() call into parse_options_step(), which forces such an abnormal exit deeper in the callchain [*1*]. For readers (not compilers), it would help to have a comment at the caller that says that show_gitcomp() never returns and exits. side note #1. Perhaps parse_options_start() would have been a better place, instead of parse_options_step() that is repeatedly called in a loop and itself has a loop. ANd worse yet, the check is done inside the loop even though the call is to be made only when the --git-completion-helper option is given as the sole request. Thanks. > Reported-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> > --- > parse-options.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/parse-options.c b/parse-options.c > index 3b874a83a0..6577e52f63 100644 > --- a/parse-options.c > +++ b/parse-options.c > @@ -474,8 +474,8 @@ static void show_negated_gitcomp(const struct option *opts, int nr_noopts) > } > } > > -static int show_gitcomp(struct parse_opt_ctx_t *ctx, > - const struct option *opts) > +static void NORETURN show_gitcomp(struct parse_opt_ctx_t *ctx, > + const struct option *opts) > { > const struct option *original_opts = opts; > int nr_noopts = 0; > @@ -550,7 +550,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx, > > /* lone --git-completion-helper is asked by git-completion.bash */ > if (ctx->total == 1 && !strcmp(arg + 1, "-git-completion-helper")) > - return show_gitcomp(ctx, options); > + show_gitcomp(ctx, options); > > if (arg[1] != '-') { > ctx->opt = arg + 1;