On 10.05.2025 01:28, Stefano Stabellini wrote: > From: Federico Serafini <[email protected]> > > MISRA C Rule 14.3 states that "Controlling expressions shall not be > invariant". > > Change the #define to static inline to resolve the violation. > > Signed-off-by: Federico Serafini <[email protected]> > Signed-off-by: Victor Lira <[email protected]> > > diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c > index bd4538c28d..9ee1506703 100644 > --- a/xen/common/page_alloc.c > +++ b/xen/common/page_alloc.c > @@ -2005,7 +2005,10 @@ static unsigned long __initdata buddy_alloc_size = > MB(CONFIG_BUDDY_ALLOCATOR_SIZE); > size_param("buddy-alloc-size", buddy_alloc_size); > #else > -#define domain_num_llc_colors(d) 0 > +static inline unsigned int domain_num_llc_colors(const struct domain *d) > +{ > + return 0; > +}
Isn't this merely pleasing Eclair without actually addressing the violation? The spec's last example is, I think, a good demonstration (sadly the PDF doesn't allow copy-out). The violation described there, with a loop calculating a value ahead of the actual if(), is even less obviously one than the inline function here. Jan
