Skip to content

Conversation

JordanYates
Copy link
Contributor

@JordanYates JordanYates commented Oct 7, 2025

Relax the Missing a blank line after declarations checkpatch error by loosening the requirements for a macro to be treated as one that declares 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);
};

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 <jordan@embeint.com>
@zephyrbot zephyrbot added area: Linters size: XS A PR changing only a single line of code labels Oct 7, 2025
Copy link

sonarqubecloud bot commented Oct 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Linters size: XS A PR changing only a single line of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants