From: Elena Ufimtseva <ufimtseva@gmail.com>
To: apw@canonical.com, joe@perches.com
Cc: linux-kernel@vger.kernel.org, Elena Ufimtseva <ufimtseva@gmail.com>
Subject: [PATCH v2] checkpatch.pl: Check for functions without a real prototype
Date: Fri, 22 Nov 2013 17:17:44 -0500 [thread overview]
Message-ID: <1385158664-12923-1-git-send-email-ufimtseva@gmail.com> (raw)
Based on Richard Weinberger patch https://lkml.org/lkml/2012/3/16/510
Functions like this one are evil:
void foo()
{
...
}
Signed-off-by: Elena Ufimtseva <ufimtseva@gmail.com>
---
Changes since v1:
- added white space in regular expression between (), based
on comments from Joe Perches.
scripts/checkpatch.pl | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 61090e0..08c95c0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2785,6 +2785,19 @@ sub process {
"open brace '{' following function declarations go on the next line\n" . $herecurr);
}
+ if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
+ ERROR("FUNCTION_NO_PROTOTYPE",
+"Bad function definition - $1() should probably be $1(void)\n" . $herecurr .
+"\nThou shalt not, in the language of C, under any circumstances, on the
+pain of death, declare or define a function with an empty set of
+parentheses, for though in the language of C++ it meaneth the same as
+(void), in C it meaneth (...) which is of meaningless as there be no
+anchor argument by which the types of the varadic arguments can be
+expressed, and which misleadeth the compiler into allowing unsavory code
+and in some cases generate really ugly stuff for varadic handling.
+ -hpa\n");
+ }
+
# open braces for enum, union and struct go on the same line.
if ($line =~ /^.\s*{/ &&
$prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
--
1.7.10.4
next reply other threads:[~2013-11-22 22:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 22:17 Elena Ufimtseva [this message]
2013-11-22 22:45 ` Joe Perches
2013-11-22 22:48 ` Elena Ufimtseva
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=1385158664-12923-1-git-send-email-ufimtseva@gmail.com \
--to=ufimtseva@gmail.com \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®