From 5f532c1c7ce8a8fbba6fb4cc58dff7be84e8b900 Mon Sep 17 00:00:00 2001 From: Alexey Gladkov Date: Mon, 1 Sep 2025 15:40:13 +0200 Subject: [PATCH] Upgrade clang-format configuration Signed-off-by: Alexey Gladkov --- .clang-format | 82 +++++++++++++++++++++++++-- src/include/kbd/compiler_attributes.h | 2 +- src/libcommon/nls.h | 6 +- 3 files changed, 80 insertions(+), 10 deletions(-) diff --git a/.clang-format b/.clang-format index f9901ee..2aba424 100644 --- a/.clang-format +++ b/.clang-format @@ -1,10 +1,80 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# clang-format configuration file. Intended for clang-format >= 17. +# +# For more information, see: +# +# Documentation/dev-tools/clang-format.rst +# https://clang.llvm.org/docs/ClangFormat.html +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +# +--- BasedOnStyle: LLVM -IndentWidth: 8 + +AlignArrayOfStructures: Left +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AllowAllParametersOfDeclarationOnNextLine: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: BinPack +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 +BracedInitializerIndentWidth: 8 +BreakBeforeBraces: Custom ColumnLimit: 0 -UseTab: ForIndentation -BreakBeforeBraces: Linux -AllowShortIfStatementsOnASingleLine: false -IndentCaseLabels: true -AlignConsecutiveAssignments: true +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 Cpp11BracedListStyle: false +IndentCaseLabels: true +IndentGotoLabels: false +IndentPPDirectives: None +IndentWidth: 8 +IndentWrappedFunctionNames: false +MaxEmptyLinesToKeep: 1 +PointerAlignment: Right +QualifierAlignment: Left +ReflowComments: IndentOnly SortIncludes: false +SpaceAfterCStyleCast: true +SpaceBeforeAssignmentOperators: true +TabWidth: 8 +UseTab: ForContinuationAndIndentation + +# Taken from git's rules +PenaltyBreakAssignment: 10 +PenaltyBreakBeforeFirstCallParameter: 30 +PenaltyBreakComment: 10 +PenaltyBreakFirstLessLess: 0 +PenaltyBreakString: 10 +PenaltyExcessCharacter: 100 +PenaltyReturnTypeOnItsOwnLine: 60 + +# Taken from: +# git grep --no-line-number -h '^#define[[:space:]]+KBD_[^[:space:]]*' \ +# | sed -r -e "s,^#define[[:space:]]+(KBD_[^[:space:](]*)[[:space:]]*.*$, - '\1'," \ +# | LC_ALL=C sort -u +AttributeMacros: + - 'KBD_ATTR_MUST_CHECK' + - 'KBD_ATTR_NONNULL' + - 'KBD_ATTR_NORETURN' + - 'KBD_ATTR_PRINTF' + - 'KBD_ATTR_SCANF' + - 'KBD_ATTR_UNUSED' + - 'KBD_ATTR_USED' + - 'KBD_TEXTDOMAIN_EXPLICIT' +... diff --git a/src/include/kbd/compiler_attributes.h b/src/include/kbd/compiler_attributes.h index f8ba8e0..6701983 100644 --- a/src/include/kbd/compiler_attributes.h +++ b/src/include/kbd/compiler_attributes.h @@ -69,4 +69,4 @@ */ #define KBD_ATTR_MUST_CHECK __attribute__((__warn_unused_result__)) -#endif /* _KBD _COMMON_COMPILER_ATTRIBUTES_H_ */ +#endif /* _KBD_COMMON_COMPILER_ATTRIBUTES_H_ */ diff --git a/src/libcommon/nls.h b/src/libcommon/nls.h index 1a4cbda..7d23346 100644 --- a/src/libcommon/nls.h +++ b/src/libcommon/nls.h @@ -1,5 +1,5 @@ -#ifndef KBD_NLS_H -#define KBD_NLS_H +#ifndef _KBD_NLS_H_ +#define _KBD_NLS_H_ #ifndef LOCALEDIR #define LOCALEDIR "/usr/share/locale" @@ -50,4 +50,4 @@ textdomain(PACKAGE); \ } while (0) -#endif /* KBD_NLS_H */ +#endif /* _KBD_NLS_H_ */