Re: [PATCHv2 14/17] nvme: fix Clang context analysis warning in rdma.c

From: Marco Elver

Date: Mon Jun 29 2026 - 18:47:53 EST


On Mon, 29 Jun 2026 at 14:50, Christoph Hellwig <hch@xxxxxx> wrote:
>
> On Fri, Jun 26, 2026 at 09:01:20PM +0530, Nilay Shroff wrote:
> >> Does switching to list_empty_careful fix this? If not, does
> >> list_empty_careful need annotations to make this work?
> >>
> >
> > I tried using list_empty_careful() but clang still throws the
> > same warning. And yes it needs same annotation to suppress
> > the warning.
>
> Sounds like we should have annotations (or just use of data_race)
> in list_empty_careful, as it is designed to be used without holding
> the relevant lock used for modifications?

Given list_empty_careful() is a real inline function (not a macro),
you can just add __no_context_analysis to list_empty_careful(), which
should also suppress warnings about pointer-to-guarded-variable being
passed as an argument into it. data_race() wouldn't work, as the
warning is generated in the caller, but when the attribute is added to
the callee, it also suppresses warnings about arguments in the caller.