From nobody Fri Sep 20 23:51:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1721722594137663.5618262304367; Tue, 23 Jul 2024 01:16:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.762713.1172980 (Exim 4.92) (envelope-from ) id 1sWAgy-0003y6-0S; Tue, 23 Jul 2024 08:16:16 +0000 Received: by outflank-mailman (output) from mailman id 762713.1172980; Tue, 23 Jul 2024 08:16:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sWAgx-0003xz-Sz; Tue, 23 Jul 2024 08:16:15 +0000 Received: by outflank-mailman (input) for mailman id 762713; Tue, 23 Jul 2024 08:16:15 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sWAgh-0007w0-A0 for xen-devel@lists.xenproject.org; Tue, 23 Jul 2024 08:15:59 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c9ca172c-48cb-11ef-8776-851b0ebba9a2; Tue, 23 Jul 2024 10:15:57 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-79-35-51-193.retail.telecomitalia.it [79.35.51.193]) by support.bugseng.com (Postfix) with ESMTPSA id 73C734EE0745; Tue, 23 Jul 2024 10:15:55 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c9ca172c-48cb-11ef-8776-851b0ebba9a2 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Simone Ballarin , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , "Daniel P. Smith" , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Alessandro Zucchelli Subject: [XEN PATCH v5 10/17] x86/asm: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 23 Jul 2024 10:15:02 +0200 Message-Id: <20e1d32d9e384f9682fc25d9a55480edd11e344e.1721720583.git.alessandro.zucchelli@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1721722595374116600 Content-Type: text/plain; charset="utf-8" From: Simone Ballarin 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 Signed-off-by: Maria Celeste Cesario Signed-off-by: Nicola Vetrini Signed-off-by: Alessandro Zucchelli Reviewed-by: Stefano Stabellini --- Changes in v5: - rebase against current staging tree - remove an unused path in Makefile that was mistakenly left in - edit inclusion guards, according to feedback received Changes in v4: - changed guard creation for autogenerated headers in Makefile Changes in v3: - fix inconsistent deviation ID - remove trailing underscores Changes in v2: - merge patches 7/13 and 13/13 of v1 as they had the same commit message - amend the Makefile to produce the required inclusion guard - use the format introduced with doc/misra/safe.json instead of a generic text-based deviation --- docs/misra/safe.json | 8 ++++++++ xen/arch/x86/include/asm/compat.h | 5 +++++ xen/arch/x86/include/asm/cpufeatures.h | 5 +---- xen/arch/x86/include/asm/efibind.h | 5 +++++ xen/include/Makefile | 9 +++++++-- 5 files changed, 26 insertions(+), 6 deletions(-) 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 suppose= d 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/c= ompat.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 */ =20 +#ifndef ASM__X86__COMPAT_H +#define ASM__X86__COMPAT_H + #ifdef CONFIG_COMPAT =20 #define COMPAT_BITS_PER_LONG 32 @@ -18,3 +21,5 @@ int switch_compat(struct domain *); #include 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 =20 /* 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 #include + +#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 :=3D $(shell sed -ne 's,@arch@,$(compat-arch-y)= ,g' -re 's,^[?!][[:blank:]]+ xlat-y :=3D $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y)) =20 quiet_cmd_xlat_h =3D GEN $@ -cmd_xlat_h =3D \ - cat $(filter %.h,$^) >$@.new; \ +define cmd_xlat_h + guard=3D$$(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 =20 $(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) FORCE $(call if_changed,xlat_h) --=20 2.34.1