Skip to content

checkpatch: Missing line after declaration not enforced if line is removed #98976

@Thalley

Description

@Thalley

Describe the bug

If a user attempts to add something like

void foo(void)
{
	int a = 0;
	if (a == 0) {
		return;
	}
}

then checkpatch.pl would return an error like

WARNING : Test Checkpatch warning: 
LINE_SPACING: Missing a blank line after declarations

as it should be

void foo(void)
{
	int a = 0;

	if (a == 0) {
		return;
	}
}

However if the existing code is

void foo(void)
{
	int a = 0;

	if (a == 0) {
		return;
	}
}

and a commit removes the newline so that it becomes

void foo(void)
{
	int a = 0;
	if (a == 0) {
		return;
	}
}

Then the missing newline is not captured by checkpatch.pl, and it passes CI.

Regression

  • This is a regression.

Steps to reproduce

N/A

Relevant log output

N/A

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

8b2c75a

Additional Context

It has been seen in a few PRs (e.g. #98406), so it's valid issue, but it's fairly harmless.

Metadata

Metadata

Assignees

Labels

area: Coding GuidelinesCoding guidelines and stylebugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions