]> Git Repo - qemu.git/blobdiff - scripts/checkpatch.pl
scripts/replay-dump.py: replay log dumper
[qemu.git] / scripts / checkpatch.pl
index ce9f08eb9f5d13da8718408bf49f2b12f562efc9..57daae05ea181ca3aac849e434255e89d2f7445e 100755 (executable)
@@ -265,6 +265,7 @@ our @typeList = (
        qr{${Ident}_handler_fn},
        qr{target_(?:u)?long},
        qr{hwaddr},
+       qr{xml${Ident}},
 );
 
 # This can be modified by sub possible.  Since it can be empty, be careful
@@ -1446,9 +1447,10 @@ sub process {
 # check we are in a valid source file if not then ignore this hunk
                next if ($realfile !~ /$SrcFile/);
 
-#90 column limit
+#90 column limit; exempt URLs, if no other words on line
                if ($line =~ /^\+/ &&
                    !($line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
+                   !($rawline =~ /^[^[:alnum:]]*https?:\S*$/) &&
                    $length > 80)
                {
                        if ($length > 90) {
@@ -1622,6 +1624,11 @@ sub process {
                        }
                }
 
+# 'do ... while (0/false)' only makes sense in macros, without trailing ';'
+               if ($line =~ /while\s*\((0|false)\);/) {
+                       ERROR("suspicious ; after while (0)\n" . $herecurr);
+               }
+
 # Check relative indent for conditionals and blocks.
                if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
                        my ($s, $c) = ($stat, $cond);
@@ -2346,8 +2353,9 @@ sub process {
                        }
                }
 
-# check for missing bracing round if etc
-               if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) {
+# check for missing bracing around if etc
+               if ($line =~ /(^.*)\b(?:if|while|for)\b/ &&
+                       $line !~ /\#\s*if/) {
                        my ($level, $endln, @chunks) =
                                ctx_statement_full($linenr, $realcnt, 1);
                         if ($dbg_adv_apw) {
@@ -2475,8 +2483,11 @@ sub process {
 
 # no volatiles please
                my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
-               if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
-                       ERROR("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
+               if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/ &&
+                    $line !~ /sig_atomic_t/ &&
+                    !ctx_has_comment($first_line, $linenr)) {
+                       my $msg = "Use of volatile is usually wrong, please add a comment\n" . $herecurr;
+                        ERROR($msg);
                }
 
 # warn about #if 0
@@ -2575,6 +2586,11 @@ sub process {
                        ERROR("__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
                }
 
+# recommend g_path_get_* over g_strdup(basename/dirname(...))
+               if ($line =~ /\bg_strdup\s*\(\s*(basename|dirname)\s*\(/) {
+                       WARN("consider using g_path_get_$1() in preference to g_strdup($1())\n" . $herecurr);
+               }
+
 # recommend qemu_strto* over strto* for numeric conversions
                if ($line =~ /\b(strto[^kd].*?)\s*\(/) {
                        ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);
@@ -2603,7 +2619,6 @@ sub process {
                                SCSIBusInfo|
                                SCSIReqOps|
                                Spice[A-Z][a-zA-Z0-9]*Interface|
-                               TPMDriverOps|
                                USBDesc[A-Z][a-zA-Z0-9]*|
                                VhostOps|
                                VMStateDescription|
This page took 0.025 seconds and 4 git commands to generate.