[Openvpn-devel,v18] Define a .clang-format file for the project
Commit Message
From: Frank Lichtenheld <frank@lichtenheld.com>
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>
---
This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/790
This mail reflects revision 18 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>
Comments
So, this is the beginning of the Grand Reformatting of 2025 - here are
the rules, that have been out for review for a long time, and all the
more active community members have either signalled "yeah, fine, I do not
care much either way" or "this is ok for me".
We move from uncrustify to clang-format, because uncrustify has become
a maintenance chore - newer versions break our formatting in interesting
ways, and pinning buildbots/GHA to old versions is nontrivial effort.
*This* does not change any formatting, nor does it auto-install any new
hooks. More commits will follow.
Your patch has been applied to the master branch.
commit bba057b0573fa788e400a8490b5375153df87141
Author: Frank Lichtenheld
Date: Sun Aug 3 17:01:37 2025 +0200
Define a .clang-format file for the project
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>
--
kind regards,
Gert Doering
new file mode 100644
@@ -0,0 +1,51 @@
+---
+BasedOnStyle: Mozilla
+AccessModifierOffset: '-4'
+AlignAfterOpenBracket: Align
+AlignConsecutiveMacros:
+ Enabled: true
+ AcrossEmptyLines: false
+ AcrossComments: true
+AlignEscapedNewlines: Left
+AlignOperands: true
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLoopsOnASingleLine: false
+BinPackArguments: true
+BinPackParameters: true
+BreakAfterReturnType: AllDefinitions
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeBraces: Allman
+BreakBeforeTernaryOperators: true
+BreakStringLiterals: false
+ColumnLimit: '100'
+ContinuationIndentWidth: '4'
+DerivePointerAlignment: false
+IndentCaseLabels: true
+IndentGotoLabels: false
+IndentWidth: '4'
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: false
+MaxEmptyLinesToKeep: '2'
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: false
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpacesBeforeTrailingComments: '2'
+SpacesInParens: Never
+TabWidth: '4'
+TypeNames: [DWORD]
+UseTab: Never
+WhitespaceSensitiveMacros: [_STRINGIFY]
+---
+Language: C
+---
+Language: Cpp
new file mode 100644
@@ -0,0 +1,8 @@
+repos:
+ - repo: https://github.com/pre-commit/mirrors-clang-format
+ rev: 'v20.1.0'
+ hooks:
+ - id: clang-format
+ files: \.[ch]$
+ # preserve upstream formatting
+ exclude: ^(src/compat/compat-lz4\.[ch]|src/openvpn/ovpn_dco_(linux|win)\.h)$