Message ID | 20e1d32d9e384f9682fc25d9a55480edd11e344e.1721720583.git.alessandro.zucchelli@bugseng.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | xen: address violation of MISRA C:2012 Directive 4.10 | expand |
On Tue, 23 Jul 2024, Alessandro Zucchelli wrote: > From: Simone Ballarin <simone.ballarin@bugseng.com> > > Amend generation script, add 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"). > > This patch amends the Makefile adding the required inclusion guards > for xlat.h. > > Add deviation comment for files intended for multiple inclusion. > > Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com> > Signed-off-by: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com> > Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com> > Signed-off-by: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
On 23.07.2024 10:15, Alessandro Zucchelli wrote: > --- a/xen/include/Makefile > +++ b/xen/include/Makefile > @@ -105,9 +105,14 @@ xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,^[?!][[:blank:]]+ > xlat-y := $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y)) > > quiet_cmd_xlat_h = GEN $@ > -cmd_xlat_h = \ > - cat $(filter %.h,$^) >$@.new; \ > +define cmd_xlat_h > + guard=$$(echo ASM__${SRCARCH}__COMPAT__XLAT_H | tr a-z A-Z); \ The generated living in xen/include/compat/xlat.h, I don't think this guard identifier is correct. Jan
diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 684346386e..6ede5c91c2 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -92,6 +92,14 @@ }, { "id": "SAF-11-safe", + "analyser": { + "eclair": "MC3R1.D4.10" + }, + "name": "Dir 4.10: file intended for multiple inclusion", + "text": "Files intended for multiple inclusion are not supposed to comply with D4.10." + }, + { + "id": "SAF-12-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/arch/x86/include/asm/compat.h b/xen/arch/x86/include/asm/compat.h index 818cad87db..98ed170b95 100644 --- a/xen/arch/x86/include/asm/compat.h +++ b/xen/arch/x86/include/asm/compat.h @@ -2,6 +2,9 @@ * compat.h */ +#ifndef ASM__X86__COMPAT_H +#define ASM__X86__COMPAT_H + #ifdef CONFIG_COMPAT #define COMPAT_BITS_PER_LONG 32 @@ -18,3 +21,5 @@ int switch_compat(struct domain *); #include <xen/errno.h> static inline int switch_compat(struct domain *d) { return -EOPNOTSUPP; } #endif + +#endif /* ASM__X86__COMPAT_H */ diff --git a/xen/arch/x86/include/asm/cpufeatures.h b/xen/arch/x86/include/asm/cpufeatures.h index ba3df174b7..d590fe31ea 100644 --- a/xen/arch/x86/include/asm/cpufeatures.h +++ b/xen/arch/x86/include/asm/cpufeatures.h @@ -1,7 +1,4 @@ -/* - * Explicitly intended for multiple inclusion. - */ - +/* SAF-11-safe file intended for multiple inclusion */ #include <xen/lib/x86/cpuid-autogen.h> /* Number of capability words covered by the featureset words. */ diff --git a/xen/arch/x86/include/asm/efibind.h b/xen/arch/x86/include/asm/efibind.h index bce02f3707..57c712748a 100644 --- a/xen/arch/x86/include/asm/efibind.h +++ b/xen/arch/x86/include/asm/efibind.h @@ -1,2 +1,7 @@ +#ifndef ASM__X86__EFIBIND_H +#define ASM__X86__EFIBIND_H + #include <xen/types.h> #include <asm/x86_64/efibind.h> + +#endif /* ASM__X86__EFIBIND_H */ diff --git a/xen/include/Makefile b/xen/include/Makefile index 058b0a566b..1ff9468eeb 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -105,9 +105,14 @@ xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,^[?!][[:blank:]]+ xlat-y := $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y)) quiet_cmd_xlat_h = GEN $@ -cmd_xlat_h = \ - cat $(filter %.h,$^) >$@.new; \ +define cmd_xlat_h + guard=$$(echo ASM__${SRCARCH}__COMPAT__XLAT_H | tr a-z A-Z); \ + echo "#ifndef $$guard" > $@.new; \ + echo "#define $$guard" >> $@.new; \ + cat $(filter %.h,$^) >> $@.new; \ + echo "#endif /* $$guard */" >> $@.new; \ mv -f $@.new $@ +endef $(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) FORCE $(call if_changed,xlat_h)