Skip to content

Commit bba057b

Browse files
flichtenheldcron2
authored andcommitted
Define a .clang-format file for the project
Each of these statements has been reviewed but not all of them are obvious. Also add a pre-commit config to easily check the formatting. Change-Id: I40f6af10c5ee2f5aed4185d783fc622a2e3c19ff Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20250803150143.3878-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32484.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
1 parent ff371d1 commit bba057b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.clang-format

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
BasedOnStyle: Mozilla
3+
AccessModifierOffset: '-4'
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveMacros:
6+
Enabled: true
7+
AcrossEmptyLines: false
8+
AcrossComments: true
9+
AlignEscapedNewlines: Left
10+
AlignOperands: true
11+
AlignTrailingComments:
12+
Kind: Always
13+
OverEmptyLines: 1
14+
AllowAllParametersOfDeclarationOnNextLine: true
15+
AllowShortBlocksOnASingleLine: Never
16+
AllowShortCaseLabelsOnASingleLine: false
17+
AllowShortFunctionsOnASingleLine: None
18+
AllowShortIfStatementsOnASingleLine: Never
19+
AllowShortLoopsOnASingleLine: false
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BreakAfterReturnType: AllDefinitions
23+
BreakBeforeBinaryOperators: NonAssignment
24+
BreakBeforeBraces: Allman
25+
BreakBeforeTernaryOperators: true
26+
BreakStringLiterals: false
27+
ColumnLimit: '100'
28+
ContinuationIndentWidth: '4'
29+
DerivePointerAlignment: false
30+
IndentCaseLabels: true
31+
IndentGotoLabels: false
32+
IndentWidth: '4'
33+
IndentWrappedFunctionNames: false
34+
KeepEmptyLinesAtTheStartOfBlocks: false
35+
MaxEmptyLinesToKeep: '2'
36+
PointerAlignment: Right
37+
ReflowComments: true
38+
SortIncludes: false
39+
SpaceAfterCStyleCast: false
40+
SpaceBeforeAssignmentOperators: true
41+
SpaceBeforeParens: ControlStatements
42+
SpacesBeforeTrailingComments: '2'
43+
SpacesInParens: Never
44+
TabWidth: '4'
45+
TypeNames: [DWORD]
46+
UseTab: Never
47+
WhitespaceSensitiveMacros: [_STRINGIFY]
48+
---
49+
Language: C
50+
---
51+
Language: Cpp

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/mirrors-clang-format
3+
rev: 'v20.1.0'
4+
hooks:
5+
- id: clang-format
6+
files: \.[ch]$
7+
# preserve upstream formatting
8+
exclude: ^(src/compat/compat-lz4\.[ch]|src/openvpn/ovpn_dco_(linux|win)\.h)$

0 commit comments

Comments
 (0)