From: Stefan Weil <sw@weilnetz.de>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
Stefan Weil <sw@weilnetz.de>
Subject: [Qemu-devel] [PATCH] checkpatch: Check *.cc files and allow C99 comments for C++ code
Date: Sat, 7 Jun 2014 17:42:37 +0200 [thread overview]
Message-ID: <1402155757-24977-1-git-send-email-sw@weilnetz.de> (raw)
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 <sw@weilnetz.de>
---
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;
--
1.7.10.4
next reply other threads:[~2014-06-07 15:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-07 15:42 Stefan Weil [this message]
2014-06-07 15:58 ` [Qemu-devel] [PATCH] checkpatch: Check *.cc files and allow C99 comments for C++ code Peter Maydell
2014-06-07 16:10 ` Stefan Weil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1402155757-24977-1-git-send-email-sw@weilnetz.de \
--to=sw@weilnetz.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).