Message ID | 6ef4634e273a89582299061f1d14346572bf1d47.1693228255.git.simone.ballarin@bugseng.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | address violations of MISRA C:2012 Directive 4.10 | expand |
On Mon, 28 Aug 2023, Simone Ballarin wrote: > Move or amended 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. > > Mechanical change. > > Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com> > --- > xen/include/xen/err.h | 4 +++- > xen/include/xen/pci_ids.h | 5 +++++ > xen/include/xen/softirq.h | 4 +++- > xen/include/xen/unaligned.h | 7 ++++--- > xen/include/xen/vmap.h | 4 +++- > 5 files changed, 18 insertions(+), 6 deletions(-) > > diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h > index 2f29b57d28..a6323d82d7 100644 > --- a/xen/include/xen/err.h > +++ b/xen/include/xen/err.h > @@ -1,5 +1,6 @@ > -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) > +#if !defined(__XEN_ERR_H__) > #define __XEN_ERR_H__ > +#if !defined(__ASSEMBLY__) The original pattern was also guarding the header file sufficiently, protecting it from double-inclusion. In fact, it is posing stricter restrictions than usual (not laxer). This change is unnecessary? > #include <xen/compiler.h> > #include <xen/errno.h> > @@ -54,4 +55,5 @@ static inline int __must_check PTR_RET(const void *ptr) > return IS_ERR(ptr) ? PTR_ERR(ptr) : 0; > } > > +#endif /* __ASSEMBLY__ */ > #endif /* __XEN_ERR_H__ */ > diff --git a/xen/include/xen/pci_ids.h b/xen/include/xen/pci_ids.h > index e798477a7e..1a739d4c92 100644 > --- a/xen/include/xen/pci_ids.h > +++ b/xen/include/xen/pci_ids.h > @@ -1,3 +1,6 @@ > +#ifndef __XEN_PCI_IDS_H__ > +#define __XEN_PCI_IDS_H__ > + > #define PCI_VENDOR_ID_AMD 0x1022 > > #define PCI_VENDOR_ID_NVIDIA 0x10de > @@ -11,3 +14,5 @@ > #define PCI_VENDOR_ID_BROADCOM 0x14e4 > > #define PCI_VENDOR_ID_INTEL 0x8086 > + > +#endif /* __XEN_PCI_IDS_H__ */ > diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h > index 33d6f2ecd2..092ec733b7 100644 > --- a/xen/include/xen/softirq.h > +++ b/xen/include/xen/softirq.h > @@ -1,5 +1,6 @@ > -#if !defined(__XEN_SOFTIRQ_H__) && !defined(__ASSEMBLY__) > +#if !defined(__XEN_SOFTIRQ_H__) > #define __XEN_SOFTIRQ_H__ > +#if !defined(__ASSEMBLY__) same here > /* 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 /* __ASSEMBLY__ */ > #endif /* __XEN_SOFTIRQ_H__ */ > diff --git a/xen/include/xen/unaligned.h b/xen/include/xen/unaligned.h > index 0a2b16d05d..45f03b3f1b 100644 > --- a/xen/include/xen/unaligned.h > +++ b/xen/include/xen/unaligned.h > @@ -3,13 +3,14 @@ > * without faulting, and at least reasonably efficiently. Other architectures > * will need to have a custom asm/unaligned.h. > */ > -#ifndef __ASM_UNALIGNED_H__ > -#error "xen/unaligned.h should not be included directly - include asm/unaligned.h instead" > -#endif > > #ifndef __XEN_UNALIGNED_H__ > #define __XEN_UNALIGNED_H__ > > +#ifndef __ASM_UNALIGNED_H__ > +#error "xen/unaligned.h should not be included directly - include asm/unaligned.h instead" > +#endif > + > #ifdef __XEN__ > #include <xen/types.h> > #include <asm/byteorder.h> > diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h > index b0f7632e89..7a61dea54a 100644 > --- 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) > +#if !defined(__XEN_VMAP_H__) > #define __XEN_VMAP_H__ > +#if defined(VMAP_VIRT_START) same here > #include <xen/mm-frame.h> > #include <xen/page-size.h> > @@ -38,4 +39,5 @@ static inline void vm_init(void) > vm_init_type(VMAP_DEFAULT, (void *)VMAP_VIRT_START, arch_vmap_virt_end()); > } > > +#endif /* VMAP_VIRT_START */ > #endif /* __XEN_VMAP_H__ */ > -- > 2.34.1 >
On 28.08.2023 15:20, Simone Ballarin wrote: > --- a/xen/include/xen/unaligned.h > +++ b/xen/include/xen/unaligned.h > @@ -3,13 +3,14 @@ > * without faulting, and at least reasonably efficiently. Other architectures > * will need to have a custom asm/unaligned.h. > */ > -#ifndef __ASM_UNALIGNED_H__ > -#error "xen/unaligned.h should not be included directly - include asm/unaligned.h instead" > -#endif > > #ifndef __XEN_UNALIGNED_H__ > #define __XEN_UNALIGNED_H__ > > +#ifndef __ASM_UNALIGNED_H__ > +#error "xen/unaligned.h should not be included directly - include asm/unaligned.h instead" > +#endif In addition to what Stefano said, this repositioning also is questionable (as per comments elsewhere). Overall it looks like the entire patch wants dropping? Or wait, no, the pci_ids.h change would remain. Jan
On 29/08/23 00:51, Stefano Stabellini wrote: > On Mon, 28 Aug 2023, Simone Ballarin wrote: >> Move or amended 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. >> >> Mechanical change. >> >> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com> >> --- >> xen/include/xen/err.h | 4 +++- >> xen/include/xen/pci_ids.h | 5 +++++ >> xen/include/xen/softirq.h | 4 +++- >> xen/include/xen/unaligned.h | 7 ++++--- >> xen/include/xen/vmap.h | 4 +++- >> 5 files changed, 18 insertions(+), 6 deletions(-) >> >> diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h >> index 2f29b57d28..a6323d82d7 100644 >> --- a/xen/include/xen/err.h >> +++ b/xen/include/xen/err.h >> @@ -1,5 +1,6 @@ >> -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) >> +#if !defined(__XEN_ERR_H__) >> #define __XEN_ERR_H__ >> +#if !defined(__ASSEMBLY__) > > The original pattern was also guarding the header file sufficiently, > protecting it from double-inclusion. In fact, it is posing stricter > restrictions than usual (not laxer). This change is unnecessary? The MISRA directive asks to use one of the two following forms: <start-of-file> #if !defined ( identifier ) #define identifier /* Contents of file */ #endif <end-of-file> <start-of-file> #ifndef identifier #define identifier /* Contents of file */ #endif <end-of-file> I do not see any reason for deviating, but if you ask that, I can do it. > > >> #include <xen/compiler.h> >> #include <xen/errno.h> >> @@ -54,4 +55,5 @@ static inline int __must_check PTR_RET(const void *ptr) >> return IS_ERR(ptr) ? PTR_ERR(ptr) : 0; >> } >> >> +#endif /* __ASSEMBLY__ */ >> #endif /* __XEN_ERR_H__ */ >> diff --git a/xen/include/xen/pci_ids.h b/xen/include/xen/pci_ids.h >> index e798477a7e..1a739d4c92 100644 >> --- a/xen/include/xen/pci_ids.h >> +++ b/xen/include/xen/pci_ids.h >> @@ -1,3 +1,6 @@ >> +#ifndef __XEN_PCI_IDS_H__ >> +#define __XEN_PCI_IDS_H__ >> + >> #define PCI_VENDOR_ID_AMD 0x1022 >> >> #define PCI_VENDOR_ID_NVIDIA 0x10de >> @@ -11,3 +14,5 @@ >> #define PCI_VENDOR_ID_BROADCOM 0x14e4 >> >> #define PCI_VENDOR_ID_INTEL 0x8086 >> + >> +#endif /* __XEN_PCI_IDS_H__ */ >> diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h >> index 33d6f2ecd2..092ec733b7 100644 >> --- a/xen/include/xen/softirq.h >> +++ b/xen/include/xen/softirq.h >> @@ -1,5 +1,6 @@ >> -#if !defined(__XEN_SOFTIRQ_H__) && !defined(__ASSEMBLY__) >> +#if !defined(__XEN_SOFTIRQ_H__) >> #define __XEN_SOFTIRQ_H__ >> +#if !defined(__ASSEMBLY__) > > same here > > >> /* 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 /* __ASSEMBLY__ */ >> #endif /* __XEN_SOFTIRQ_H__ */ >> diff --git a/xen/include/xen/unaligned.h b/xen/include/xen/unaligned.h >> index 0a2b16d05d..45f03b3f1b 100644 >> --- a/xen/include/xen/unaligned.h >> +++ b/xen/include/xen/unaligned.h >> @@ -3,13 +3,14 @@ >> * without faulting, and at least reasonably efficiently. Other architectures >> * will need to have a custom asm/unaligned.h. >> */ >> -#ifndef __ASM_UNALIGNED_H__ >> -#error "xen/unaligned.h should not be included directly - include asm/unaligned.h instead" >> -#endif >> >> #ifndef __XEN_UNALIGNED_H__ >> #define __XEN_UNALIGNED_H__ >> >> +#ifndef __ASM_UNALIGNED_H__ >> +#error "xen/unaligned.h should not be included directly - include asm/unaligned.h instead" >> +#endif >> + >> #ifdef __XEN__ >> #include <xen/types.h> >> #include <asm/byteorder.h> >> diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h >> index b0f7632e89..7a61dea54a 100644 >> --- 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) >> +#if !defined(__XEN_VMAP_H__) >> #define __XEN_VMAP_H__ >> +#if defined(VMAP_VIRT_START) > > same here > > >> #include <xen/mm-frame.h> >> #include <xen/page-size.h> >> @@ -38,4 +39,5 @@ static inline void vm_init(void) >> vm_init_type(VMAP_DEFAULT, (void *)VMAP_VIRT_START, arch_vmap_virt_end()); >> } >> >> +#endif /* VMAP_VIRT_START */ >> #endif /* __XEN_VMAP_H__ */ >> -- >> 2.34.1 >> >
On 31.08.2023 14:18, Simone Ballarin wrote: > On 29/08/23 00:51, Stefano Stabellini wrote: >> On Mon, 28 Aug 2023, Simone Ballarin wrote: >>> Move or amended 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. >>> >>> Mechanical change. >>> >>> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com> >>> --- >>> xen/include/xen/err.h | 4 +++- >>> xen/include/xen/pci_ids.h | 5 +++++ >>> xen/include/xen/softirq.h | 4 +++- >>> xen/include/xen/unaligned.h | 7 ++++--- >>> xen/include/xen/vmap.h | 4 +++- >>> 5 files changed, 18 insertions(+), 6 deletions(-) >>> >>> diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h >>> index 2f29b57d28..a6323d82d7 100644 >>> --- a/xen/include/xen/err.h >>> +++ b/xen/include/xen/err.h >>> @@ -1,5 +1,6 @@ >>> -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) >>> +#if !defined(__XEN_ERR_H__) >>> #define __XEN_ERR_H__ >>> +#if !defined(__ASSEMBLY__) >> >> The original pattern was also guarding the header file sufficiently, >> protecting it from double-inclusion. In fact, it is posing stricter >> restrictions than usual (not laxer). This change is unnecessary? > > The MISRA directive asks to use one of the two following forms: > > <start-of-file> > #if !defined ( identifier ) > #define identifier > /* Contents of file */ > #endif > <end-of-file> > > <start-of-file> > #ifndef identifier > #define identifier > /* Contents of file */ > #endif > <end-of-file> > > I do not see any reason for deviating, but if you ask that, I can do it. I do not see a reason why a deviation would be needed here. Misra shouldn't be more pedantic / restrictive than necessary to achieve its goals. Looking at the flood of changes we've already seen, pointless changes really shouldn't be asked for. Jan
On Thu, 31 Aug 2023, Simone Ballarin wrote: > On 29/08/23 00:51, Stefano Stabellini wrote: > > On Mon, 28 Aug 2023, Simone Ballarin wrote: > > > Move or amended 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. > > > > > > Mechanical change. > > > > > > Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com> > > > --- > > > xen/include/xen/err.h | 4 +++- > > > xen/include/xen/pci_ids.h | 5 +++++ > > > xen/include/xen/softirq.h | 4 +++- > > > xen/include/xen/unaligned.h | 7 ++++--- > > > xen/include/xen/vmap.h | 4 +++- > > > 5 files changed, 18 insertions(+), 6 deletions(-) > > > > > > diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h > > > index 2f29b57d28..a6323d82d7 100644 > > > --- a/xen/include/xen/err.h > > > +++ b/xen/include/xen/err.h > > > @@ -1,5 +1,6 @@ > > > -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) > > > +#if !defined(__XEN_ERR_H__) > > > #define __XEN_ERR_H__ > > > +#if !defined(__ASSEMBLY__) > > > > The original pattern was also guarding the header file sufficiently, > > protecting it from double-inclusion. In fact, it is posing stricter > > restrictions than usual (not laxer). This change is unnecessary? > > The MISRA directive asks to use one of the two following forms: > > <start-of-file> > #if !defined ( identifier ) > #define identifier > /* Contents of file */ > #endif > <end-of-file> > > <start-of-file> > #ifndef identifier > #define identifier > /* Contents of file */ > #endif > <end-of-file> > > I do not see any reason for deviating, but if you ask that, I can do it. Let's follow MISRA's form.
On 06.09.2023 00:27, Stefano Stabellini wrote: > On Thu, 31 Aug 2023, Simone Ballarin wrote: >> On 29/08/23 00:51, Stefano Stabellini wrote: >>> On Mon, 28 Aug 2023, Simone Ballarin wrote: >>>> Move or amended 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. >>>> >>>> Mechanical change. >>>> >>>> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com> >>>> --- >>>> xen/include/xen/err.h | 4 +++- >>>> xen/include/xen/pci_ids.h | 5 +++++ >>>> xen/include/xen/softirq.h | 4 +++- >>>> xen/include/xen/unaligned.h | 7 ++++--- >>>> xen/include/xen/vmap.h | 4 +++- >>>> 5 files changed, 18 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h >>>> index 2f29b57d28..a6323d82d7 100644 >>>> --- a/xen/include/xen/err.h >>>> +++ b/xen/include/xen/err.h >>>> @@ -1,5 +1,6 @@ >>>> -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) >>>> +#if !defined(__XEN_ERR_H__) >>>> #define __XEN_ERR_H__ >>>> +#if !defined(__ASSEMBLY__) >>> >>> The original pattern was also guarding the header file sufficiently, >>> protecting it from double-inclusion. In fact, it is posing stricter >>> restrictions than usual (not laxer). This change is unnecessary? >> >> The MISRA directive asks to use one of the two following forms: >> >> <start-of-file> >> #if !defined ( identifier ) >> #define identifier >> /* Contents of file */ >> #endif >> <end-of-file> >> >> <start-of-file> >> #ifndef identifier >> #define identifier >> /* Contents of file */ >> #endif >> <end-of-file> >> >> I do not see any reason for deviating, but if you ask that, I can do it. > > Let's follow MISRA's form. This is what I strongly dislike: They could be less restrictive on the exact patterns permitted without impacting the goal intended to be reached. But it's all as simple as possible, not as flexible as possible. In any event, if a transformation like what can still be seen in context is to be made, then please #ifdef / #ifndef instead of defined(...) whenever possible. Jan
On Wed, 6 Sep 2023, Jan Beulich wrote: > On 06.09.2023 00:27, Stefano Stabellini wrote: > > On Thu, 31 Aug 2023, Simone Ballarin wrote: > >> On 29/08/23 00:51, Stefano Stabellini wrote: > >>> On Mon, 28 Aug 2023, Simone Ballarin wrote: > >>>> Move or amended 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. > >>>> > >>>> Mechanical change. > >>>> > >>>> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com> > >>>> --- > >>>> xen/include/xen/err.h | 4 +++- > >>>> xen/include/xen/pci_ids.h | 5 +++++ > >>>> xen/include/xen/softirq.h | 4 +++- > >>>> xen/include/xen/unaligned.h | 7 ++++--- > >>>> xen/include/xen/vmap.h | 4 +++- > >>>> 5 files changed, 18 insertions(+), 6 deletions(-) > >>>> > >>>> diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h > >>>> index 2f29b57d28..a6323d82d7 100644 > >>>> --- a/xen/include/xen/err.h > >>>> +++ b/xen/include/xen/err.h > >>>> @@ -1,5 +1,6 @@ > >>>> -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) > >>>> +#if !defined(__XEN_ERR_H__) > >>>> #define __XEN_ERR_H__ > >>>> +#if !defined(__ASSEMBLY__) > >>> > >>> The original pattern was also guarding the header file sufficiently, > >>> protecting it from double-inclusion. In fact, it is posing stricter > >>> restrictions than usual (not laxer). This change is unnecessary? > >> > >> The MISRA directive asks to use one of the two following forms: > >> > >> <start-of-file> > >> #if !defined ( identifier ) > >> #define identifier > >> /* Contents of file */ > >> #endif > >> <end-of-file> > >> > >> <start-of-file> > >> #ifndef identifier > >> #define identifier > >> /* Contents of file */ > >> #endif > >> <end-of-file> > >> > >> I do not see any reason for deviating, but if you ask that, I can do it. > > > > Let's follow MISRA's form. > > This is what I strongly dislike: They could be less restrictive on the > exact patterns permitted without impacting the goal intended to be > reached. But it's all as simple as possible, not as flexible as possible. > > In any event, if a transformation like what can still be seen in context > is to be made, then please #ifdef / #ifndef instead of defined(...) > whenever possible. In all fairness I dislike this too. However the rule is clear that to make it easier to implement MISRA C checkers MISRA only supports 2 specific patterns. And I can see they have a point there in making it easier to automatically check for correctness. So I would go ahead with the change.
diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h index 2f29b57d28..a6323d82d7 100644 --- a/xen/include/xen/err.h +++ b/xen/include/xen/err.h @@ -1,5 +1,6 @@ -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) +#if !defined(__XEN_ERR_H__) #define __XEN_ERR_H__ +#if !defined(__ASSEMBLY__) #include <xen/compiler.h> #include <xen/errno.h> @@ -54,4 +55,5 @@ static inline int __must_check PTR_RET(const void *ptr) return IS_ERR(ptr) ? PTR_ERR(ptr) : 0; } +#endif /* __ASSEMBLY__ */ #endif /* __XEN_ERR_H__ */ diff --git a/xen/include/xen/pci_ids.h b/xen/include/xen/pci_ids.h index e798477a7e..1a739d4c92 100644 --- a/xen/include/xen/pci_ids.h +++ b/xen/include/xen/pci_ids.h @@ -1,3 +1,6 @@ +#ifndef __XEN_PCI_IDS_H__ +#define __XEN_PCI_IDS_H__ + #define PCI_VENDOR_ID_AMD 0x1022 #define PCI_VENDOR_ID_NVIDIA 0x10de @@ -11,3 +14,5 @@ #define PCI_VENDOR_ID_BROADCOM 0x14e4 #define PCI_VENDOR_ID_INTEL 0x8086 + +#endif /* __XEN_PCI_IDS_H__ */ diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h index 33d6f2ecd2..092ec733b7 100644 --- a/xen/include/xen/softirq.h +++ b/xen/include/xen/softirq.h @@ -1,5 +1,6 @@ -#if !defined(__XEN_SOFTIRQ_H__) && !defined(__ASSEMBLY__) +#if !defined(__XEN_SOFTIRQ_H__) #define __XEN_SOFTIRQ_H__ +#if !defined(__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 /* __ASSEMBLY__ */ #endif /* __XEN_SOFTIRQ_H__ */ diff --git a/xen/include/xen/unaligned.h b/xen/include/xen/unaligned.h index 0a2b16d05d..45f03b3f1b 100644 --- a/xen/include/xen/unaligned.h +++ b/xen/include/xen/unaligned.h @@ -3,13 +3,14 @@ * without faulting, and at least reasonably efficiently. Other architectures * will need to have a custom asm/unaligned.h. */ -#ifndef __ASM_UNALIGNED_H__ -#error "xen/unaligned.h should not be included directly - include asm/unaligned.h instead" -#endif #ifndef __XEN_UNALIGNED_H__ #define __XEN_UNALIGNED_H__ +#ifndef __ASM_UNALIGNED_H__ +#error "xen/unaligned.h should not be included directly - include asm/unaligned.h instead" +#endif + #ifdef __XEN__ #include <xen/types.h> #include <asm/byteorder.h> diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index b0f7632e89..7a61dea54a 100644 --- 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) +#if !defined(__XEN_VMAP_H__) #define __XEN_VMAP_H__ +#if defined(VMAP_VIRT_START) #include <xen/mm-frame.h> #include <xen/page-size.h> @@ -38,4 +39,5 @@ static inline void vm_init(void) vm_init_type(VMAP_DEFAULT, (void *)VMAP_VIRT_START, arch_vmap_virt_end()); } +#endif /* VMAP_VIRT_START */ #endif /* __XEN_VMAP_H__ */
Move or amended 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. Mechanical change. Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com> --- xen/include/xen/err.h | 4 +++- xen/include/xen/pci_ids.h | 5 +++++ xen/include/xen/softirq.h | 4 +++- xen/include/xen/unaligned.h | 7 ++++--- xen/include/xen/vmap.h | 4 +++- 5 files changed, 18 insertions(+), 6 deletions(-)