From 27ec56ad0809cf89f4b925a34c461a12c0afdee9 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 5 Jul 2026 14:13:04 +0200 Subject: [PATCH] Update .clang-format: list_for_each* should be treated like for loops otherwise you get weird side effects with clang-format. --- .clang-format | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 9de60d808..2ee5639c0 100644 --- a/.clang-format +++ b/.clang-format @@ -46,7 +46,33 @@ AlignTrailingComments: OverEmptyLines: 0 IndentCaseLabels: true # case labels are indented one level -SpaceBeforeParens: ControlStatements # "if (" but "call(" / "sizeof(" + +# Our list_for_each* macros (include/list.h) are loops. Without this, +# clang-format thinks they are function calls and then joins the loop +# body onto the same line, like: list_for_each_entry(...) if (x) y(); +ForEachMacros: + - list_for_each + - list_for_each_prev + - list_for_each_safe + - list_for_each_prev_safe + - list_for_each_entry + - list_for_each_entry2 + - list_for_each_entry_reverse + - list_for_each_entry_continue + - list_for_each_entry_continue_reverse + - list_for_each_entry_from + - list_for_each_entry_safe + - list_for_each_entry_safe_continue + - list_for_each_entry_safe_from + - list_for_each_entry_safe_reverse + +# "if (" but "call(" / "sizeof(". The foreach option is so the macros +# above are written as "list_for_each_entry(" without a space, like a +# function call, which is how the code already does it. +SpaceBeforeParens: Custom +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: false PointerAlignment: Right # "type *name" DerivePointerAlignment: false BreakBeforeBinaryOperators: None # wrap after && / ||, not before