Message ID | 76caa62c49a7aa02e43892f9edd72d90e9f39243.1719829101.git.alessandro.zucchelli@bugseng.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xen: address violation of MISRA C:2012 Directive 4.10 | expand |
On 01.07.2024 15:36, Alessandro Zucchelli wrote: > --- 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 INCLUDE_XEN_ERR_H > +#define INCLUDE_XEN_ERR_H There once was a document (or was it a patch description) describing the naming system for these guards. Where did that go? With include files typically living under include/, seeing INCLUDE_ as a prefix is, well, odd and unnecessary baggage. I also don't recall there having been agreement to use names like the ones presented here. Jan > +#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 /* INCLUDE_XEN_ERR_H */ > diff --git a/xen/include/xen/pci_ids.h b/xen/include/xen/pci_ids.h > index e798477a7e..8e40c78db7 100644 > --- a/xen/include/xen/pci_ids.h > +++ b/xen/include/xen/pci_ids.h > @@ -1,3 +1,6 @@ > +#ifndef INCLUDE_XEN_PCI_IDS_H > +#define INCLUDE_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 /* INCLUDE_XEN_PCI_IDS_H */ > diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h > index 33d6f2ecd2..90d4875df7 100644 > --- 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 INCLUDE_XEN_SOFTIRQ_H > +#define 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 /* INCLUDE_XEN_SOFTIRQ_H */ > diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h > index 0c16baa85f..ec1b6b05e9 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) > -#define __XEN_VMAP_H__ > +#ifndef INCLUDE_XEN_VMAP_H > +#define 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 /* INCLUDE_XEN_VMAP_H */
On Wed, 3 Jul 2024, Jan Beulich wrote: > On 01.07.2024 15:36, Alessandro Zucchelli wrote: > > --- 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 INCLUDE_XEN_ERR_H > > +#define INCLUDE_XEN_ERR_H > > There once was a document (or was it a patch description) describing the > naming system for these guards. Where did that go? With include files > typically living under include/, seeing INCLUDE_ as a prefix is, well, > odd and unnecessary baggage. I also don't recall there having been > agreement to use names like the ones presented here. I agree with Jan that INCLUDE_ is unnecessary and looking at patch #0 and our previous discussions it would seem that this case was not covered. I think we should just use XEN_ERR_H The rule could be (to be added to the others in patch #0): - xen/include/xen -> XEN_<filename>_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 /* INCLUDE_XEN_ERR_H */ > > diff --git a/xen/include/xen/pci_ids.h b/xen/include/xen/pci_ids.h > > index e798477a7e..8e40c78db7 100644 > > --- a/xen/include/xen/pci_ids.h > > +++ b/xen/include/xen/pci_ids.h > > @@ -1,3 +1,6 @@ > > +#ifndef INCLUDE_XEN_PCI_IDS_H > > +#define INCLUDE_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 /* INCLUDE_XEN_PCI_IDS_H */ > > diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h > > index 33d6f2ecd2..90d4875df7 100644 > > --- 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 INCLUDE_XEN_SOFTIRQ_H > > +#define 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 /* INCLUDE_XEN_SOFTIRQ_H */ > > diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h > > index 0c16baa85f..ec1b6b05e9 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) > > -#define __XEN_VMAP_H__ > > +#ifndef INCLUDE_XEN_VMAP_H > > +#define 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 /* INCLUDE_XEN_VMAP_H */ > >
diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h index cbdd1bf7f8..65549caac2 100644 --- 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 INCLUDE_XEN_ERR_H +#define 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 /* INCLUDE_XEN_ERR_H */ diff --git a/xen/include/xen/pci_ids.h b/xen/include/xen/pci_ids.h index e798477a7e..8e40c78db7 100644 --- a/xen/include/xen/pci_ids.h +++ b/xen/include/xen/pci_ids.h @@ -1,3 +1,6 @@ +#ifndef INCLUDE_XEN_PCI_IDS_H +#define INCLUDE_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 /* INCLUDE_XEN_PCI_IDS_H */ diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h index 33d6f2ecd2..90d4875df7 100644 --- 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 INCLUDE_XEN_SOFTIRQ_H +#define 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 /* INCLUDE_XEN_SOFTIRQ_H */ diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index 0c16baa85f..ec1b6b05e9 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) -#define __XEN_VMAP_H__ +#ifndef INCLUDE_XEN_VMAP_H +#define 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 /* INCLUDE_XEN_VMAP_H */