qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] checkpatch: Prefer DEFINE_TYPES() over type_init / type_regi


From: Daniel Henrique Barboza
Subject: Re: [PATCH] checkpatch: Prefer DEFINE_TYPES() over type_init / type_register_static
Date: Thu, 25 May 2023 08:32:09 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0



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|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]