mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-16 06:35:39 +08:00
d4ef8d3ff0
clang-format is a tool to format C/C++/... code according to a set of rules and heuristics. Like most tools, it is not perfect nor covers every single case, but it is good enough to be helpful. In particular, it is useful for quickly re-formatting blocks of code automatically, for reviewing full files in order to spot coding style mistakes, typos and possible improvements. It is also handy for sorting ``#includes``, for aligning variables and macros, for reflowing text and other similar tasks. It also serves as a teaching tool/guide for newcomers. The tool itself has been already included in the repositories of popular Linux distributions for a long time. The rules in this file are intended for clang-format >= 4, which is easily available in most distributions. This commit adds the configuration file that contains the rules that the tool uses to know how to format the code according to the kernel coding style. This gives us several advantages: * clang-format works out of the box with reasonable defaults; avoiding that everyone has to re-do the configuration. * Everyone agrees (eventually) on what is the most useful default configuration for most of the kernel. * If it becomes commonplace among kernel developers, clang-format may feel compelled to support us better. They already recognize the Linux kernel and its style in their documentation and in one of the style sub-options. Some of clang-format's features relevant for the kernel are: * Uses clang's tooling support behind the scenes to parse and rewrite the code. It is not based on ad-hoc regexps. * Supports reasonably well the Linux kernel coding style. * Fast enough to be used at the press of a key. * There are already integrations (either built-in or third-party) for many common editors used by kernel developers (e.g. vim, emacs, Sublime, Atom...) that allow you to format an entire file or, more usefully, just your selection. * Able to parse unified diffs -- you can, for instance, reformat only the lines changed by a git commit. * Able to reflow text comments as well. * Widely supported and used by hundreds of developers in highly complex projects and organizations (e.g. the LLVM project itself, Chromium, WebKit, Google, Mozilla...). Therefore, it will be supported for a long time. See more information about the tool at: https://clang.llvm.org/docs/ClangFormat.html https://clang.llvm.org/docs/ClangFormatStyleOptions.html Link: http://lkml.kernel.org/r/20180318171632.qfkemw3mwbcukth6@gmail.com Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Andy Whitcroft <apw@canonical.com> Cc: Joe Perches <joe@perches.com> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
136 lines
1.6 KiB
Plaintext
136 lines
1.6 KiB
Plaintext
#
|
|
# NOTE! Don't add files that are generated in specific
|
|
# subdirectories here. Add them in the ".gitignore" file
|
|
# in that subdirectory instead.
|
|
#
|
|
# NOTE! Please use 'git ls-files -i --exclude-standard'
|
|
# command after changing this file, to see if there are
|
|
# any tracked files which get ignored after the change.
|
|
#
|
|
# Normal rules (sorted alphabetically)
|
|
#
|
|
.*
|
|
*.a
|
|
*.bin
|
|
*.bz2
|
|
*.c.[012]*.*
|
|
*.dtb
|
|
*.dtb.S
|
|
*.dwo
|
|
*.elf
|
|
*.gcno
|
|
*.gz
|
|
*.i
|
|
*.ko
|
|
*.ll
|
|
*.lst
|
|
*.lz4
|
|
*.lzma
|
|
*.lzo
|
|
*.mod.c
|
|
*.o
|
|
*.o.*
|
|
*.order
|
|
*.patch
|
|
*.s
|
|
*.so
|
|
*.so.dbg
|
|
*.su
|
|
*.symtypes
|
|
*.tar
|
|
*.xz
|
|
Module.symvers
|
|
modules.builtin
|
|
|
|
#
|
|
# Top-level generic files
|
|
#
|
|
/tags
|
|
/TAGS
|
|
/linux
|
|
/vmlinux
|
|
/vmlinux.32
|
|
/vmlinux-gdb.py
|
|
/vmlinuz
|
|
/System.map
|
|
/Module.markers
|
|
|
|
#
|
|
# RPM spec file (make rpm-pkg)
|
|
#
|
|
/*.spec
|
|
|
|
#
|
|
# Debian directory (make deb-pkg)
|
|
#
|
|
/debian/
|
|
|
|
#
|
|
# Snap directory (make snap-pkg)
|
|
#
|
|
/snap/
|
|
|
|
#
|
|
# tar directory (make tar*-pkg)
|
|
#
|
|
/tar-install/
|
|
|
|
#
|
|
# git files that we don't want to ignore even if they are dot-files
|
|
#
|
|
!.gitignore
|
|
!.mailmap
|
|
!.cocciconfig
|
|
!.clang-format
|
|
|
|
#
|
|
# Generated include files
|
|
#
|
|
include/config
|
|
include/generated
|
|
include/ksym
|
|
arch/*/include/generated
|
|
|
|
# stgit generated dirs
|
|
patches-*
|
|
|
|
# quilt's files
|
|
patches
|
|
series
|
|
|
|
# cscope files
|
|
cscope.*
|
|
ncscope.*
|
|
|
|
# gnu global files
|
|
GPATH
|
|
GRTAGS
|
|
GSYMS
|
|
GTAGS
|
|
|
|
# id-utils files
|
|
ID
|
|
|
|
*.orig
|
|
*~
|
|
\#*#
|
|
|
|
#
|
|
# Leavings from module signing
|
|
#
|
|
extra_certificates
|
|
signing_key.pem
|
|
signing_key.priv
|
|
signing_key.x509
|
|
x509.genkey
|
|
|
|
# Kconfig presets
|
|
all.config
|
|
|
|
# Kdevelop4
|
|
*.kdev4
|
|
|
|
#Automatically generated by ASN.1 compiler
|
|
net/ipv4/netfilter/nf_nat_snmp_basic-asn1.c
|
|
net/ipv4/netfilter/nf_nat_snmp_basic-asn1.h
|