From e537caf170438b739bf99a741c87c0357997b48a Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 May 2019 11:55:05 +0100 Subject: [PATCH] Ensure we're more specific about clang format options and include order --- .clang-format | 41 ++++++++++++++++++--------------------- daemon/gamemode-context.c | 6 ++++-- daemon/gamemode-dbus.c | 4 +++- daemon/gamemode-gpu.c | 2 +- daemon/gamemode-ioprio.c | 2 +- daemon/gamemode-sched.c | 2 +- daemon/gamemode-tests.c | 2 +- daemon/gamemode-wine.c | 2 +- daemon/gamemoded.c | 2 +- 9 files changed, 32 insertions(+), 31 deletions(-) diff --git a/.clang-format b/.clang-format index 07c5eec..1df7530 100644 --- a/.clang-format +++ b/.clang-format @@ -2,8 +2,7 @@ AccessModifierOffset: 0 AlignAfterOpenBracket: true AlignConsecutiveAssignments: false -#uncomment for clang 3.9 -#AlignConsecutiveDeclarations: false +AlignConsecutiveDeclarations: false AlignEscapedNewlinesLeft: false AlignOperands: true AlignTrailingComments: true @@ -14,21 +13,18 @@ AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false # AlwaysBreakAfterDefinitionReturnType: None -#uncomment for clang 3.9 -#AlwaysBreakAfterReturnType: None +AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: false BinPackArguments: false BinPackParameters: true -# BraceWrapping: (not set since BreakBeforeBraces is not Custom) BreakBeforeBinaryOperators: None -# BreakAfterJavaFieldAnnotations: (not java) BreakBeforeBinaryOperators: None BreakBeforeBraces: Linux BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: false -#uncomment for clang 3.9 -#BreakStringLiterals: false +# Too new for travis clang-format version +# BreakStringLiterals: false ColumnLimit: 100 CommentPragmas: '\*\<' ConstructorInitializerAllOnOneLineOrOnePerLine: false @@ -39,35 +35,37 @@ DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ ] -#Uncomment for clang 3.9 -#IncludeCategories: -# - Regex: '^"' -# Priority: 1 +SortIncludes: true +# IncludeBlocksStyle changed to IncludeBlocks, between xenial and disco, so we can't use it for consistency +# IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^"gamemode.h"' + Priority: 0 + - Regex: '^"build-' + Priority: 1 + - Regex: '^"common-' + Priority: 2 + - Regex: '^"gamemode-' + Priority: 3 + - Regex: '^<' + Priority: 4 # IncludeIsMainRegex: (project doesn't use a main includes that can add other includes via regex) IndentCaseLabels: false IndentWidth: 4 IndentWrappedFunctionNames: false -# JavaScriptQuotes: (not javascript) KeepEmptyLinesAtTheStartOfBlocks: false Language: Cpp MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None -# ObjCBlockIndentWidth: (not objc) -# ObjCSpaceAfterProperty: (not objc) -# ObjCSpaceBeforeProtocolList: (not objc) PenaltyBreakBeforeFirstCallParameter: 400 PenaltyBreakComment: 0 -# PenaltyBreakFirstLessLess: (not cpp) PenaltyBreakString: 500 PenaltyExcessCharacter: 10000 PenaltyReturnTypeOnItsOwnLine: 600 PointerAlignment: Right -#uncomment for clang 3.9 -#ReflowComments: true -#uncomment for clang 3.9 -#SortIncludes: true +ReflowComments: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements @@ -75,7 +73,6 @@ SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInCStyleCastParentheses: false -# SpacesInContainerLiterals: (not objc or javascript) SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp11 diff --git a/daemon/gamemode-context.c b/daemon/gamemode-context.c index f038f61..cb075b4 100644 --- a/daemon/gamemode-context.c +++ b/daemon/gamemode-context.c @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "common-helpers.h" #include "common-logging.h" -#include "gamemode-config.h" #include "gamemode.h" +#include "gamemode-config.h" #include "build-config.h" @@ -602,10 +602,12 @@ int game_mode_context_query_status(GameModeContext *self, pid_t client, pid_t re */ static GameModeClient *game_mode_client_new(pid_t pid, char *executable) { + /* clang-format off */ GameModeClient c = { .next = NULL, .pid = pid, }; + /* clang-format on */ GameModeClient *ret = NULL; ret = calloc(1, sizeof(struct GameModeClient)); @@ -794,4 +796,4 @@ int game_mode_reload_config(GameModeContext *self) start_reaper_thread(self); return 0; -} \ No newline at end of file +} diff --git a/daemon/gamemode-dbus.c b/daemon/gamemode-dbus.c index 1bf22c7..5db544b 100644 --- a/daemon/gamemode-dbus.c +++ b/daemon/gamemode-dbus.c @@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE. #define _GNU_SOURCE -#include "common-logging.h" #include "gamemode.h" +#include "common-logging.h" #include #include @@ -216,6 +216,7 @@ static int method_refresh_config(sd_bus_message *m, void *userdata, /** * D-BUS vtable to dispatch virtual methods */ +/* clang-format off */ static const sd_bus_vtable gamemode_vtable[] = { SD_BUS_VTABLE_START(0), SD_BUS_PROPERTY("ClientCount", "i", property_get_client_count, 0, @@ -232,6 +233,7 @@ static const sd_bus_vtable gamemode_vtable[] = { SD_BUS_METHOD("RefreshConfig", "", "i", method_refresh_config, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_VTABLE_END }; +/* clang-format on */ /** * Main process loop for the daemon. Run until quitting has been requested. diff --git a/daemon/gamemode-gpu.c b/daemon/gamemode-gpu.c index 5debbf5..2ba977c 100644 --- a/daemon/gamemode-gpu.c +++ b/daemon/gamemode-gpu.c @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "common-helpers.h" #include "common-logging.h" -#include "gamemode-config.h" #include "gamemode.h" +#include "gamemode-config.h" #include "build-config.h" diff --git a/daemon/gamemode-ioprio.c b/daemon/gamemode-ioprio.c index 65709c0..ec6c893 100644 --- a/daemon/gamemode-ioprio.c +++ b/daemon/gamemode-ioprio.c @@ -31,10 +31,10 @@ POSSIBILITY OF SUCH DAMAGE. #define _GNU_SOURCE +#include "gamemode.h" #include "common-helpers.h" #include "common-logging.h" #include "gamemode-config.h" -#include "gamemode.h" #include #include diff --git a/daemon/gamemode-sched.c b/daemon/gamemode-sched.c index 30745b4..a03d2aa 100644 --- a/daemon/gamemode-sched.c +++ b/daemon/gamemode-sched.c @@ -31,9 +31,9 @@ POSSIBILITY OF SUCH DAMAGE. #define _GNU_SOURCE +#include "gamemode.h" #include "common-logging.h" #include "gamemode-config.h" -#include "gamemode.h" #include #include diff --git a/daemon/gamemode-tests.c b/daemon/gamemode-tests.c index 8de10e8..b9b9c3b 100644 --- a/daemon/gamemode-tests.c +++ b/daemon/gamemode-tests.c @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "common-helpers.h" #include "common-logging.h" -#include "gamemode-config.h" #include "gamemode.h" +#include "gamemode-config.h" #include "gamemode_client.h" #include diff --git a/daemon/gamemode-wine.c b/daemon/gamemode-wine.c index 4dd6278..11a6920 100644 --- a/daemon/gamemode-wine.c +++ b/daemon/gamemode-wine.c @@ -31,9 +31,9 @@ POSSIBILITY OF SUCH DAMAGE. #define _GNU_SOURCE +#include "gamemode.h" #include "common-helpers.h" #include "common-logging.h" -#include "gamemode.h" #include #include diff --git a/daemon/gamemoded.c b/daemon/gamemoded.c index 26a4f31..a6ff2cd 100644 --- a/daemon/gamemoded.c +++ b/daemon/gamemoded.c @@ -49,9 +49,9 @@ POSSIBILITY OF SUCH DAMAGE. #define _GNU_SOURCE +#include "gamemode.h" #include "common-logging.h" #include "gamemode-config.h" -#include "gamemode.h" #include "gamemode_client.h"