From patchwork Mon Mar 11 08:59:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simone Ballarin X-Patchwork-Id: 13588378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D52E8C54E68 for ; Mon, 11 Mar 2024 09:00:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.691271.1077114 (Exim 4.92) (envelope-from ) id 1rjbW9-000081-0f; Mon, 11 Mar 2024 09:00:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 691271.1077114; Mon, 11 Mar 2024 09:00:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rjbW8-0008U8-Dc; Mon, 11 Mar 2024 09:00:20 +0000 Received: by outflank-mailman (input) for mailman id 691271; Mon, 11 Mar 2024 09:00:18 +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 1rjbW6-0006j9-0j for xen-devel@lists.xenproject.org; Mon, 11 Mar 2024 09:00:18 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c7593b5a-df85-11ee-a1ee-f123f15fe8a2; Mon, 11 Mar 2024 10:00:16 +0100 (CET) Received: from beta.station (net-93-144-106-196.cust.vodafonedsl.it [93.144.106.196]) by support.bugseng.com (Postfix) with ESMTPSA id B42534EE0C90; Mon, 11 Mar 2024 10:00:15 +0100 (CET) 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: c7593b5a-df85-11ee-a1ee-f123f15fe8a2 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu , =?utf-8?q?Roger_Pau_Mo?= =?utf-8?q?nn=C3=A9?= , Maria Celeste Cesario Subject: [XEN PATCH v3 10/16] x86/asm: address violations of MISRA C:2012 Directive 4.10 Date: Mon, 11 Mar 2024 09:59:19 +0100 Message-Id: <1e44047e767431c32621ae44d3121bc2152b3cb5.1710145041.git.simone.ballarin@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 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 --- 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 | 10 ++++++++-- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 363c9e21b0..13208d18ec 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -52,6 +52,14 @@ }, { "id": "SAF-6-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-7-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..36e7750843 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 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 c3aad21c3b..a65754d553 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-6-safe file intended for multiple inclusion */ #include /* 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..75684742be 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 a77c9ffb7e..e777921eb1 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -104,10 +104,16 @@ $(obj)/compat/.xlat/%.lst: $(srcdir)/xlat.lst FORCE xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,^[?!][[:blank:]]+[^[:blank:]]+[[:blank:]]+,,p' $(srcdir)/xlat.lst | uniq) xlat-y := $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y)) +ARCHDIR = $(shell echo $(SRCARCH) | tr a-z A-Z) + quiet_cmd_xlat_h = GEN $@ -cmd_xlat_h = \ - cat $(filter %.h,$^) >$@.new; \ +define cmd_xlat_h + echo "#ifndef ASM_$(ARCHDIR)_COMPAT_XLAT_H" > $@.new; \ + echo "#define ASM_$(ARCHDIR)_COMPAT_XLAT_H" >> $@.new; \ + cat $(filter %.h,$^) >> $@.new; \ + echo "#endif /* ASM_$(ARCHDIR)_COMPAT_XLAT_H */" >> $@.new; \ mv -f $@.new $@ +endef $(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) FORCE $(call if_changed,xlat_h)