[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120322141005.1abe7b1e@wrlaptop>
Date: Thu, 22 Mar 2012 14:10:05 -0500
From: Peter Seebach <peter.seebach@...driver.com>
To: Phil Carmody <ext-phil.2.carmody@...ia.com>
CC: "ext H. Peter Anvin" <hpa@...or.com>, Jiri Slaby <jslaby@...e.cz>,
<apw@...onical.com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] checkpatch.pl: thou shalt not use () or (...) in
function declarations
On Thu, 22 Mar 2012 19:48:02 +0200
Phil Carmody <ext-phil.2.carmody@...ia.com> wrote:
> While empty paramter lists in function definitions are not technically
> wrong, those situations are rare enough that it's worth encouraging
> people towards a more uniform, always unambiguous, style.
Typo here ("paramter").
You don't need to check for (...). That doesn't actually exist, and
gcc rejects it (as it should). The description of () as meaning (...)
is a (slight) oversimplification. As to the () case:
The rules here are complicated. Complicated enough that I don't even
TRY to remember them. Fundamentally, f() is equivalent to either
f(void) or f(please do unpleasant things to me with railroad spikes).
I would definitely endorse a policy discouraging its use.
I can only think of one exception, and it's inapplicable. The
exception: Imagine that you wish to write a wrapper for a function
like scandir, which takes a function pointer as an argument, and you
wish the wrapper to work on two systems where the arguments passed to
the function pointer are of different types, but you yourself will
never actually see or care about the arguments; you just want to pass
the function pointer around. Then it could make sense to declare the
argument as int (*compar)(). But that's a once-a-lifetime use case,
give or take.
-s
--
Listen, get this. Nobody with a good compiler needs to be justified.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists