From: Thomas Huth <thuth@redhat.com>
To: Steffen Eiden <seiden@linux.ibm.com>, kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Andrew Jones <andrew.jones@linux.dev>
Subject: Re: [kvm-unit-tests PATCH] clang-format: add project-wide configuration file
Date: Wed, 26 Apr 2023 16:41:10 +0200 [thread overview]
Message-ID: <243608a7-484c-4844-9274-0b02dc32ec25@redhat.com> (raw)
In-Reply-To: <20230426140805.704491-1-seiden@linux.ibm.com>
On 26/04/2023 16.08, Steffen Eiden wrote:
> clang-format is a tool to format C/C++/... code according to a set of
> rules and heuristics.
>
> This commit adds the configuration file, with the setting the
> Linux kernel project uses "as of today", with the modification
> of allowing up to 120 chars per line.
>
> This hopefully eases code formatting for developers, as clang-format
> has support for most editors and also can be run standalone.
>
> Additional information:
> https://clang.llvm.org/docs/ClangFormat.html
> https://clang.llvm.org/docs/ClangFormatStyleOptions.html
>
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> ---
> .clang-format | 688 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 688 insertions(+)
> create mode 100644 .clang-format
>
> diff --git a/.clang-format b/.clang-format
> new file mode 100644
> index 0000000..71c7830
> --- /dev/null
> +++ b/.clang-format
> @@ -0,0 +1,688 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# clang-format configuration file. Intended for clang-format >= 11.
> +#
> +# For more information, see:
> +#
> +# Documentation/process/clang-format.rst
> +# https://clang.llvm.org/docs/ClangFormat.html
> +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
> +#
> +---
> +AccessModifierOffset: -4
> +AlignAfterOpenBracket: Align
> +AlignConsecutiveAssignments: false
> +AlignConsecutiveDeclarations: false
> +AlignEscapedNewlines: Left
> +AlignOperands: true
> +AlignTrailingComments: false
> +AllowAllParametersOfDeclarationOnNextLine: false
> +AllowShortBlocksOnASingleLine: false
> +AllowShortCaseLabelsOnASingleLine: false
> +AllowShortFunctionsOnASingleLine: None
> +AllowShortIfStatementsOnASingleLine: false
> +AllowShortLoopsOnASingleLine: false
> +AlwaysBreakAfterDefinitionReturnType: None
> +AlwaysBreakAfterReturnType: None
> +AlwaysBreakBeforeMultilineStrings: false
> +AlwaysBreakTemplateDeclarations: false
> +BinPackArguments: true
> +BinPackParameters: true
> +BraceWrapping:
> + AfterClass: false
> + AfterControlStatement: false
> + AfterEnum: false
> + AfterFunction: true
> + AfterNamespace: true
> + AfterObjCDeclaration: false
> + AfterStruct: false
> + AfterUnion: false
> + AfterExternBlock: false
> + BeforeCatch: false
> + BeforeElse: false
> + IndentBraces: false
> + SplitEmptyFunction: true
> + SplitEmptyRecord: true
> + SplitEmptyNamespace: true
> +BreakBeforeBinaryOperators: None
> +BreakBeforeBraces: Custom
> +BreakBeforeInheritanceComma: false
> +BreakBeforeTernaryOperators: false
> +BreakConstructorInitializersBeforeComma: false
> +BreakConstructorInitializers: BeforeComma
> +BreakAfterJavaFieldAnnotations: false
> +BreakStringLiterals: false
> +ColumnLimit: 120
> +CommentPragmas: '^ IWYU pragma:'
> +CompactNamespaces: false
> +ConstructorInitializerAllOnOneLineOrOnePerLine: false
> +ConstructorInitializerIndentWidth: 8
> +ContinuationIndentWidth: 8
> +Cpp11BracedListStyle: false
> +DerivePointerAlignment: false
> +DisableFormat: false
> +ExperimentalAutoDetectBinPacking: false
> +FixNamespaceComments: false
> +
> +# Taken from:
> +# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \
> +# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
> +# | LC_ALL=C sort -u
> +ForEachMacros:
> + - '__ata_qc_for_each'
> + - '__bio_for_each_bvec'
> + - '__bio_for_each_segment'
> + - '__evlist__for_each_entry'
> + - '__evlist__for_each_entry_continue'
> + - '__evlist__for_each_entry_from'
> + - '__evlist__for_each_entry_reverse'
> + - '__evlist__for_each_entry_safe'
> + - '__for_each_mem_range'
> + - '__for_each_mem_range_rev'
> + - '__for_each_thread'
> + - '__hlist_for_each_rcu'
> + - '__map__for_each_symbol_by_name'
> + - '__perf_evlist__for_each_entry'
> + - '__perf_evlist__for_each_entry_reverse'
> + - '__perf_evlist__for_each_entry_safe'
> + - '__rq_for_each_bio'
> + - '__shost_for_each_device'
...
I think this ForEachMacros list should be adapted for the k-u-ts.
The "git grep" statement results in this list for the k-u-ts:
- 'dt_for_each_subnode'
- 'fdt_for_each_property_offset'
- 'fdt_for_each_subnode'
- 'for_each_cpu'
- 'for_each_online_cpu'
- 'for_each_present_cpu'
which is definitely much shorter :-)
Thomas
next prev parent reply other threads:[~2023-04-26 14:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 14:08 [kvm-unit-tests PATCH] clang-format: add project-wide configuration file Steffen Eiden
2023-04-26 14:41 ` Thomas Huth [this message]
2023-04-26 16:31 ` Steffen Eiden
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=243608a7-484c-4844-9274-0b02dc32ec25@redhat.com \
--to=thuth@redhat.com \
--cc=andrew.jones@linux.dev \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seiden@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox