]> Git Repo - qemu.git/blobdiff - scripts/checkpatch.pl
net/colo.c: Add vnet packet parse feature in colo-proxy
[qemu.git] / scripts / checkpatch.pl
index f0845429342a926aa4691eefefcad92e174ca25f..4e911228137cb909bfc9803dd7cccabff402d67f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # (c) 2001, Dave Jones. (the file handling bit)
 # (c) 2005, Joel Schopp <[email protected]> (the ugly bit)
 # (c) 2007,2008, Andy Whitcroft <[email protected]> (new conditions, test suite)
@@ -6,6 +6,7 @@
 # Licensed under the terms of the GNU GPL License version 2
 
 use strict;
+use warnings;
 
 my $P = $0;
 $P =~ s@.*/@@g;
@@ -2472,6 +2473,10 @@ sub process {
                if ($line =~ /\b(strto[^kd].*?)\s*\(/) {
                        ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);
                }
+# recommend sigaction over signal for portability, when establishing a handler
+               if ($line =~ /\bsignal\s*\(/ && !($line =~ /SIG_(?:IGN|DFL)/)) {
+                       ERROR("use sigaction to establish signal handlers; signal is not portable\n" . $herecurr);
+               }
 # check for module_init(), use category-specific init macros explicitly please
                if ($line =~ /^module_init\s*\(/) {
                        ERROR("please use block_init(), type_init() etc. instead of module_init()\n" . $herecurr);
@@ -2528,9 +2533,14 @@ sub process {
                                error_setg_file_open|
                                error_set|
                                error_prepend|
+                               warn_reportf_err|
                                error_reportf_err|
                                error_vreport|
-                               error_report}x;
+                               warn_vreport|
+                               info_vreport|
+                               error_report|
+                               warn_report|
+                               info_report}x;
 
        if ($rawline =~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) {
                ERROR("Error messages should not contain newlines\n" . $herecurr);
@@ -2571,6 +2581,27 @@ sub process {
                if ($line =~ /\bbzero\(/) {
                        ERROR("use memset() instead of bzero()\n" . $herecurr);
                }
+               my $non_exit_glib_asserts = qr{g_assert_cmpstr|
+                                               g_assert_cmpint|
+                                               g_assert_cmpuint|
+                                               g_assert_cmphex|
+                                               g_assert_cmpfloat|
+                                               g_assert_true|
+                                               g_assert_false|
+                                               g_assert_nonnull|
+                                               g_assert_null|
+                                               g_assert_no_error|
+                                               g_assert_error|
+                                               g_test_assert_expected_messages|
+                                               g_test_trap_assert_passed|
+                                               g_test_trap_assert_stdout|
+                                               g_test_trap_assert_stdout_unmatched|
+                                               g_test_trap_assert_stderr|
+                                               g_test_trap_assert_stderr_unmatched}x;
+               if ($realfile !~ /^tests\// &&
+                       $line =~ /\b(?:$non_exit_glib_asserts)\(/) {
+                       ERROR("Use g_assert or g_assert_not_reached\n". $herecurr);
+               }
        }
 
        # If we have no input at all, then there is nothing to report on
This page took 0.025818 seconds and 4 git commands to generate.