From nobody Mon May 13 16:30:52 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; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690531980651941.6958572071994; Fri, 28 Jul 2023 01:13:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.571372.895044 (Exim 4.92) (envelope-from ) id 1qPIZv-0004Pb-JM; Fri, 28 Jul 2023 08:12:03 +0000 Received: by outflank-mailman (output) from mailman id 571372.895044; Fri, 28 Jul 2023 08:12:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qPIZv-0004PU-Go; Fri, 28 Jul 2023 08:12:03 +0000 Received: by outflank-mailman (input) for mailman id 571372; Fri, 28 Jul 2023 08:12:02 +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 1qPIZu-0004AY-CM for xen-devel@lists.xenproject.org; Fri, 28 Jul 2023 08:12:02 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 6cd904e3-2d1e-11ee-b24d-6b7b168915f2; Fri, 28 Jul 2023 10:11:59 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14C43D75; Fri, 28 Jul 2023 01:12:42 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9DD3F3F67D; Fri, 28 Jul 2023 01:11:57 -0700 (PDT) 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: 6cd904e3-2d1e-11ee-b24d-6b7b168915f2 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 1/5] [WIP]misra: add entries to the excluded list Date: Fri, 28 Jul 2023 09:11:40 +0100 Message-Id: <20230728081144.4124309-2-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230728081144.4124309-1-luca.fancellu@arm.com> References: <20230728081144.4124309-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1690531981677100001 Content-Type: text/plain; charset="utf-8" Add entries to the exclusion list, so that they can be excluded from the formatter tool. TBD: add a field on each entry to understand for what tool is the exclusion Signed-off-by: Luca Fancellu --- docs/misra/exclude-list.json | 88 ++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/docs/misra/exclude-list.json b/docs/misra/exclude-list.json index ca1e2dd678ff..c103c69209c9 100644 --- a/docs/misra/exclude-list.json +++ b/docs/misra/exclude-list.json @@ -1,6 +1,10 @@ { "version": "1.0", "content": [ + { + "rel_path": "arch/arm/arm32/lib/assembler.h", + "comment": "Includes mostly assembly macro and it's meant to b= e included only in assembly code" + }, { "rel_path": "arch/arm/arm64/cpufeature.c", "comment": "Imported from Linux, ignore for now" @@ -13,6 +17,26 @@ "rel_path": "arch/arm/arm64/lib/find_next_bit.c", "comment": "Imported from Linux, ignore for now" }, + { + "rel_path": "arch/arm/include/asm/arm32/macros.h", + "comment": "Includes only assembly macro" + }, + { + "rel_path": "arch/arm/include/asm/arm64/macros.h", + "comment": "Includes only assembly macro" + }, + { + "rel_path": "arch/arm/include/asm/alternative.h", + "comment": "Imported from Linux, ignore for now" + }, + { + "rel_path": "arch/arm/include/asm/asm_defns.h", + "comment": "Includes mostly assembly macro" + }, + { + "rel_path": "arch/arm/include/asm/macros.h", + "comment": "Includes mostly assembly macro and it's meant to b= e included only in assembly code" + }, { "rel_path": "arch/x86/acpi/boot.c", "comment": "Imported from Linux, ignore for now" @@ -69,6 +93,30 @@ "rel_path": "arch/x86/cpu/mwait-idle.c", "comment": "Imported from Linux, ignore for now" }, + { + "rel_path": "arch/x86/include/asm/alternative-asm.h", + "comment": "Includes mostly assembly macro and it's meant to b= e included only in assembly code" + }, + { + "rel_path": "arch/x86/include/asm/asm_defns.h", + "comment": "Includes mostly assembly macro" + }, + { + "rel_path": "arch/x86/include/asm/asm-defns.h", + "comment": "Includes mostly assembly macro" + }, + { + "rel_path": "arch/x86/include/asm/bug.h", + "comment": "Includes mostly assembly macro" + }, + { + "rel_path": "arch/x86/include/asm/mpspec.h", + "comment": "Imported from Linux, also case ranges are not hand= led by clang-format, ignore for now" + }, + { + "rel_path": "arch/x86/include/asm/spec_ctrl_asm.h", + "comment": "Includes mostly assembly macro" + }, { "rel_path": "arch/x86/delay.c", "comment": "Imported from Linux, ignore for now" @@ -181,6 +229,42 @@ "rel_path": "drivers/video/font_*", "comment": "Imported from Linux, ignore for now" }, + { + "rel_path": "include/efi/*.h", + "comment": "Imported from gnu-efi-3.0k" + }, + { + "rel_path": "include/public/arch-x86/cpufeatureset.h", + "comment": "This file contains some inputs for the gen-cpuid.p= y script, leave it out" + }, + { + "rel_path": "include/public/**/**/*.h", + "comment": "Public headers are quite sensitive to format tools" + }, + { + "rel_path": "include/public/**/*.h", + "comment": "Public headers are quite sensitive to format tools" + }, + { + "rel_path": "include/public/*.h", + "comment": "Public headers are quite sensitive to format tools" + }, + { + "rel_path": "include/xen/cper.h", + "comment": "Header does not follow Xen coding style" + }, + { + "rel_path": "include/xen/nodemask.h", + "comment": "Imported from Linux, also case ranges are not hand= led by clang-format, ignore for now" + }, + { + "rel_path": "include/xen/xen.lds.h", + "comment": "This file contains only macros used inside the lin= ker script" + }, + { + "rel_path": "include/hypercall-defs.c", + "comment": "This file contains only C preprocessing syntax, th= e other lines are not C and are used to generate the hypercall definition b= y another script." + }, { "rel_path": "lib/list-sort.c", "comment": "Imported from Linux, ignore for now" @@ -193,6 +277,10 @@ "rel_path": "lib/xxhash*.c", "comment": "Imported from Linux, ignore for now" }, + { + "rel_path": "tools/*", + "comment": "Contains host tools imported from Linux, ignore fo= r now" + }, { "rel_path": "xsm/flask/*", "comment": "Not in scope initially as it generates many violat= ions and it is not enabled in safety configurations" --=20 2.34.1 From nobody Mon May 13 16:30:52 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; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690531944464901.8859518455982; Fri, 28 Jul 2023 01:12:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.571373.895050 (Exim 4.92) (envelope-from ) id 1qPIZv-0004T1-Te; Fri, 28 Jul 2023 08:12:03 +0000 Received: by outflank-mailman (output) from mailman id 571373.895050; Fri, 28 Jul 2023 08:12:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qPIZv-0004Sq-PJ; Fri, 28 Jul 2023 08:12:03 +0000 Received: by outflank-mailman (input) for mailman id 571373; Fri, 28 Jul 2023 08:12:02 +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 1qPIZu-0004AS-CL for xen-devel@lists.xenproject.org; Fri, 28 Jul 2023 08:12:02 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 6d49fda0-2d1e-11ee-8613-37d641c3527e; Fri, 28 Jul 2023 10:12:00 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E5AC81515; Fri, 28 Jul 2023 01:12:42 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3960D3F67D; Fri, 28 Jul 2023 01:11:59 -0700 (PDT) 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: 6d49fda0-2d1e-11ee-8613-37d641c3527e From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com Subject: [RFC PATCH 2/5] [WIP]cppcheck: rework exclusion_file_list.py code Date: Fri, 28 Jul 2023 09:11:41 +0100 Message-Id: <20230728081144.4124309-3-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230728081144.4124309-1-luca.fancellu@arm.com> References: <20230728081144.4124309-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1690531946194100003 Content-Type: text/plain; charset="utf-8" Rework the exclusion_file_list.py code to have the function load_exclusion_file_list() detached from the xen-analysis.py tool, in a way so that other modules can use the function. The xen-analysis tool and in particular its module cppcheck_analysis.py will use a new function cppcheck_exclusion_file_list(). No functional changes are intended. TBD: Read the field in each entry and act accordingly. Signed-off-by: Luca Fancellu --- xen/scripts/xen_analysis/cppcheck_analysis.py | 6 ++-- .../xen_analysis/exclusion_file_list.py | 31 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xe= n_analysis/cppcheck_analysis.py index 8dc45e653b79..e54848aa5339 100644 --- a/xen/scripts/xen_analysis/cppcheck_analysis.py +++ b/xen/scripts/xen_analysis/cppcheck_analysis.py @@ -2,7 +2,8 @@ =20 import os, re, shutil from . import settings, utils, cppcheck_report_utils, exclusion_file_list -from .exclusion_file_list import ExclusionFileListError +from .exclusion_file_list import (ExclusionFileListError, + cppcheck_exclusion_file_list) =20 class GetMakeVarsPhaseError(Exception): pass @@ -54,8 +55,7 @@ def __generate_suppression_list(out_file): try: exclusion_file =3D \ "{}/docs/misra/exclude-list.json".format(settings.repo= _dir) - exclusion_list =3D \ - exclusion_file_list.load_exclusion_file_list(exclusion= _file) + exclusion_list =3D cppcheck_exclusion_file_list(exclusion_= file) except ExclusionFileListError as e: raise CppcheckDepsPhaseError( "Issue with reading file {}: {}".format(exclusion_file= , e) diff --git a/xen/scripts/xen_analysis/exclusion_file_list.py b/xen/scripts/= xen_analysis/exclusion_file_list.py index 871e480586bb..79ebd34f55ec 100644 --- a/xen/scripts/xen_analysis/exclusion_file_list.py +++ b/xen/scripts/xen_analysis/exclusion_file_list.py @@ -7,16 +7,24 @@ class ExclusionFileListError(Exception): pass =20 =20 -def __cppcheck_path_exclude_syntax(path): - # Prepending * to the relative path to match every path where the Xen - # codebase could be - path =3D "*" + path +def cppcheck_exclusion_file_list(input_file): + ret =3D [] + excl_list =3D load_exclusion_file_list(input_file) + + for entry in excl_list: + # Prepending * to the relative path to match every path where the = Xen + # codebase could be + ret.append("*" + entry[0]) =20 - return path + return ret =20 =20 -# Reads the exclusion file list and returns a list of relative path to be -# excluded. +# Reads the exclusion file list and returns an array containing a set wher= e the +# first entry is what was listed in the exclusion list file, and the second +# entry is the absolute path of the first entry. +# If the first entry contained a wildcard '*', the second entry will have = an +# array of the solved absolute path for that entry. +# Returns [('path',[path,path,...]), ('path',[path,path,...]), ...] def load_exclusion_file_list(input_file): ret =3D [] try: @@ -58,13 +66,6 @@ def load_exclusion_file_list(input_file): .format(path, filepath_object) ) =20 - if settings.analysis_tool =3D=3D "cppcheck": - path =3D __cppcheck_path_exclude_syntax(path) - else: - raise ExclusionFileListError( - "Unimplemented for {}!".format(settings.analysis_tool) - ) - - ret.append(path) + ret.append((path, check_path)) =20 return ret --=20 2.34.1 From nobody Mon May 13 16:30:52 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; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690531980819686.7655749996549; Fri, 28 Jul 2023 01:13:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.571374.895065 (Exim 4.92) (envelope-from ) id 1qPIZx-0004tR-85; Fri, 28 Jul 2023 08:12:05 +0000 Received: by outflank-mailman (output) from mailman id 571374.895065; Fri, 28 Jul 2023 08:12:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qPIZx-0004sQ-2J; Fri, 28 Jul 2023 08:12:05 +0000 Received: by outflank-mailman (input) for mailman id 571374; Fri, 28 Jul 2023 08:12:03 +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 1qPIZv-0004AY-8m for xen-devel@lists.xenproject.org; Fri, 28 Jul 2023 08:12:03 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 6e6e9f40-2d1e-11ee-b24d-6b7b168915f2; Fri, 28 Jul 2023 10:12:02 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9F8581516; Fri, 28 Jul 2023 01:12:44 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 180D23F67D; Fri, 28 Jul 2023 01:11:59 -0700 (PDT) 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: 6e6e9f40-2d1e-11ee-b24d-6b7b168915f2 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 3/5] [WIP]xen/scripts: add codestyle.py script Date: Fri, 28 Jul 2023 09:11:42 +0100 Message-Id: <20230728081144.4124309-4-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230728081144.4124309-1-luca.fancellu@arm.com> References: <20230728081144.4124309-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1690531981886100003 Content-Type: text/plain; charset="utf-8" This script finds every .c and .h file in the xen hypervisor codebase, takes the exclusion list from docs/misra, removes the file excluded from the list and for the remaining files is calling clang-format on them. TBD: write it better Signed-off-by: Luca Fancellu --- xen/scripts/codestyle.py | 261 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100755 xen/scripts/codestyle.py diff --git a/xen/scripts/codestyle.py b/xen/scripts/codestyle.py new file mode 100755 index 000000000000..5bba004d814b --- /dev/null +++ b/xen/scripts/codestyle.py @@ -0,0 +1,261 @@ +#!/usr/bin/env python3 + +import glob +import os +import re +import sys +from xen_analysis.settings import xen_dir, repo_dir +from xen_analysis import utils +from xen_analysis import exclusion_file_list +from xen_analysis.exclusion_file_list import ExclusionFileListError + +# The Xen codestyle states that labels needs to be indented by at least one +# blank, but clang-format doesn't have an option for that and if it encoun= ters +# a label indented by blank characters that are less than its indent +# configuration, it removes the indentation. +# So this action is meant as post step and checks every label syntax match= and +# it adds one blank before the label +def action_fix_label_indent(filename, file_lines): + label_rgx =3D re.compile('^[a-zA-Z_][a-zA-Z0-9_]*\s*:.*$') + + for i in range(0, len(file_lines)): + if label_rgx.match(file_lines[i]): + file_lines[i] =3D ' ' + file_lines[i] + + return file_lines + + +# clang-format most of the time breaks the content of asm(...) instruction= s, +# so with this function, we protect all the asm sections using the special +# in code comments that tells clang-format to don't touch the block. +# asm(...) instruction could be also inside macros, so in that case we pro= tect +# the entire macro that is enclosing the instruction, in the un-protect st= age +# however, we need to do clang-format's job at least on the tab-space conv= ersion +# and to put the backslash on the right side. +def action_protect_asm(filename, file_lines, protect): + opening_asm =3D False + cf_off_comment =3D '/* clang-format off */' + cf_on_comment =3D '/* clang-format on */' + asm_stx =3D '(?:asm|__asm__)(?:\s(?:volatile|__volatile__))?' + + if protect: + # Look for closing parenthesis with semicolon ');' + closing_asm_rgx_rule =3D '^.*\);.*$' + # Look for opening asm syntax + opening_asm_rgx_rule =3D f'^\s*{asm_stx}\s?\(.*$' + macro_start_rgx_rule =3D r'^\s?#\s?define.*\\$' + opening_asm_find =3D r'(asm|__asm__)' + opening_asm_replace =3D cf_off_comment + r'\1' + opening_def_find =3D r'#\s?define' + opening_def_replace =3D f'{cf_off_comment}#define' + closing_asm_find =3D r'\);' + closing_asm_replace =3D ');' + cf_on_comment + closing_def_find =3D '\n' + closing_def_replace =3D cf_on_comment + '\n' + else: + # Look for closing parenthesis with semicolon ');' and with the + # special clang-format comment + closing_asm_rgx_rule =3D f'^.*\);.*{re.escape(cf_on_comment)}.*$' + # Look for opening asm syntax preceded by the special clang-format + # comment, the comment is optional to generalise the algorithm to + # un-protect asm outside and inside macros. The case outside is ea= sy + # because we will find '/* clang-format off */asm', instead the ca= se + # inside is more tricky and we are going to find only 'asm' and th= en + # go backwards until we find '/* clang-format off */#define' + opening_asm_rgx_rule =3D \ + f'^\s*({re.escape(cf_off_comment)})?{asm_stx}\s?\(.*$' + # Look for the define just before the asm invocation, here we look= for + # '/* clang-format off */#define' or '#define', this is to handle = a rare + # corner case where an asm invocation is inside a macro, but was n= ot + # protected in the 'protect stage', because it was on the same line + # of the define and was not ending with backslash but it was excee= ding + # line width so clang-format formatted anyway. + # It's safe because we won't change code that has no clang-format + # comments, but at least the tool won't complain + macro_start_rgx_rule =3D \ + rf'^\s?(?:{re.escape(cf_off_comment)})?#\s?define.*\\$' + opening_asm_find =3D rf'({re.escape(cf_off_comment)}(asm|__asm__))' + opening_asm_replace =3D r'\2' + opening_def_find =3D rf'(?:{re.escape(cf_off_comment)})?#\s?define' + opening_def_replace =3D '#define' + closing_asm_find =3D rf'\);.*{re.escape(cf_on_comment)}' + closing_asm_replace =3D ');' + closing_def_find =3D cf_on_comment + '\n' + closing_def_replace =3D '\n' + + opening_asm_rgx =3D re.compile(opening_asm_rgx_rule) + closing_asm_rgx =3D re.compile(closing_asm_rgx_rule) + macro_start_rgx =3D re.compile(macro_start_rgx_rule) + + i =3D 0 + i_max =3D len(file_lines) + macro_begin =3D -1 + while i < i_max: + # Keep track of the last define we found + if macro_start_rgx.match(file_lines[i]): + macro_begin =3D i + # Try to find in the current line the asm syntax opening, but don't + # touch asm syntax inside macros that usually have the line ended = by + # a backslash, this is because insert stuff in them will have issu= es + # when later clang-format will format the macro itself + if (not opening_asm) and opening_asm_rgx.match(file_lines[i]): + line_before =3D (i > 0) and file_lines[i-1].endswith('\\\n') + if file_lines[i].endswith('\\\n') or line_before: + # This should never happen, but if it does, it means an + # unexpected syntax is found in the file + if macro_begin < 0: + raise Exception("Begin of macro not found in {}\n" + "The asm invocation is on line {}" + .format(filename, i)) + + # asm invocation inside macro, need to protect the entire = macro, + # macro_begin should point to this define + file_lines[macro_begin] =3D re.sub(opening_def_find, + opening_def_replace, + file_lines[macro_begin]) + + # now go to the end of the macro, it's easy as the first l= ine + # without a backslash will be the end + for j in range(i, len(file_lines)): + if not file_lines[j].endswith('\\\n'): + file_lines[j] =3D \ + file_lines[j].replace(closing_def_find, + closing_def_replace, 1) + # Advance i index, as j is the last line checked + i =3D j + break + + # In the un-protect stage, we need to do clang-format's jo= b, + # so convert tabs to 4 spaces and for macros put the backs= lash + # at the end of the line + if not protect: + for j in range(macro_begin, i+1): + # Tab replacement + file_lines[j] =3D file_lines[j].replace('\t', ' = ') + # backslash indentation + line_len =3D len(file_lines[j]) + # 81 counting also the newline character + if file_lines[j].endswith('\\\n') and line_len < 8= 1: + spaces =3D ' ' * (81 - line_len) + file_lines[j] =3D \ + file_lines[j].replace('\\\n', spaces + '\\= \n', + 1) + + macro_begin =3D -1 + else: + # asm invocation is not inside a macro, protect the asm sy= ntax + opening_asm =3D True + file_lines[i] =3D re.sub(opening_asm_find, opening_asm_rep= lace, + file_lines[i]) + + # Try to find in the current line the asm closing syntax, only if a + # previous line already found an opening asm syntax + if opening_asm and closing_asm_rgx.match(file_lines[i]): + opening_asm =3D False + file_lines[i] =3D re.sub(closing_asm_find, closing_asm_replace, + file_lines[i]) + + i +=3D 1 + + # This should never happen, but if it does, it means an unexpected syn= tax + # is found in the file + if opening_asm: + raise Exception("Unbalanced asm parenthesis in {}".format(filename= )) + + return file_lines + + +# This function runs a set of actions on the passed file name, the actions= needs +# to have a specific interface: action(filename, file_lines), filename wil= l be +# the name of the file where the script is working, file_lines will be the +# content of the file expressed as an array of lines in string format. +# The action function must return this array back to the caller and every +# possible modifications done on that +def stage(filename, actions): + + if len(actions) =3D=3D 0: + return + + try: + with open(filename, "rt") as infile: + file_lines =3D infile.readlines() + except OSError as e: + raise Exception("Issue with reading file {}: {}".format(filename, = e)) + + for task in actions: + file_lines =3D task(filename, file_lines) + + try: + with open(filename, "wt") as outfile: + outfile.writelines(file_lines) + except OSError as e: + raise Exception("Issue writing file {}: {}".format(filename, e)) + + +def main(argv): + # Setup actions for pre-stage and post-stage + pre_stage_asm_protect =3D \ + lambda file, file_lines: action_protect_asm(file, file_lines, True) + post_stage_asm_unprotect =3D \ + lambda file, file_lines: action_protect_asm(file, file_lines, Fals= e) + pre_stage_actions =3D [pre_stage_asm_protect] + post_stage_actions =3D [post_stage_asm_unprotect, action_fix_label_ind= ent] + + len_args =3D len(argv) + if len_args > 0: + c_files =3D [] + for i in range(0, len_args): + if not argv[i].startswith('/'): + # Assume a relative path to Xen + abs_path =3D os.getcwd() + "/" + argv[i] + check_path =3D [abs_path] + if '*' in abs_path: + check_path =3D glob.glob(abs_path) + for path in check_path: + if os.path.exists(path): + c_files.append(path) + else: + raise Exception("Malformed path {} solved from {}" + .format(path, argv[i])) + else: + # Find all files with .c and .h extension + c_files =3D utils.recursive_find_file(xen_dir, r'.*\.(?:c|h)$') + + try: + exclusion_file =3D \ + "{}/docs/misra/exclude-list.json".format(repo_dir) + exclusion_list =3D \ + exclusion_file_list.load_exclusion_file_list(exclusion_fil= e) + except ExclusionFileListError as e: + print("ERROR: Issue with reading file {}: {}".format(exclusion_fil= e, e)) + sys.exit(1) + + # Transform the lists of absolute path in the second element of the + # exclusion_list into a plain list of absolute path to be exluded + excluded_c_files =3D [j for i in exclusion_list for j in i[1]] + + file_to_format =3D [] + for file in c_files: + add_to_list =3D True + for excl in excluded_c_files: + if excl in file: + add_to_list =3D False + break + if add_to_list: + file_to_format.append(file) + elif len_args > 0: + print("ERROR: file {} is excluded!".format(file)) + sys.exit(1) + + for file in file_to_format: + try: + stage(file, pre_stage_actions) + utils.invoke_command("clang-format -i {}".format(file), False, + Exception, "Error occured invoking: {}\n") + stage(file, post_stage_actions) + except Exception as e: + print("ERROR: {}\n".format(e)) + + +if __name__ =3D=3D "__main__": + main(sys.argv[1:]) --=20 2.34.1 From nobody Mon May 13 16:30:52 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; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690531945108110.54995378254193; Fri, 28 Jul 2023 01:12:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.571375.895070 (Exim 4.92) (envelope-from ) id 1qPIZx-00051t-OV; Fri, 28 Jul 2023 08:12:05 +0000 Received: by outflank-mailman (output) from mailman id 571375.895070; Fri, 28 Jul 2023 08:12:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qPIZx-00050C-JJ; Fri, 28 Jul 2023 08:12:05 +0000 Received: by outflank-mailman (input) for mailman id 571375; Fri, 28 Jul 2023 08:12:04 +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 1qPIZw-0004AY-1R for xen-devel@lists.xenproject.org; Fri, 28 Jul 2023 08:12:04 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 6f271b89-2d1e-11ee-b24d-6b7b168915f2; Fri, 28 Jul 2023 10:12:03 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F36AF2F4; Fri, 28 Jul 2023 01:12:45 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C4D073F67D; Fri, 28 Jul 2023 01:12:01 -0700 (PDT) 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: 6f271b89-2d1e-11ee-b24d-6b7b168915f2 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [RFC PATCH 4/5] x86/HVM: protect mm_type_tbl format from clang-format Date: Fri, 28 Jul 2023 09:11:43 +0100 Message-Id: <20230728081144.4124309-5-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230728081144.4124309-1-luca.fancellu@arm.com> References: <20230728081144.4124309-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1690531945752100001 Content-Type: text/plain; charset="utf-8" The array mm_type_tbl initialization is formatted in a way that clang-format can't keep, so disable clang-format on that array initialization. Signed-off-by: Luca Fancellu --- xen/arch/x86/hvm/mtrr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c index 29f3fb160776..f32ce3162ae2 100644 --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -18,6 +18,7 @@ /* Get page attribute fields (PAn) from PAT MSR. */ #define pat_cr_2_paf(pat_cr,n) ((((uint64_t)pat_cr) >> ((n)<<3)) & 0xff) =20 +/* clang-format off */ /* Effective mm type lookup table, according to MTRR and PAT. */ static const uint8_t mm_type_tbl[MTRR_NUM_TYPES][X86_NUM_MT] =3D { #define RS MEMORY_NUM_TYPES @@ -43,6 +44,7 @@ static const uint8_t mm_type_tbl[MTRR_NUM_TYPES][X86_NUM_= MT] =3D { #undef WB #undef RS }; +/* clang-format on */ =20 /* * Reverse lookup table, to find a pat type according to MTRR and effective --=20 2.34.1 From nobody Mon May 13 16:30:52 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; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690531987918101.16525397883038; Fri, 28 Jul 2023 01:13:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.571376.895085 (Exim 4.92) (envelope-from ) id 1qPIa0-0005VN-WC; Fri, 28 Jul 2023 08:12:09 +0000 Received: by outflank-mailman (output) from mailman id 571376.895085; Fri, 28 Jul 2023 08:12:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qPIa0-0005VC-Sg; Fri, 28 Jul 2023 08:12:08 +0000 Received: by outflank-mailman (input) for mailman id 571376; Fri, 28 Jul 2023 08:12:07 +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 1qPIZy-0004AY-Vw for xen-devel@lists.xenproject.org; Fri, 28 Jul 2023 08:12:07 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 7041c0f2-2d1e-11ee-b24d-6b7b168915f2; Fri, 28 Jul 2023 10:12:05 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AEB71D75; Fri, 28 Jul 2023 01:12:47 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 261613F67D; Fri, 28 Jul 2023 01:12:03 -0700 (PDT) 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: 7041c0f2-2d1e-11ee-b24d-6b7b168915f2 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 5/5] xen: Add clang-format configuration Date: Fri, 28 Jul 2023 09:11:44 +0100 Message-Id: <20230728081144.4124309-6-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230728081144.4124309-1-luca.fancellu@arm.com> References: <20230728081144.4124309-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1690531988774100001 Add a clang format configuration for the Xen Hypervisor. Signed-off-by: Luca Fancellu --- xen/.clang-format | 693 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 693 insertions(+) create mode 100644 xen/.clang-format diff --git a/xen/.clang-format b/xen/.clang-format new file mode 100644 index 000000000000..ccc85a6b854a --- /dev/null +++ b/xen/.clang-format @@ -0,0 +1,693 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# clang-format configuration file. Intended for clang-format >=3D 15. +# +# For more information, see: +# +# Documentation/process/clang-format.rst +# https://clang.llvm.org/docs/ClangFormat.html +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +# +--- + +# [not specified] +# Align function parameter that goes into a new line, under the open brack= et +# (supported in clang-format 3.8) +AlignAfterOpenBracket: Align + +# [not specified] +# Align array of struct's elements by column and justify +# struct test demo[] =3D +# { +# {56, 23, "hello"}, +# {-1, 93463, "world"}, +# {7, 5, "!!" } +# }; +# (supported in clang-format 13) +AlignArrayOfStructures: Left + +# [not specified] +# Align consecutive assignments (supported in clang-format 3.8) +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: true + AcrossComments: false + +# [not specified] +# Do not align consecutive bit fields (supported in clang-format 11) +AlignConsecutiveBitFields: None + +# [not specified] +# Do not align values of consecutive declarations +# (supported in clang-format 3.8) +AlignConsecutiveDeclarations: None + +# [not specified] +# Align values of consecutive macros (supported in clang-format 9) +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: true + AcrossComments: true + +# [not specified] +# Align escaped newlines to the right (supported in clang-format 5) +AlignEscapedNewlines: Right + +# [not specified] +# Aligns operands of a single expression that needs to be split over multi= ple +# lines (supported in clang-format 3.5) +AlignOperands: Align + +# Do not align trailing consecutive comments (It helps to make clang-format +# reproduce the same output when it runs on an already formatted file) +# (supported in clang-format 3.7) +AlignTrailingComments: false + +# [not specified] +# Do not put all function call arguments on a new line, try to have at lea= st +# the first one close to the opening parenthesis (supported in clang-forma= t 9) +AllowAllArgumentsOnNextLine: false + +# [not specified] +# Do not put all function declaration parameters on a new line, try to hav= e at +# least the first one close to the opening parenthesis +# (supported in clang-format 3.3) +AllowAllParametersOfDeclarationOnNextLine: false + +# Bracing condition needs to be respected even if the line is so short tha= t the +# final block brace can stay on a single line +# (supported in clang-format 3.5) +AllowShortBlocksOnASingleLine: Never + +# (supported in clang-format 3.6) +AllowShortCaseLabelsOnASingleLine: false + +# (supported in clang-format 3.5) +AllowShortFunctionsOnASingleLine: None + +# (supported in clang-format 3.3) +AllowShortIfStatementsOnASingleLine: Never + +# (supported in clang-format 3.7) +AllowShortLoopsOnASingleLine: false + +# [not specified] +# Do not add a break after the definition return type +# (supported in clang-format 3.8) +AlwaysBreakAfterReturnType: None + +# [not specified] +# There is no need to use a break after an assigment to a multiline string +# (supported in clang-format 3.4) +AlwaysBreakBeforeMultilineStrings: false + +# (supported in clang-format 3.4) +AlwaysBreakTemplateDeclarations: false + +# Specify Xen's macro attributes (supported in clang-format 12) +AttributeMacros: + - '__init' + - '__exit' + - '__initdata' + - '__initconst' + - '__initconstrel' + - '__initdata_cf_clobber' + - '__initconst_cf_clobber' + - '__hwdom_init' + - '__hwdom_initdata' + - '__maybe_unused' + - '__packed' + - '__stdcall' + - '__vfp_aligned' + - '__alt_call_maybe_initdata' + - '__cacheline_aligned' + - '__ro_after_init' + - 'always_inline' + - 'noinline' + - 'noreturn' + - '__weak' + - '__inline__' + - '__attribute_const__' + - '__transparent__' + - '__used' + - '__must_check' + - '__kprobes' + +# [not specified] +# Try always to pack function call arguments on the same line before break= ing +# (supported in clang-format 3.7) +BinPackArguments: true + +# [not specified] +# Try always to pack function declaration parameters on the same line befo= re +# breaking (supported in clang-format 3.7) +BinPackParameters: true + +# [not specified] +# Do not add a spaces on bitfield 'unsigned bf:2;' +# (supported in clang-format 12) +BitFieldColonSpacing: None + +# Xen's coding style does not follow clang-format already available profil= es for +# breaking before braces, so set it to Custom and specify each case separa= tely +# (supported in clang-format 3.8) +BraceWrapping: + # Braces ('{' and '}') are usually placed on a line of their own + AfterCaseLabel: true + AfterFunction: true + BeforeElse: true + AfterExternBlock: true + # except for the opening brace in definitions of enum, struct, and union + AfterEnum: false + AfterStruct: false + AfterUnion: false + # This is unlike the Linux coding style and unlike K&R. + # + # if ( condition ) + # { + # /* Do stuff. */ + # } + # else + # { + # /* Other stuff. */ + # } + # + # while ( condition ) + # { + # /* Do stuff. */ + # } + # + # [non-compliant] + # do-while is not compliant with CODING_STYLE because clang format doesn= 't + # support different styles for every control statement + # do + # { + # /* Do stuff. */ + # } while ( condition ); + AfterControlStatement: Always + BeforeWhile: false + IndentBraces: false + # [not specified] + # Keep empty functions with braces style like this: 'void func() {}' ins= tead + # of breaking the braces + SplitEmptyFunction: false + # Not related to C language, but specified for completeness + AfterClass: false + AfterNamespace: false + AfterObjCDeclaration: false + BeforeCatch: false + BeforeLambdaBody: false + SplitEmptyRecord: true + SplitEmptyNamespace: true + +# [not specified] +# Break only after the operator in case of a long expression +# (supported in clang-format 3.6) +BreakBeforeBinaryOperators: None + +# Xen's coding style does not follow clang-format already available profil= es for +# breaking before braces, so set it to Custom and specify each case separa= tely +# (supported in clang-format 3.7) +BreakBeforeBraces: Custom + +# [not specified] +# Break before inline ASM colon if the line length is longer than column l= imit. +# (This is a new feature upstreamed by EPAM during its work on clang-forma= t for +# Xen) +# (supported in clang-format 16) +# BreakBeforeInlineASMColon: OnlyMultiline + +# [not specified] +# Ternary operators '?, :' can be put after a line break +# (supported in clang-format 3.7) +BreakBeforeTernaryOperators: true + +# (supported in clang-format 5) +BreakConstructorInitializers: BeforeComma + +# User visible strings (e.g., printk() messages) should not be split so th= ey can +# be searched for more easily. (supported in clang-format 3.9) +BreakStringLiterals: false + +# Lines should be less than 80 characters in length +# (supported in clang-format 3.7) +ColumnLimit: 80 + +# (supported in clang-format 3.7) +CommentPragmas: '^ IWYU pragma:' + +# Code within blocks is indented by one extra indent level +# (supported in clang-format 3.7) +ContinuationIndentWidth: 4 + +# Do not derive pointer alignment style from the file +# (supported in clang-format 3.7) +DerivePointerAlignment: false + +# Taken from: +# git grep -h -i '^#define [^[:space:]]*for_each[^[:space:]]*(' xen/ \ +# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1',i"= \ +# | LC_ALL=3DC sort -u +# A vector of macros that should be interpreted as foreach loops instead o= f as +# function calls. +# (supported in clang-format 3.7) +ForEachMacros: + - 'FOR_EACH_IOREQ_SERVER' + - '__list_for_each_rcu' + - 'dt_for_each_child_node' + - 'dt_for_each_device_node' + - 'dt_for_each_property_node' + - 'ebitmap_for_each_positive_bit' + - 'expr_list_for_each_sym' + - 'fdt_for_each_property_offset' + - 'fdt_for_each_subnode' + - 'for_each_affinity_balance_step' + - 'for_each_amd_iommu' + - 'for_each_cfg_sme' + - 'for_each_cpu' + - 'for_each_domain' + - 'for_each_domain_in_cpupool' + - 'for_each_drhd_unit' + - 'for_each_kimage_entry' + - 'for_each_node_mask' + - 'for_each_online_cpu' + - 'for_each_online_node' + - 'for_each_pdev' + - 'for_each_possible_cpu' + - 'for_each_present_cpu' + - 'for_each_rmrr_device' + - 'for_each_sched_unit' + - 'for_each_sched_unit_vcpu' + - 'for_each_set_bit' + - 'for_each_vcpu' + - 'for_each_vp' + - 'hlist_for_each' + - 'hlist_for_each_entry' + - 'hlist_for_each_entry_continue' + - 'hlist_for_each_entry_from' + - 'hlist_for_each_entry_rcu' + - 'hlist_for_each_entry_safe' + - 'hlist_for_each_safe' + - 'list_for_each' + - 'list_for_each_backwards_safe' + - 'list_for_each_continue_rcu' + - 'list_for_each_entry' + - 'list_for_each_entry_continue' + - 'list_for_each_entry_from' + - 'list_for_each_entry_rcu' + - 'list_for_each_entry_reverse' + - 'list_for_each_entry_safe' + - 'list_for_each_entry_safe_continue' + - 'list_for_each_entry_safe_from' + - 'list_for_each_entry_safe_reverse' + - 'list_for_each_prev' + - 'list_for_each_rcu' + - 'list_for_each_safe' + - 'list_for_each_safe_rcu' + - 'page_list_for_each' + - 'page_list_for_each_safe' + - 'page_list_for_each_safe_reverse' + +# A vector of macros that should be interpreted as conditionals instead of= as +# function calls. (supported in clang-format 13) +#IfMacros: +# - '' + +# Sort include files by block of includes and not as only one group +# (supported in clang-format 6) +IncludeBlocks: Preserve + +# [not specified] +# Regular expressions denoting the different #include categories used for +# ordering #includes. (supported in clang-format 3.8) +#IncludeCategories: +# - Regex: '.*' +# Priority: 1 + +# When guessing whether a #include is the =E2=80=9Cmain=E2=80=9D include (= to assign category 0, +# see above), use this regex of allowed suffixes to the header stem. A par= tial +# match is done, so that: - =E2=80=9C=E2=80=9D means =E2=80=9Carbitrary su= ffix=E2=80=9D - =E2=80=9C$=E2=80=9D means =E2=80=9Cno suffix=E2=80=9D +# For example, if configured to =E2=80=9C(_test)?$=E2=80=9D, then a header= a.h would be seen as +# the =E2=80=9Cmain=E2=80=9D include in both a.cc and a_test.cc. +# (Do we have a main include in Xen?) +# (supported in clang-format 3.9) +#IncludeIsMainRegex: '(Test)?$' + +# Non-case labels inside switch() bodies are preferred to be indented the = same +# as the block's case labels (supported in clang-format 11) +IndentCaseBlocks: false + +# [not specified] +# Do not indent case labels in the switch block (supported in clang-format= 3.3) +IndentCaseLabels: false + +# [not specified] +# Do not indent extern "C" block +# (supported in clang-format 11) +IndentExternBlock: NoIndent + +# Due to the behavior of GNU diffutils "diff -p", labels should be indente= d by +# at least one blank (supported in clang-format 10) +IndentGotoLabels: true + +# [not specified] +# Do not create indentation for the preprocessor directives +# (supported in clang-format 6) +IndentPPDirectives: None + +# An indent level consists of four spaces (supported in clang-format 3.7) +IndentWidth: 4 + +# [not specified] +# In case a function definition or declaration needs to be wrapped after t= he +# type, do not indent the new line (supported in clang-format 3.7) +IndentWrappedFunctionNames: false + +# Braces should be omitted for blocks with a single statement. e.g., +# if ( condition ) +# single_statement(); +# (supported in clang-format 15) +InsertBraces: false + +# [not specified] +# Every file needs to end with a new line +# (supported in clang-format 16) +# InsertNewlineAtEOF: true + +# [not specified] +# Keep empty lines (up to MaxEmptyLinesToKeep) at end of file +# (supported in clang-format 17) +# KeepEmptyLinesAtEOF: true + +# [not specified] +# Do not add a new empty line at the start of the block +# (supported in clang-format 3.7) +KeepEmptyLinesAtTheStartOfBlocks: false + +# The Xen Hypervisor is written in C language (supported in clang-format 3= .5) +Language: Cpp + +# [not specified] +# Line ending style is '\n' (supported in clang-format 16) +# LineEnding: LF + +# Specify Xen's macro that starts a block of code +# (supported in clang-format 3.7) +MacroBlockBegin: '^PLATFORM_START|^DT_DEVICE_START|^ACPI_DEVICE_START' + +# Specify Xen's macro that ends a block of code (supported in clang-format= 3.7) +MacroBlockEnd: '^PLATFORM_END|^DT_DEVICE_END|^ACPI_DEVICE_END' + +# [not specified] +# Maximum consecutive empty lines allowed (supported in clang-format 3.7) +MaxEmptyLinesToKeep: 1 + +# Parameters to tweak to discourage clang-format to break something +# (supported in clang-format 5) +PenaltyBreakAssignment: 10 +# (supported in clang-format 3.7) +PenaltyBreakBeforeFirstCallParameter: 30 +# (supported in clang-format 3.7) +PenaltyBreakComment: 10 +# (supported in clang-format 3.7) +PenaltyBreakFirstLessLess: 0 +# (supported in clang-format 14) +PenaltyBreakOpenParenthesis: 100 +# (supported in clang-format 3.7) +PenaltyBreakString: 10 +# (supported in clang-format 3.7) +PenaltyExcessCharacter: 100 +# (supported in clang-format 12) +PenaltyIndentedWhitespace: 0 +# (supported in clang-format 3.7) +PenaltyReturnTypeOnItsOwnLine: 60 + +# [not specified] +# Pointer alignment style is on the right 'void *var' +# (supported in clang-format 3.7) +PointerAlignment: Right + +# [not specified] +# The number of columns to use for indentation of preprocessor statements +# When set to -1 (default) IndentWidth is used also for preprocessor state= ments. +# (supported in clang-format 13) +PPIndentWidth: -1 + +# [not specified] +# (supported in clang-format 14) +QualifierAlignment: Custom + +# Specify in which order the qualifiers should appear 'static const int *v= ar' +# (supported in clang-format 14) +QualifierOrder: ['static', 'inline', 'const', 'volatile', 'type'] + +# Don't try to reflow comments to respect the column limit (It helps to ma= ke +# clang-format reproduce the same output when it runs on an already format= ted +# file) +# (supported in clang-format 3.8) +ReflowComments: false + +# [not specified] +# Specifies the use of empty lines to separate definition blocks, including +# structs, enums, and functions +# (supported in clang-format 14) +SeparateDefinitionBlocks: Always + +# [not specified] +# Sort the include files by name (supported in clang-format 3.8) +# TODO: enabling this will currently break the compilation, maybe fix? +SortIncludes: Never + +# [not specified] +# Do not allow a space after a type cast '(type)var' +# (supported in clang-format 3.5) +SpaceAfterCStyleCast: false + +# [not specified] +# Do not allow a space after the not operator '!var' +# (supported in clang-format 9) +SpaceAfterLogicalNot: false + +# Ensure that there is a space after pointer qualifiers, when used with +# PointerAlignment of value Right it means 'void *const *x =3D NULL;' +# (supported in clang-format 12) +SpaceAroundPointerQualifiers: After + +# [not specified] +# Always have a space after an assign operator or a compound operator, for +# example '+=3D' (supported in clang-format 3.7) +SpaceBeforeAssignmentOperators: true + +# [not specified] +# Do not allow a space between the case argument and the final colon 'case= 0:' +# (supported in clang-format 12) +SpaceBeforeCaseColon: false + +# [not specified] +# Have a space before the parenthesis of a control statement, do an except= ion +# for ForEach and If macros +SpaceBeforeParens: ControlStatementsExceptForEachMacros + +# (supported in clang-format 7) +SpaceBeforeRangeBasedForLoopColon: true + +# [not specified] +# Do not add a spaces before square brackets 'int a[5];' +# (supported in clang-format 10) +SpaceBeforeSquareBrackets: false + +# [not specified] +# Do not add a space inside empty parenthesis '()' +# (supported in clang-format 3.7) +SpaceInEmptyParentheses: false + +# (supported in clang-format 3.7) +SpacesBeforeTrailingComments: 1 + +# Space characters are used to spread out logical statements, such as in t= he +# condition of an if or while 'if ( a )' 'while ( i < 5 )' +# (supported in clang-format 10) +SpacesInConditionalStatement: true + +# (supported in clang-format 3.7) +SpacesInContainerLiterals: false + +# [not specified] +# Do not add a spaces inside a type cast parenthesis '(int)var' +# (supported in clang-format 3.7) +SpacesInCStyleCastParentheses: false + +# [not specified] +# Do not insert spaces in empty block '{}' +# (supported in clang-format 3.5) +SpaceInEmptyBlock: false + +# Only one space is allowed at the start of a line comment +# (supported in clang-format 13) +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 + +# [not specified] +# Do not add a spaces inside parenthesis '(var & var)' +# (supported in clang-format 3.7) +SpacesInParentheses: false + +# [not specified] +# Do not add spaces inside square brakets 'int a[5];' +# (supported in clang-format 3.7) +SpacesInSquareBrackets: false + +# (supported in clang-format 3.7) +Standard: C++03 + +# Macros which are ignored in front of a statement, as if they were an +# attribute. So that they are not parsed as identifier +# (supported in clang-format 12) +# StatementAttributeLikeMacros: [''] + +# A vector of macros that should be interpreted as complete statements. +# Typical macros are expressions, and require a semi-colon to be added; +# sometimes this is not the case, and this allows to make clang-format awa= re of +# such cases. (supported in clang-format 8) +StatementMacros: + - 'PROGRESS' + - 'PROGRESS_VCPU' + - 'bitop' + - 'guest_bitop' + - 'testop' + - 'guest_testop' + - 'DEFINE_XEN_GUEST_HANDLE' + - '__DEFINE_XEN_GUEST_HANDLE' + - '___DEFINE_XEN_GUEST_HANDLE' + - 'presmp_initcall' + - '__initcall' + - '__exitcall' + +# An indent level consists of four spaces (supported in clang-format 3.7) +TabWidth: 4 + +# A vector of macros that should be interpreted as type declarations inste= ad of +# as function calls (supported in clang-format 9) +TypenameMacros: + - 'XEN_GUEST_HANDLE' + - 'XEN_GUEST_HANDLE_64' + - 'XEN_GUEST_HANDLE_PARAM' + - 'ELF_HANDLE_DECL' + +# Indentation is done using spaces, not tabs (supported in clang-format 3.= 7) +UseTab: Never + +# A vector of macros which are whitespace-sensitive and should not be touc= hed +# (supported in clang-format 11) +WhitespaceSensitiveMacros: + - '__stringify' + +## Not related to C language #############################################= ###### + +# (supported in clang-format 3.3) +AccessModifierOffset: -4 + +# (supported in clang-format 9) +AllowShortLambdasOnASingleLine: None + +# (supported in clang-format 16) +# BreakAfterAttributes: Never + +# (supported in clang-format 3.8) +BreakAfterJavaFieldAnnotations: false + +# (supported in clang-format 16) +# BreakArrays: false + +# (supported in clang-format 12) +BreakBeforeConceptDeclarations: Never + +# (supported in clang-format 7) +BreakInheritanceList: BeforeColon + +# (supported in clang-format 5) +CompactNamespaces: false + +# (supported in clang-format 3.7) +ConstructorInitializerAllOnOneLineOrOnePerLine: false + +# (supported in clang-format 3.7) +ConstructorInitializerIndentWidth: 4 + +# (supported in clang-format 3.4) +Cpp11BracedListStyle: false + +# (supported in clang-format 13) +EmptyLineAfterAccessModifier: Leave + +# (supported in clang-format 12) +EmptyLineBeforeAccessModifier: Leave + +# (supported in clang-format 5) +FixNamespaceComments: false + +# (supported in clang-format 13) +IndentAccessModifiers: false + +# (supported in clang-format 15) +IndentRequiresClause: false + +# (supported in clang-format 11) +InsertTrailingCommas: None + +# (supported in clang-format 3.9) +JavaScriptQuotes: Leave + +# (supported in clang-format 3.9) +JavaScriptWrapImports: true + +# (supported in clang-format 3.7) +NamespaceIndentation: None + +# (supported in clang-format 7) +ObjCBinPackProtocolList: Auto + +# (supported in clang-format 3.7) +ObjCBlockIndentWidth: 4 + +# (supported in clang-format 11) +ObjCBreakBeforeNestedBlockParam: false + +# (supported in clang-format 3.7) +ObjCSpaceAfterProperty: true + +# (supported in clang-format 3.7) +ObjCSpaceBeforeProtocolList: true + +# (supported in clang-format 14) +PackConstructorInitializers: Never + +# (supported in clang-format 7) +PenaltyBreakTemplateDeclaration: 0 + +# (supported in clang-format 13) +ReferenceAlignment: Right + +# (supported in clang-format 16) +# RemoveSemicolon: false + +# (supported in clang-format 5) +SortUsingDeclarations: false + +# (supported in clang-format 4) +SpaceAfterTemplateKeyword: true + +# (supported in clang-format 7) +SpaceBeforeCpp11BracedList: false + +# (supported in clang-format 7) +SpaceBeforeCtorInitializerColon: true + +# (supported in clang-format 7) +SpaceBeforeInheritanceColon: true + +# (supported in clang-format 3.4) +SpacesInAngles: false + +... --=20 2.34.1