* [PATCH] checkpatch: Prefer DEFINE_TYPES() over type_init / type_register_static
@ 2023-05-24 14:54 Philippe Mathieu-Daudé
2023-05-24 17:16 ` Richard Henderson
2023-05-25 11:32 ` Daniel Henrique Barboza
0 siblings, 2 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-05-24 14:54 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel Henrique Barboza
When multiple QOM types are registered in the same file, it
is clearer and simpler to use the the DEFINE_TYPES() macro.
Add a rule to checkpatch.pl to suggest using DEFINE_TYPES()
instead of type_init() / type_register_static().
Suggested-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index eeaec436eb..db8029635c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2877,6 +2877,12 @@ sub process {
if ($line =~ /^module_init\s*\(/) {
ERROR("please use block_init(), type_init() etc. instead of module_init()\n" . $herecurr);
}
+
+# recommend DEFINE_TYPES() over type_init()/type_register_static()
+ if ($line =~ /\b(type_init|type_register_static)\(/) {
+ WARN("consider using DEFINE_TYPES() in preference to type_init()\n" . $herecurr);
+ }
+
# check for various ops structs, ensure they are const.
my $struct_ops = qr{AIOCBInfo|
BdrvActionOps|
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] checkpatch: Prefer DEFINE_TYPES() over type_init / type_register_static
2023-05-24 14:54 [PATCH] checkpatch: Prefer DEFINE_TYPES() over type_init / type_register_static Philippe Mathieu-Daudé
@ 2023-05-24 17:16 ` Richard Henderson
2023-05-25 11:32 ` Daniel Henrique Barboza
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2023-05-24 17:16 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Daniel Henrique Barboza
On 5/24/23 07:54, Philippe Mathieu-Daudé wrote:
> When multiple QOM types are registered in the same file, it
> is clearer and simpler to use the the DEFINE_TYPES() macro.
>
> Add a rule to checkpatch.pl to suggest using DEFINE_TYPES()
> instead of type_init() / type_register_static().
>
> Suggested-by: Daniel Henrique Barboza<dbarboza@ventanamicro.com>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> scripts/checkpatch.pl | 6 ++++++
> 1 file changed, 6 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] checkpatch: Prefer DEFINE_TYPES() over type_init / type_register_static
2023-05-24 14:54 [PATCH] checkpatch: Prefer DEFINE_TYPES() over type_init / type_register_static Philippe Mathieu-Daudé
2023-05-24 17:16 ` Richard Henderson
@ 2023-05-25 11:32 ` Daniel Henrique Barboza
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-25 11:32 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 5/24/23 11:54, Philippe Mathieu-Daudé wrote:
> When multiple QOM types are registered in the same file, it
> is clearer and simpler to use the the DEFINE_TYPES() macro.
>
> Add a rule to checkpatch.pl to suggest using DEFINE_TYPES()
> instead of type_init() / type_register_static().
>
Nice!
> Suggested-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> scripts/checkpatch.pl | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index eeaec436eb..db8029635c 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2877,6 +2877,12 @@ sub process {
> if ($line =~ /^module_init\s*\(/) {
> ERROR("please use block_init(), type_init() etc. instead of module_init()\n" . $herecurr);
> }
> +
> +# recommend DEFINE_TYPES() over type_init()/type_register_static()
> + if ($line =~ /\b(type_init|type_register_static)\(/) {
> + WARN("consider using DEFINE_TYPES() in preference to type_init()\n" . $herecurr);
> + }
> +
> # check for various ops structs, ensure they are const.
> my $struct_ops = qr{AIOCBInfo|
> BdrvActionOps|
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-25 11:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-24 14:54 [PATCH] checkpatch: Prefer DEFINE_TYPES() over type_init / type_register_static Philippe Mathieu-Daudé
2023-05-24 17:16 ` Richard Henderson
2023-05-25 11:32 ` Daniel Henrique Barboza
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).