Address a violation of MISRA C:2012 Rule 5.5:
"Identifiers shall be distinct from macro names".
Reports for service MC3A2.R5.5:
xen/include/xen/irq.h: non-compliant function `pirq_cleanup_check(struct pirq*, struct domain*)'
xen/include/xen/irq.h: non-compliant macro `pirq_cleanup_check'
The primary issue stems from the macro and function
having identical names, which is confusing and
non-compliant with common coding standards.
Change the function name by adding two underscores at the end.
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
xen/arch/x86/irq.c | 2 +-
xen/include/xen/irq.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 556134f85a..d61720aa60 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -1383,7 +1383,7 @@ struct pirq *alloc_pirq_struct(struct domain *d)
return pirq;
}
-void (pirq_cleanup_check)(struct pirq *pirq, struct domain *d)
+void pirq_cleanup_check__(struct pirq *pirq, struct domain *d)
{
/*
* Check whether all fields have their default values, and delete
diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h
index 95034c0d6b..02f686a999 100644
--- a/xen/include/xen/irq.h
+++ b/xen/include/xen/irq.h
@@ -183,10 +183,10 @@ extern struct pirq *pirq_get_info(struct domain *d, int pirq);
#define pirq_to_evtchn(d, pirq) pirq_field(d, pirq, evtchn, 0)
#define pirq_masked(d, pirq) pirq_field(d, pirq, masked, 0)
-void pirq_cleanup_check(struct pirq *pirq, struct domain *d);
+void pirq_cleanup_check__(struct pirq *pirq, struct domain *d);
#define pirq_cleanup_check(pirq, d) \
- (!(pirq)->evtchn ? pirq_cleanup_check(pirq, d) : (void)0)
+ (!(pirq)->evtchn ? pirq_cleanup_check__(pirq, d) : (void)0)
extern void pirq_guest_eoi(struct pirq *pirq);
extern void desc_guest_eoi(struct irq_desc *desc, struct pirq *pirq);
--
2.43.0
On 04.07.2025 22:39, 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/include/xen/irq.h: non-compliant function `pirq_cleanup_check(struct pirq*, struct domain*)' > xen/include/xen/irq.h: non-compliant macro `pirq_cleanup_check' > > The primary issue stems from the macro and function > having identical names, which is confusing and > non-compliant with common coding standards. > > Change the function name by adding two underscores at the end. > > Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com> I'm not going to NAK this, but I dislike the transformation done. The aliasing in this case was intentional, to avoid any caller appearing that would bypass the macro. Yes, the double underscores will also stand out (as much as the parenthesization that would have been needed to override the protection), but still ... Jan
On Mon, 7 Jul 2025, Jan Beulich wrote: > On 04.07.2025 22:39, 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/include/xen/irq.h: non-compliant function `pirq_cleanup_check(struct pirq*, struct domain*)' > > xen/include/xen/irq.h: non-compliant macro `pirq_cleanup_check' > > > > The primary issue stems from the macro and function > > having identical names, which is confusing and > > non-compliant with common coding standards. > > > > Change the function name by adding two underscores at the end. > > > > Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com> > > I'm not going to NAK this, but I dislike the transformation done. The aliasing > in this case was intentional, to avoid any caller appearing that would bypass > the macro. Yes, the double underscores will also stand out (as much as the > parenthesization that would have been needed to override the protection), but > still ... Maybe you can suggest a different name? Looking at the diff, this patch also seems OKish. It is possible but difficult to deviate specific instances like this: if a SAF in-code comment works, then great, otherwise we have to resort to a regex which makes thing harder to maintain. Unless a SAF in-code comment works, I think this patch is the best way to go.
On 07.07.2025 23:25, Stefano Stabellini wrote: > On Mon, 7 Jul 2025, Jan Beulich wrote: >> On 04.07.2025 22:39, 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/include/xen/irq.h: non-compliant function `pirq_cleanup_check(struct pirq*, struct domain*)' >>> xen/include/xen/irq.h: non-compliant macro `pirq_cleanup_check' >>> >>> The primary issue stems from the macro and function >>> having identical names, which is confusing and >>> non-compliant with common coding standards. >>> >>> Change the function name by adding two underscores at the end. >>> >>> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com> >> >> I'm not going to NAK this, but I dislike the transformation done. The aliasing >> in this case was intentional, to avoid any caller appearing that would bypass >> the macro. Yes, the double underscores will also stand out (as much as the >> parenthesization that would have been needed to override the protection), but >> still ... > > Maybe you can suggest a different name? As per my earlier reply, using the same name was intentional here. Hence it's not a matter of what (different) name to pick, but the mere fact that a different name is being suggested to be used. Yet as said - I'm not going to NAK this, but I also don't like the change. Jan > Looking at the diff, this patch also seems OKish. > > It is possible but difficult to deviate specific instances like this: if > a SAF in-code comment works, then great, otherwise we have to resort to > a regex which makes thing harder to maintain. > > Unless a SAF in-code comment works, I think this patch is the best way > to go.
© 2016 - 2025 Red Hat, Inc.