[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN PATCH v3 09/16] xen: address violations of MISRA C:2012 Directive 4.10
On 11.03.2024 09:59, Simone Ballarin wrote: > Amend inclusion guards to address violations of > MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order > to prevent the contents of a header file being included more than > once"). > > Inclusion guards must appear at the beginning of the headers > (comments are permitted anywhere) and the #if directive cannot > be used for other checks. This latter restriction, even if just slightly, hampers readability > --- a/xen/include/xen/err.h > +++ b/xen/include/xen/err.h > @@ -1,5 +1,6 @@ > -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) > -#define __XEN_ERR_H__ > +#ifndef XEN_INCLUDE_XEN_ERR_H > +#define XEN_INCLUDE_XEN_ERR_H > +#ifndef __ASSEMBLY__ > > #include <xen/compiler.h> > #include <xen/errno.h> > @@ -41,4 +42,5 @@ static inline int __must_check PTR_RET(const void *ptr) > return IS_ERR(ptr) ? PTR_ERR(ptr) : 0; > } > > -#endif /* __XEN_ERR_H__ */ > +#endif /* __ASSEMBLY__ */ > +#endif /* XEN_INCLUDE_XEN_ERR_H */ ... here, ... > --- a/xen/include/xen/softirq.h > +++ b/xen/include/xen/softirq.h > @@ -1,5 +1,6 @@ > -#if !defined(__XEN_SOFTIRQ_H__) && !defined(__ASSEMBLY__) > -#define __XEN_SOFTIRQ_H__ > +#ifndef XEN_INCLUDE_XEN_SOFTIRQ_H > +#define XEN_INCLUDE_XEN_SOFTIRQ_H > +#ifndef __ASSEMBLY__ > > /* Low-latency softirqs come first in the following list. */ > enum { > @@ -40,4 +41,5 @@ void cpu_raise_softirq_batch_finish(void); > */ > void process_pending_softirqs(void); > > -#endif /* __XEN_SOFTIRQ_H__ */ > +#endif /* __ASSEMBLY__ */ > +#endif /* XEN_INCLUDE_XEN_SOFTIRQ_H */ ... here, and ... > --- a/xen/include/xen/vmap.h > +++ b/xen/include/xen/vmap.h > @@ -1,5 +1,6 @@ > -#if !defined(__XEN_VMAP_H__) && defined(VMAP_VIRT_START) > -#define __XEN_VMAP_H__ > +#ifndef XEN_INCLUDE_XEN_VMAP_H > +#define XEN_INCLUDE_XEN_VMAP_H > +#ifdef VMAP_VIRT_START > > #include <xen/mm-frame.h> > #include <xen/page-size.h> > @@ -42,4 +43,5 @@ static inline void vm_init(void) > vm_init_type(VMAP_DEFAULT, (void *)VMAP_VIRT_START, > arch_vmap_virt_end()); > } > > -#endif /* __XEN_VMAP_H__ */ > +#endif /* VMAP_VIRT_START */ > +#endif /* XEN_INCLUDE_XEN_VMAP_H */ ... here. Wasn't a goal of Misra to also not have negative effects on code readability? Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |