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

Nilay Shroff nilay at linux.ibm.com
Tue Jun 30 02:35:44 PDT 2026


On 6/30/26 4:17 AM, Marco Elver wrote:
> On Mon, 29 Jun 2026 at 14:50, Christoph Hellwig <hch at lst.de> 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.

That sounds reasonable. So you're suggesting adding __no_context_analysis
to list_empty_careful(). If we agree that's the right approach, I think
it would make sense as a separate infrastructure patch rather than embedding
it in an NVMe-specific change. So are you planning to send such a patch?

Thanks,
--Nilay



More information about the Linux-nvme mailing list