* [PATCH 1/2] clang-format: do not allow short enums on a single line
@ 2026-08-19 14:39 Ahmad Fatoum
2026-08-19 14:39 ` [PATCH 2/2] clang-format: align consecutive macros Ahmad Fatoum
2026-08-24 12:13 ` [PATCH 1/2] clang-format: do not allow short enums on a single line Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-08-19 14:39 UTC (permalink / raw)
To: barebox
From: Michael Riesch <michael.riesch@wolfvision.net>
clang-format 11 introduced the option "AllowShortEnumsOnASingleLine".
Set it to "false" in order to avoid short enums of the form:
enum my_short_num { green, red };
With the option set to "false", they will be converted to
enum my_short_num {
green,
red
};
which is consistent with the definition of enums with more items.
Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Riesch <michael.riesch@collabora.com>
Link: https://lore.pengutronix.de/20250210-clang-format-fixes-v2-1-37894413bbee@collabora.com
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
.clang-format | 1 +
1 file changed, 1 insertion(+)
diff --git a/.clang-format b/.clang-format
index be6c955e731c..1f310cfef5c6 100644
--- a/.clang-format
+++ b/.clang-format
@@ -19,6 +19,7 @@ AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
+AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 2/2] clang-format: align consecutive macros
2026-08-19 14:39 [PATCH 1/2] clang-format: do not allow short enums on a single line Ahmad Fatoum
@ 2026-08-19 14:39 ` Ahmad Fatoum
2026-08-24 12:13 ` [PATCH 1/2] clang-format: do not allow short enums on a single line Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-08-19 14:39 UTC (permalink / raw)
To: barebox
From: Michael Riesch <michael.riesch@wolfvision.net>
clang-format 9 introduced the option "AlignConsecutiveMacros".
Set it to "AcrossEmptyLinesAndComments" in order to avoid macro
definitions of the form:
#define MAGIC_REGISTER_1 0x42
#define MAGIC_REGISTER_BIT_FLIP BIT(2)
/* important comment */
#define MAGIC_REGISTER_BIT_ENABLE BIT(12)
#define MAGIC_REGISTER_2 0x43
With the option set to "AcrossEmptyLinesAndComments", they will
be converted to
#define MAGIC_REGISTER_1 0x42
#define MAGIC_REGISTER_BIT_FLIP BIT(2)
/* important comment */
#define MAGIC_REGISTER_BIT_ENABLE BIT(12)
#define MAGIC_REGISTER_2 0x43
which seems to be the convention in the kernel code base.
Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Riesch <michael.riesch@collabora.com>
Link: https://lore.pengutronix.de/20250210-clang-format-fixes-v2-2-37894413bbee@collabora.com
Suggested-by: Fabian Pflug <f.pflug@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
.clang-format | 1 +
1 file changed, 1 insertion(+)
diff --git a/.clang-format b/.clang-format
index 1f310cfef5c6..d0846dccc0c3 100644
--- a/.clang-format
+++ b/.clang-format
@@ -13,6 +13,7 @@ AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
+AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] clang-format: do not allow short enums on a single line
2026-08-19 14:39 [PATCH 1/2] clang-format: do not allow short enums on a single line Ahmad Fatoum
2026-08-19 14:39 ` [PATCH 2/2] clang-format: align consecutive macros Ahmad Fatoum
@ 2026-08-24 12:13 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-08-24 12:13 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Wed, 19 Aug 2026 16:39:55 +0200, Ahmad Fatoum wrote:
> clang-format 11 introduced the option "AllowShortEnumsOnASingleLine".
> Set it to "false" in order to avoid short enums of the form:
>
> enum my_short_num { green, red };
>
> With the option set to "false", they will be converted to
>
> [...]
Applied, thanks!
[1/2] clang-format: do not allow short enums on a single line
https://git.pengutronix.de/cgit/barebox/commit/?id=60d0f532f5e9 (link may not be stable)
[2/2] clang-format: align consecutive macros
https://git.pengutronix.de/cgit/barebox/commit/?id=e06de817fd44 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-24 12:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-19 14:39 [PATCH 1/2] clang-format: do not allow short enums on a single line Ahmad Fatoum
2026-08-19 14:39 ` [PATCH 2/2] clang-format: align consecutive macros Ahmad Fatoum
2026-08-24 12:13 ` [PATCH 1/2] clang-format: do not allow short enums on a single line Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox