On 2025-08-02 19:48, Dmytro Prokopchuk1 wrote:
Hello folks!

There are a lot of MISRA C R17.7 violations in the XEN.
This rule states: "The value returned by a function having non-void
return type shall be used".

Actually, need to decide how to deal with these violations.
Quick analyze shown that there are different cases in XEN code base.
Like, for example:

the return value of function `clean_and_invalidate_dcache_va_range(const
void*, unsigned long)' (unit `xen/arch/arm/alternative.c' with target
`xen/arch/arm/alternative.o') is unexpectedly ignored


This thread [1] has some discussions around the cache invalidation helpers, so it may be useful to consider the points raised there in this discussion

[1] https://lore.kernel.org/xen-devel/cc6bf44701c808645c69bacaf4463295e2cb0fba.1708354388.git.nicola.vetr...@bugseng.com/

The return value of this function 'clean_and_invalidate_dcache_va_range'
is checked only in one place. Probably, after deeper analyze the return
value can be dropped and function prototype can be changed to

static inline void clean_and_invalidate_dcache_va_range
     (const void *p, unsigned long size);


Next case is vice versa:

the return value of function `vgic_reserve_virq(struct domain*,
unsigned)' is unexpectedly ignored

There is only one place where the return value is not checked.
Probably, in this place code may be changed to:

     (void)vgic_reserve_virq(d, irq);


For the case with 'memset' function:

the return value of function `memset(void*, int, size_t)' is
unexpectedly ignored

I guess it's better to create deviation, something like:

"The return value of the function memset(void *, int, size_t) is ignored
because the primary purpose of the function is to set a block of memory
to a specific value, not to use the pointer returned by the function."


But due to the large number of violations, it will be tricky to address
all of them.
I don't know, maybe the only right solution is to deviate all.


Thanks!
Dmytro.

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253

Reply via email to