]> git.proxmox.com Git - mirror_qemu.git/blobdiff - scripts/checkpatch.pl
qapi/commands: Optionally generate trace for QMP commands
[mirror_qemu.git] / scripts / checkpatch.pl
index 88c858f67cbb13de1c87adafb08a4f02d2d2f92f..5caa739db4866b9ae559db20ba369b59eb71cc1b 100755 (executable)
@@ -12,7 +12,7 @@ use Term::ANSIColor qw(:constants);
 my $P = $0;
 $P =~ s@.*/@@g;
 
-our $SrcFile    = qr{\.(?:h|c|cpp|s|S|pl|py|sh)$};
+our $SrcFile    = qr{\.(?:(h|c)(\.inc)?|cpp|s|S|pl|py|sh)$};
 
 my $V = '0.31';
 
@@ -399,7 +399,12 @@ if ($chk_branch) {
        my $num_patches = @patches;
        for my $hash (@patches) {
                my $FILE;
-               open($FILE, '-|', "git", "show", $hash) ||
+               open($FILE, '-|', "git",
+                     "-c", "diff.renamelimit=0",
+                     "-c", "diff.renames=True",
+                     "-c", "diff.algorithm=histogram",
+                     "show",
+                     "--patch-with-stat", $hash) ||
                        die "$P: git show $hash - $!\n";
                while (<$FILE>) {
                        chomp;
@@ -1499,7 +1504,7 @@ sub process {
                        $is_patch = 1;
                }
 
-               if ($line =~ /^Author: .*via Qemu-devel.*<qemu-devel\@nongnu.org>/) {
+               if ($line =~ /^(Author|From): .* via .*<qemu-devel\@nongnu.org>/) {
                    ERROR("Author email address is mangled by the mailing list\n" . $herecurr);
                }
 
@@ -1530,7 +1535,10 @@ sub process {
                    ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
                     $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
                     ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
-                     (defined($1) || defined($2))))) {
+                     (defined($1) || defined($2)))) &&
+                      !(($realfile ne '') &&
+                        defined($acpi_testexpected) &&
+                        ($realfile eq $acpi_testexpected))) {
                        $reported_maintainer_file = 1;
                        WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
                }
@@ -1668,7 +1676,7 @@ sub process {
                }
 
 # check we are in a valid C source file if not then ignore this hunk
-               next if ($realfile !~ /\.(h|c|cpp)$/);
+               next if ($realfile !~ /\.((h|c)(\.inc)?|cpp)$/);
 
 # Block comment styles
 
@@ -2842,6 +2850,11 @@ sub process {
                        WARN("consider using g_path_get_$1() in preference to g_strdup($1())\n" . $herecurr);
                }
 
+# enforce g_memdup2() over g_memdup()
+               if ($line =~ /\bg_memdup\s*\(/) {
+                       ERROR("use g_memdup2() instead of unsafe g_memdup()\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);