Re: [PATCH v2 8/9] objtool: Detect missing __noreturn annotations

From: Josh Poimboeuf
Date: Thu Apr 13 2023 - 11:32:48 EST


On Thu, Apr 13, 2023 at 04:19:10PM +0200, Miroslav Benes wrote:
> > --- a/tools/objtool/check.c
> > +++ b/tools/objtool/check.c
> > @@ -4485,7 +4485,8 @@ static int validate_sls(struct objtool_file *file)
> >
> > static int validate_reachable_instructions(struct objtool_file *file)
> > {
> > - struct instruction *insn;
> > + struct instruction *insn, *prev_insn;
> > + struct symbol *call_dest;
> > int warnings = 0;
> >
> > if (file->ignore_unreachables)
> > @@ -4495,6 +4496,17 @@ static int validate_reachable_instructions(struct objtool_file *file)
> > if (insn->visited || ignore_unreachable_insn(file, insn))
> > continue;
> >
> > + prev_insn = prev_insn_same_sec(file, insn);
> > + if (prev_insn && prev_insn->dead_end) {
> > + call_dest = insn_call_dest(prev_insn);
> > + if (call_dest) {
> > + WARN_INSN(insn, "%s() is missing a __noreturn annotation",
> > + call_dest->name);
> > + warnings++;
> > + continue;
>
> A nit but this and
>
> > + }
> > + }
> > +
> > WARN_INSN(insn, "unreachable instruction");
> > warnings++;
>
> this makes me thinking. Wouldn't it be confusing to anyone that there is
> no correspondence between warnings and a number of actual reported
> warnings through WARN_INSN()? In the future when there would be a usage
> for warnings. It does not really matter now.

True, maybe we need WARN_INSN_ONCE_PER_FUNC() or so ;-)

--
Josh