From patchwork Sat Jun 7 15:42:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 357102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 04AB5140092 for ; Sun, 8 Jun 2014 01:43:07 +1000 (EST) Received: from localhost ([::1]:52165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtIls-0003lp-Uy for incoming@patchwork.ozlabs.org; Sat, 07 Jun 2014 11:43:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtIla-0003Rc-F6 for qemu-devel@nongnu.org; Sat, 07 Jun 2014 11:42:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WtIlW-0003Uh-A0 for qemu-devel@nongnu.org; Sat, 07 Jun 2014 11:42:46 -0400 Received: from qemu.weilnetz.de ([37.221.198.45]:36298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtIlW-0003UL-0S; Sat, 07 Jun 2014 11:42:42 -0400 Received: by qemu.weilnetz.de (Postfix, from userid 1000) id 0726B17F5D0; Sat, 7 Jun 2014 17:42:38 +0200 (CEST) From: Stefan Weil To: qemu-devel@nongnu.org Date: Sat, 7 Jun 2014 17:42:37 +0200 Message-Id: <1402155757-24977-1-git-send-email-sw@weilnetz.de> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 37.221.198.45 Cc: qemu-trivial@nongnu.org, Peter Maydell , Stefan Weil Subject: [Qemu-devel] [PATCH] checkpatch: Check *.cc files and allow C99 comments for C++ code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org QEMU uses both *.cc and *.cpp for some files with C++ code: disas/libvixl/utils.cc disas/libvixl/a64/disasm-a64.cc disas/libvixl/a64/instructions-a64.cc disas/libvixl/a64/decoder-a64.cc disas/arm-a64.cc qga/vss-win32/provider.cpp qga/vss-win32/install.cpp qga/vss-win32/requester.cpp *.cpp files were already checked. Add the cc pattern, so *.cc are checked now, too. Comments with // are quite common in C++ code, so don't forbid them. Signed-off-by: Stefan Weil --- The current *.cc files now trigger several warnings and errors, but that's not a good reason why they should be suppressed. Regards, Stefan Weil scripts/checkpatch.pl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9d46e5a..f29bdbe 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1363,7 +1363,7 @@ sub process { # Check for incorrect file permissions if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) { my $permhere = $here . "FILE: $realfile\n"; - if ($realfile =~ /(Makefile|Kconfig|\.c|\.cpp|\.h|\.S|\.tmpl)$/) { + if ($realfile =~ /(Makefile|Kconfig|\.c|\.cc|\.cpp|\.h|\.S|\.tmpl)$/) { ERROR("do not set execute permissions for source files\n" . $permhere); } } @@ -1460,7 +1460,7 @@ sub process { } # check we are in a valid source file if not then ignore this hunk - next if ($realfile !~ /\.(h|c|cpp|s|S|pl|sh)$/); + next if ($realfile !~ /\.(h|c|cc|cpp|s|S|pl|sh)$/); #80 column limit if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && @@ -1495,7 +1495,7 @@ sub process { } # check we are in a valid source file C or perl if not then ignore this hunk - next if ($realfile !~ /\.(h|c|cpp|pl)$/); + next if ($realfile !~ /\.(h|c|cc|cpp|pl)$/); # in QEMU, no tabs are allowed if ($rawline =~ /^\+.*\t/) { @@ -1505,7 +1505,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|cc|cpp)$/); # check for RCS/CVS revision markers if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { @@ -1792,7 +1792,7 @@ sub process { } # no C99 // comments - if ($line =~ m{//}) { + if (($line =~ m{//}) && !($realfile =~ /(\.cc|\.cpp)$/)) { ERROR("do not use C99 // comments\n" . $herecurr); } # Remove C99 comments. @@ -1970,7 +1970,7 @@ sub process { { # Ignore 'catch (...)' in C++ - } elsif ($name =~ /^catch$/ && $realfile =~ /(\.cpp|\.h)$/) { + } elsif ($name =~ /^catch$/ && $realfile =~ /(\.cc|\.cpp|\.h)$/) { # cpp #define statements have non-optional spaces, ie # if there is a space between the name and the open @@ -2067,7 +2067,7 @@ sub process { # Ignore : used in class declaration in C++ } elsif ($opv eq ':B' && $ctx =~ /Wx[WE]/ && - $line =~ /class/ && $realfile =~ /(\.cpp|\.h)$/) { + $line =~ /class/ && $realfile =~ /(\.cc|\.cpp|\.h)$/) { # No spaces for: # -> @@ -2095,7 +2095,7 @@ sub process { } elsif ($op eq '!' || $op eq '~' || $opv eq '*U' || $opv eq '-U' || $opv eq '&U' || $opv eq '&&U') { - if ($op eq '~' && $ca =~ /::$/ && $realfile =~ /(\.cpp|\.h)$/) { + if ($op eq '~' && $ca =~ /::$/ && $realfile =~ /(\.cc|\.cpp|\.h)$/) { # '~' used as a name of Destructor } elsif ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { @@ -2145,7 +2145,7 @@ sub process { } elsif ($ctx !~ /[EWC]x[CWE]/) { my $ok = 0; - if ($realfile =~ /\.cpp|\.h$/) { + if ($realfile =~ /\.cc|\.cpp|\.h$/) { # Ignore template arguments <...> in C++ if (($op eq '<' || $op eq '>') && $line =~ /<.*>/) { $ok = 1;