[XEN PATCH v2 1/3] iommu: address violation of MISRA C Rule 5.5

Dmytro Prokopchuk1 posted 3 patches 3 months, 3 weeks ago
[XEN PATCH v2 1/3] iommu: address violation of MISRA C Rule 5.5
Posted by Dmytro Prokopchuk1 3 months, 3 weeks ago
Address a violation of MISRA C:2012 Rule 5.5:
"Identifiers shall be distinct from macro names".

Reports for service MC3A2.R5.5:
xen/drivers/passthrough/iommu.c: non-compliant macro 'iommu_quarantine'
xen/include/xen/iommu.h: non-compliant variable 'iommu_quarantine'

There is a clash between function name and macro.
Add an 'extern' declaration for 'iommu_quarantine'
under the same preprocessor condition (#ifdef CONFIG_HAS_PCI).
This ensures that the declaration is consistent
and only exposed when CONFIG_HAS_PCI is defined.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
 xen/include/xen/iommu.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index 3205e49990..57f338e2a0 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -53,7 +53,9 @@ static inline bool dfn_eq(dfn_t x, dfn_t y)
 extern bool iommu_enable, iommu_enabled;
 extern bool force_iommu, iommu_verbose;
 /* Boolean except for the specific purposes of drivers/passthrough/iommu.c. */
+#ifdef CONFIG_HAS_PCI
 extern uint8_t iommu_quarantine;
+#endif /* CONFIG_HAS_PCI */
 #else
 #define iommu_enabled false
 #endif
-- 
2.43.0
Re: [XEN PATCH v2 1/3] iommu: address violation of MISRA C Rule 5.5
Posted by Jan Beulich 3 months, 3 weeks ago
On 09.07.2025 23:38, Dmytro Prokopchuk1 wrote:
> Address a violation of MISRA C:2012 Rule 5.5:
> "Identifiers shall be distinct from macro names".
> 
> Reports for service MC3A2.R5.5:
> xen/drivers/passthrough/iommu.c: non-compliant macro 'iommu_quarantine'
> xen/include/xen/iommu.h: non-compliant variable 'iommu_quarantine'
> 
> There is a clash between function name and macro.
> Add an 'extern' declaration for 'iommu_quarantine'
> under the same preprocessor condition (#ifdef CONFIG_HAS_PCI).

Perhaps s/Add an/Put the/ or some such? You don't add any declaration,
after all.

> This ensures that the declaration is consistent
> and only exposed when CONFIG_HAS_PCI is defined.
> 
> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>

With some suitable adjustment (happy to make while committing as long as
you agree):
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
Re: [XEN PATCH v2 1/3] iommu: address violation of MISRA C Rule 5.5
Posted by Dmytro Prokopchuk1 3 months, 3 weeks ago
Yes, sure. I'll update commit message.
Thanks!

On 7/10/25 11:21, Jan Beulich wrote:
> On 09.07.2025 23:38, Dmytro Prokopchuk1 wrote:
>> Address a violation of MISRA C:2012 Rule 5.5:
>> "Identifiers shall be distinct from macro names".
>>
>> Reports for service MC3A2.R5.5:
>> xen/drivers/passthrough/iommu.c: non-compliant macro 'iommu_quarantine'
>> xen/include/xen/iommu.h: non-compliant variable 'iommu_quarantine'
>>
>> There is a clash between function name and macro.
>> Add an 'extern' declaration for 'iommu_quarantine'
>> under the same preprocessor condition (#ifdef CONFIG_HAS_PCI).
> 
> Perhaps s/Add an/Put the/ or some such? You don't add any declaration,
> after all.
> 
>> This ensures that the declaration is consistent
>> and only exposed when CONFIG_HAS_PCI is defined.
>>
>> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
> 
> With some suitable adjustment (happy to make while committing as long as
> you agree):
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> Jan
Re: [XEN PATCH v2 1/3] iommu: address violation of MISRA C Rule 5.5
Posted by Dmytro Prokopchuk1 3 months, 3 weeks ago
Jan, I don't mind, you can adjust it.
Please, go ahead.

On 7/10/25 12:44, Dmytro Prokopchuk wrote:
> Yes, sure. I'll update commit message.
> Thanks!
> 
> On 7/10/25 11:21, Jan Beulich wrote:
>> On 09.07.2025 23:38, Dmytro Prokopchuk1 wrote:
>>> Address a violation of MISRA C:2012 Rule 5.5:
>>> "Identifiers shall be distinct from macro names".
>>>
>>> Reports for service MC3A2.R5.5:
>>> xen/drivers/passthrough/iommu.c: non-compliant macro 'iommu_quarantine'
>>> xen/include/xen/iommu.h: non-compliant variable 'iommu_quarantine'
>>>
>>> There is a clash between function name and macro.
>>> Add an 'extern' declaration for 'iommu_quarantine'
>>> under the same preprocessor condition (#ifdef CONFIG_HAS_PCI).
>>
>> Perhaps s/Add an/Put the/ or some such? You don't add any declaration,
>> after all.
>>
>>> This ensures that the declaration is consistent
>>> and only exposed when CONFIG_HAS_PCI is defined.
>>>
>>> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
>>
>> With some suitable adjustment (happy to make while committing as long as
>> you agree):
>> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>>
>> Jan
>