]> Git Repo - qemu.git/blobdiff - scripts/checkpatch.pl
virtio-pci: fix proxy->vector_irqfd leak in virtio_pci_set_guest_notifiers
[qemu.git] / scripts / checkpatch.pl
index bbcd25ae05775b17d1521ed9222a495b447a102e..6ecabfb2b52019428e3a83a67bbafe2c841cb769 100755 (executable)
@@ -223,11 +223,11 @@ our $Sparse       = qr{
 our $Attribute = qr{
                        const|
                        volatile|
-                       QEMU_NORETURN|
-                       QEMU_WARN_UNUSED_RESULT|
-                       QEMU_SENTINEL|
+                       G_NORETURN|
+                       G_GNUC_WARN_UNUSED_RESULT|
+                       G_GNUC_NULL_TERMINATED|
                        QEMU_PACKED|
-                       GCC_FMT_ATTR
+                       G_GNUC_PRINTF
                  }x;
 our $Modifier;
 our $Inline    = qr{inline};
@@ -307,7 +307,6 @@ our @typeList = (
        qr{target_(?:u)?long},
        qr{hwaddr},
         # external libraries
-       qr{xml${Ident}},
        qr{xen\w+_handle},
        # Glib definitions
        qr{gchar},
@@ -399,7 +398,12 @@ if ($chk_branch) {
        my $num_patches = @patches;
        for my $hash (@patches) {
                my $FILE;
-               open($FILE, '-|', "git", "show", "--patch-with-stat", $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;
@@ -1663,6 +1667,7 @@ sub process {
 # some scripts we imported from other projects.
                next if ($realfile =~ /\.(s|S)$/);
                next if ($realfile =~ /(checkpatch|get_maintainer)\.pl$/);
+               next if ($realfile =~ /^target\/hexagon\/imported\/*/);
 
                if ($rawline =~ /^\+.*\t/) {
                        my $herevet = "$here\n" . cat_vet($rawline) . "\n";
@@ -1676,8 +1681,10 @@ sub process {
 # Block comment styles
 
                # Block comments use /* on a line of its own
-               if ($rawline !~ m@^\+.*/\*.*\*/[ \t)}]*$@ &&    #inline /*...*/
-                   $rawline =~ m@^\+.*/\*\*?+[ \t]*[^ \t]@) { # /* or /** non-blank
+               my $commentline = $rawline;
+               while ($commentline =~ s@^(\+.*)/\*.*\*/@$1@o) { # remove inline /*...*/
+               }
+               if ($commentline =~ m@^\+.*/\*\*?+[ \t]*[^ \t]@) { # /* or /** non-blank
                        WARN("Block comments use a leading /* on a separate line\n" . $herecurr);
                }
 
@@ -2827,8 +2834,8 @@ sub process {
                }
 
 # check for pointless casting of g_malloc return
-               if ($line =~ /\*\s*\)\s*g_(try)?(m|re)alloc(0?)(_n)?\b/) {
-                       if ($2 == 'm') {
+               if ($line =~ /\*\s*\)\s*g_(try|)(m|re)alloc(0?)(_n)?\b/) {
+                       if ($2 eq 'm') {
                                ERROR("unnecessary cast may hide bugs, use g_$1new$3 instead\n" . $herecurr);
                        } else {
                                ERROR("unnecessary cast may hide bugs, use g_$1renew$3 instead\n" . $herecurr);
@@ -2845,6 +2852,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);
@@ -2873,6 +2885,7 @@ sub process {
                                SCSIBusInfo|
                                SCSIReqOps|
                                Spice[A-Z][a-zA-Z0-9]*Interface|
+                               TypeInfo|
                                USBDesc[A-Z][a-zA-Z0-9]*|
                                VhostOps|
                                VMStateDescription|
@@ -2964,10 +2977,10 @@ sub process {
                        ERROR("use memset() instead of bzero()\n" . $herecurr);
                }
                if ($line =~ /\bgetpagesize\(\)/) {
-                       ERROR("use qemu_real_host_page_size instead of getpagesize()\n" . $herecurr);
+                       ERROR("use qemu_real_host_page_size() instead of getpagesize()\n" . $herecurr);
                }
                if ($line =~ /\bsysconf\(_SC_PAGESIZE\)/) {
-                       ERROR("use qemu_real_host_page_size instead of sysconf(_SC_PAGESIZE)\n" . $herecurr);
+                       ERROR("use qemu_real_host_page_size() instead of sysconf(_SC_PAGESIZE)\n" . $herecurr);
                }
                my $non_exit_glib_asserts = qr{g_assert_cmpstr|
                                                g_assert_cmpint|
This page took 0.026658 seconds and 4 git commands to generate.