From f28e23e3eb357a7704e708bda14d918692440995 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 7 Oct 2025 11:21:01 +1000 Subject: [PATCH] scripts: checkpatch.pl: relax `Missing a blank line` Relax the `Missing a blank line after declarations` checkpatch error by loosening the requirements for a macro to be treated as one that declared a variable. Currently the regex matches the pattern `DECLARE` or `DEFINE`, as long as there are between 1 and 6 trailing `_FOO` components to the macro name (e.g. `DECLARE_MY_TYPE()`). Zephyr however contains many macros that don't have the trailing components but still resolve to variables (e.g. `ATOMIC_DEFINE`, `K_MUTEX_DEFINE, etc`). By changing `{1,6}` to `{0,6}`, we remove the requirement for the trailing `_FOO` component(s) while still allowing them. This stops checkpatch from erroring on patterns like this: ``` struct driver_data { uint16_t some_value; ATOMIC_DEFINE(some_atomic, 16); }; ``` Signed-off-by: Jordan Yates --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 8f964bc654b2e..7070500ad2e10 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -862,7 +862,7 @@ sub build_types { our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)}; our $declaration_macros = qr{(?x: - (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(| + (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){0,6}\s*\(| (?:$Storage\s+)?[HLP]?LIST_HEAD\s*\(| (?:SKCIPHER_REQUEST|SHASH_DESC|AHASH_REQUEST)_ON_STACK\s*\( )};