[PATCH v3] checkpatch: Check .m, .build, .hx, .in, .json, .txt and .plist

Akihiko Odaki posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260604-checkpatch-v3-1-23fc7b12a7e4@rsg.ci.i.u-tokyo.ac.jp
Maintainers: Chao Liu <chao.liu.zevorn@gmail.com>
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH v3] checkpatch: Check .m, .build, .hx, .in, .json, .txt and .plist
Posted by Akihiko Odaki 1 month, 1 week ago
Check more text files: Objective-C, Meson, "hx", JSON, and property
list.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
Changes in v3:
- Rebased.
- Link to v2: https://lore.kernel.org/r/20250111-checkpatch-v2-1-db77a522ab6a@daynix.com
---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2189db19f540..4ec74a4e9236 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -12,7 +12,8 @@ use Term::ANSIColor qw(:constants);
 my $P = $0;
 $P =~ s@.*/@@g;
 
-our $SrcFile    = qr{\.(?:(h|c)(\.inc)?|cpp|s|S|pl|py|sh)$};
+our $SrcFile =
+	qr{\.(?:(h|c|m)(\.inc)?|cpp|s|S|pl|py|sh|build|hx|in|json|plist|txt)$};
 
 my $V = '0.31';
 

---
base-commit: 2db91528542672cf0db78b3f2cc0e22b36302b38
change-id: 20250111-checkpatch-26ea9d86c76a

Best regards,
--  
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Re: [PATCH v3] checkpatch: Check .m, .build, .hx, .in, .json, .txt and .plist
Posted by Peter Maydell 1 month ago
On Thu, 4 Jun 2026 at 11:11, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> wrote:
>
> Check more text files: Objective-C, Meson, "hx", JSON, and property
> list.
>
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>

This is missing rationale. Currently checkpatch is set up
to check source code files, and the bulk of its checks are
for source code issues. Why do we want to make it also check
non-source-code files?

> -our $SrcFile    = qr{\.(?:(h|c)(\.inc)?|cpp|s|S|pl|py|sh)$};
> +our $SrcFile =
> +       qr{\.(?:(h|c|m)(\.inc)?|cpp|s|S|pl|py|sh|build|hx|in|json|plist|txt)$};

If I run checkpatch on our .hx files, I get a lot of complaints
about trailing whitespace after "\" characters. I have a vague
memory that those are deliberate, though I forget the details.
We shouldn't add a file type to this list if it's going to
produce a lot of false positives.

thanks
-- PMM
Re: [PATCH v3] checkpatch: Check .m, .build, .hx, .in, .json, .txt and .plist
Posted by Akihiko Odaki 1 month ago
On 2026/06/08 18:31, Peter Maydell wrote:
> On Thu, 4 Jun 2026 at 11:11, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> wrote:
>>
>> Check more text files: Objective-C, Meson, "hx", JSON, and property
>> list.
>>
>> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> 
> This is missing rationale. Currently checkpatch is set up
> to check source code files, and the bulk of its checks are
> for source code issues. Why do we want to make it also check
> non-source-code files?

The intent is to check source code files. More precisely, it is intended 
to check manually-written text files that the generic text checks apply to.

> 
>> -our $SrcFile    = qr{\.(?:(h|c)(\.inc)?|cpp|s|S|pl|py|sh)$};
>> +our $SrcFile =
>> +       qr{\.(?:(h|c|m)(\.inc)?|cpp|s|S|pl|py|sh|build|hx|in|json|plist|txt)$};
> 
> If I run checkpatch on our .hx files, I get a lot of complaints
> about trailing whitespace after "\" characters. I have a vague
> memory that those are deliberate, though I forget the details.
> We shouldn't add a file type to this list if it's going to
> produce a lot of false positives.

I found the rationale in commit 09ce5f2d6bd6 ("qemu-options.hx: Fix up 
the autogenerated rST"):

 > rST does not like definition list entries with no actual
 > definition, but it is possible to work around this by putting a
 > single escaped literal space as the definition line.

So the whitespace check cannot be applied to .hx files. I'll drop .hx 
from the source file type list.

Regards,
Akihiko Odaki