On 2025/7/30 18:46, Nicola Vetrini wrote:
> On 2025-07-30 12:42, Nicola Vetrini wrote:
>> On 2025-07-30 11:50, Jan Beulich wrote:
>>> On 28.07.2025 07:03, Jiqian Chen wrote:
>>>> +static int vpci_ext_capability_hide(
>>>> +    const struct pci_dev *pdev, unsigned int cap)
>>>> +{
>>>> +    const unsigned int offset = pci_find_ext_capability(pdev->sbdf, cap);
>>>> +    struct vpci_register *r, *prev_r;
>>>> +    struct vpci *vpci = pdev->vpci;
>>>> +    uint32_t header, pre_header;
>>>> +
>>>> +    if ( offset < PCI_CFG_SPACE_SIZE )
>>>> +    {
>>>> +        ASSERT_UNREACHABLE();
>>>> +        return 0;
>>>> +    }
>>>> +
>>>> +    spin_lock(&vpci->lock);
>>>> +    r = vpci_get_register(vpci, offset, 4);
>>>> +    if ( !r )
>>>> +    {
>>>> +        spin_unlock(&vpci->lock);
>>>> +        return -ENODEV;
>>>> +    }
>>>> +
>>>> +    header = (uint32_t)(uintptr_t)r->private;
>>>> +    if ( offset == PCI_CFG_SPACE_SIZE )
>>>> +    {
>>>> +        if ( PCI_EXT_CAP_NEXT(header) <= PCI_CFG_SPACE_SIZE )
>>>> +            r->private = (void *)(uintptr_t)0;
>>>
>>> Eclair regards this a Misra rule 11.9 violation. Elsewhere we use (void *)0,
>>> which I then would conclude is "fine". But I can't say why that is. Cc-ing
>>> Bugseng for a possible explanation.
>>>
>>
>> Hi Jan,
>>
>> I only see
>>
>> 0|$ git grep "(void\*)0"
>> xen/include/xen/types.h:#define NULL ((void*)0)
>>
>> which is fine for R11.9 of course. As Andrew noted, I don't see the need for 
>> the use of uintptr_t either.
> 
> Oh, I missed forms using a space before the pointer. In any case, from the 
> rule's Amplification: "Note: a null pointer constant of the form (void *)0 is 
> permitted, whether or not it was expanded from NULL."
> 

Thank you for helping to solve this problem.
Thank you both very much!

-- 
Best regards,
Jiqian Chen.

Reply via email to