From patchwork Tue Jul 23 08:14:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zucchelli X-Patchwork-Id: 13739679 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 CF1A0C3DA63 for ; Tue, 23 Jul 2024 08:15:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.762681.1172930 (Exim 4.92) (envelope-from ) id 1sWAgX-0000rZ-IZ; Tue, 23 Jul 2024 08:15:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 762681.1172930; Tue, 23 Jul 2024 08:15:49 +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-0000rP-Es; Tue, 23 Jul 2024 08:15:49 +0000 Received: by outflank-mailman (input) for mailman id 762681; Tue, 23 Jul 2024 08:15:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sWAgV-0008AN-E6 for xen-devel@lists.xenproject.org; Tue, 23 Jul 2024 08:15:47 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c37ed557-48cb-11ef-bbfe-fd08da9f4363; Tue, 23 Jul 2024 10:15:46 +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 0A11F4EE073F; Tue, 23 Jul 2024 10:15:44 +0200 (CEST) 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: c37ed557-48cb-11ef-bbfe-fd08da9f4363 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Simone Ballarin , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alessandro Zucchelli Subject: [XEN PATCH v5 05/17] xen/x86: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 23 Jul 2024 10:14:57 +0200 Message-Id: <4395577d2a07f6edaebbef937cb96028bb92de31.1721720583.git.alessandro.zucchelli@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Simone Ballarin Add or move 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). Mechanical change. Signed-off-by: Simone Ballarin Signed-off-by: Maria Celeste Cesario Signed-off-by: Nicola Vetrini Signed-off-by: Alessandro Zucchelli Acked-by: Jan Beulich --- Changes in v5: - remove hard tab that slipped in the makefile - edit inclusion guards and makefile Changes in v4: - modified inclusion guards and makefile. Changes in v3: - remove trailing underscores - change inclusion guard name to adhere to the new standard Changes in v2: - remove extra blanks - drop changes in C files Note: Changes in Makefile were not strictly necessary in v1 and a maintainer asked to removing them since there was a deviation for generated headers. Now, in v2, they are required since the deviation has been removed by another patch of this series. --- xen/arch/x86/Makefile | 9 +++++---- xen/arch/x86/cpu/cpu.h | 5 +++++ xen/arch/x86/x86_64/mmconfig.h | 5 +++++ xen/arch/x86/x86_emulate/private.h | 5 +++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index d902fb7acc..31197dfd96 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -260,17 +260,18 @@ $(objtree)/arch/x86/include/asm/asm-macros.h: $(obj)/asm-macros.i $(src)/Makefil $(call filechk,asm-macros.h) define filechk_asm-macros.h + guard=$$(echo ASM__${SRCARCH}__ASM_MACROS_H | tr a-z A-Z); \ + echo '#ifndef $$guard'; \ + echo '#define $$guard'; \ echo '#if 0'; \ echo '.if 0'; \ echo '#endif'; \ - echo '#ifndef __ASM_MACROS_H__'; \ - echo '#define __ASM_MACROS_H__'; \ echo 'asm ( ".include \"$@\"" );'; \ - echo '#endif /* __ASM_MACROS_H__ */'; \ echo '#if 0'; \ echo '.endif'; \ cat $<; \ - echo '#endif' + echo '#endif'; \ + echo '#endif /* $$guard */' endef $(obj)/efi.lds: AFLAGS-y += -DEFI diff --git a/xen/arch/x86/cpu/cpu.h b/xen/arch/x86/cpu/cpu.h index 8be65e975a..8e52f24e10 100644 --- a/xen/arch/x86/cpu/cpu.h +++ b/xen/arch/x86/cpu/cpu.h @@ -1,3 +1,6 @@ +#ifndef X86__CPU__CPU_H +#define X86__CPU__CPU_H + /* attempt to consolidate cpu attributes */ struct cpu_dev { void (*c_early_init)(struct cpuinfo_x86 *c); @@ -26,3 +29,5 @@ void amd_init_spectral_chicken(void); void detect_zen2_null_seg_behaviour(void); void intel_unlock_cpuid_leaves(struct cpuinfo_x86 *c); + +#endif /* X86__CPU__CPU_H */ diff --git a/xen/arch/x86/x86_64/mmconfig.h b/xen/arch/x86/x86_64/mmconfig.h index 3da4b21e9b..0b51d2179e 100644 --- a/xen/arch/x86/x86_64/mmconfig.h +++ b/xen/arch/x86/x86_64/mmconfig.h @@ -5,6 +5,9 @@ * Author: Allen Kay - adapted from linux */ +#ifndef X86__X86_64__MMCONFIG_H +#define X86__X86_64__MMCONFIG_H + #define PCI_DEVICE_ID_INTEL_E7520_MCH 0x3590 #define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 @@ -72,3 +75,5 @@ int pci_mmcfg_reserved(uint64_t address, unsigned int segment, int pci_mmcfg_arch_init(void); int pci_mmcfg_arch_enable(unsigned int idx); void pci_mmcfg_arch_disable(unsigned int idx); + +#endif /* X86__X86_64__MMCONFIG_H */ diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h index 0fa26ba00a..940d511b06 100644 --- a/xen/arch/x86/x86_emulate/private.h +++ b/xen/arch/x86/x86_emulate/private.h @@ -6,6 +6,9 @@ * Copyright (c) 2005-2007 XenSource Inc. */ +#ifndef X86__X86_EMULATE__PRIVATE_H +#define X86__X86_EMULATE__PRIVATE_H + #ifdef __XEN__ # include @@ -836,3 +839,5 @@ static inline int read_ulong(enum x86_segment seg, *val = 0; return ops->read(seg, offset, val, bytes, ctxt); } + +#endif /* X86__X86_EMULATE__PRIVATE_H */