From: Steven Cole <elenstev@mesatop.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Question about style when converting from K&R to ANSI C.
Date: 01 Jun 2003 21:15:27 -0600 [thread overview]
Message-ID: <1054523726.19551.156.camel@spc> (raw)
In-Reply-To: <1054519757.161606@palladium.transmeta.com>
On Sun, 2003-06-01 at 20:09, Linus Torvalds wrote:
> In article <20030601132626.GA3012@work.bitmover.com>,
> Larry McVoy <lm@bitmover.com> wrote:
> >On Sat, May 31, 2003 at 11:56:16PM -0600, Steven Cole wrote:
> >> Proposed conversion:
> >>
> >> int foo(void)
> >> {
> >> /* body here */
> >> }
> >
> >Sometimes it is nice to be able to see function names with a
> >
> > grep '^[a-zA-Z].*(' *.c
> >
> >which is why I've always preferred
> >
> >int
> >foo(void)
> >{
> > /* body here */
> >}
>
> That makes no sense.
>
> Do you write your normal variable definitions like
>
> int
> a,b,c;
>
> too? No you don't, because that would be totally idiotic.
>
> A function declaration is no different. The type of the function is very
> important to the function itself (along with the arguments), and I
> personally want to see _all_ of it when I grep for functions.
>
> You should just do
>
> grep -i '^[a-z_ ]*(' *.c
>
> and you'll get a nice function declaration with the standard kernel
> coding style.
>
> And I personally don't normally do "grep for random function
> declarations", that just sounds like a contrieved example. I grep for
> specific function names to find usage, and then it's _doubly_ important
> to see that the return (and argument) types match and make sense.
>
> So I definitely prefer all the arguments on the same line too, even if
> that makes the line be closer to 100 chars than 80. The zlib K&R->ANSI
> conversion was a special case, and I'd be happy if somebody were to have
> the energy to convert it all the way (which implies moving comments
> around etc).
>
How is this? I don't know about the energy part as xor'ed with itself
leaves the value unchanged right now.
I've tried to follow Documentation/kernel-doc-nano-HOWTO.txt
as suggested by acme.
Putting all the arguments on the same line gives 103 characters, if I
counted correctly. Others will be longer, so this is chosen as a folded
example.
Steven
--- linux/lib/zlib_inflate/inftrees.c.orig 2003-06-01 20:50:57.000000000 -0600
+++ linux/lib/zlib_inflate/inftrees.c 2003-06-01 20:58:51.000000000 -0600
@@ -288,14 +288,17 @@
return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
}
+/**
+ * zlib_inflate_trees_bits:
+ * @uIntf *c: 19 code lengths
+ * @uIntf *bb: bits tree desired/actual depth
+ * @inflate_huft * FAR *tb: bits tree result
+ * @inflate_huft *hp: space for trees
+ * @z_streamp z: for messages
+ */
-int zlib_inflate_trees_bits(
- uIntf *c, /* 19 code lengths */
- uIntf *bb, /* bits tree desired/actual depth */
- inflate_huft * FAR *tb, /* bits tree result */
- inflate_huft *hp, /* space for trees */
- z_streamp z /* for messages */
-)
+int zlib_inflate_trees_bits(uIntf *c, uIntf *bb, inflate_huft * FAR *tb,
+ inflate_huft *hp, z_streamp z)
{
int r;
uInt hn = 0; /* hufts used in space */
next prev parent reply other threads:[~2003-06-02 3:02 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-01 5:56 Question about style when converting from K&R to ANSI C Steven Cole
2003-06-01 6:39 ` Arnaldo Carvalho de Melo
2003-06-01 6:43 ` Zwane Mwaikambo
2003-06-01 13:14 ` Alan Cox
2003-06-01 19:10 ` Zwane Mwaikambo
2003-06-01 13:26 ` Larry McVoy
2003-06-01 13:49 ` Willy Tarreau
2003-06-01 14:06 ` Larry McVoy
2003-06-01 14:22 ` Willy Tarreau
2003-06-01 15:02 ` Steven Cole
2003-06-01 15:09 ` Larry McVoy
2003-06-01 15:50 ` Steven Cole
2003-06-01 16:02 ` Larry McVoy
2003-06-01 16:18 ` Steven Cole
2003-06-01 23:01 ` Paul Mackerras
2003-06-01 23:30 ` Steven Cole
2003-06-03 3:29 ` Robert White
2003-06-01 16:04 ` Jonathan Lundell
2003-06-01 16:11 ` Larry McVoy
2003-06-01 16:46 ` Steven Cole
2003-06-01 16:52 ` Larry McVoy
2003-06-01 17:18 ` Steven Cole
2003-06-02 12:39 ` Jesse Pollard
2003-06-03 3:15 ` Robert White
2003-06-01 13:53 ` Scott Robert Ladd
2003-06-02 2:09 ` Linus Torvalds
2003-06-02 2:21 ` Larry McVoy
2003-06-02 2:26 ` Davide Libenzi
2003-06-02 3:15 ` Steven Cole [this message]
2003-06-02 15:54 ` Erik Hensema
2003-06-03 12:32 ` Martin Waitz
2003-06-03 12:45 ` Dave Jones
2003-06-03 12:51 ` Jörn Engel
2003-06-03 13:18 ` Henning P. Schmiedehausen
2003-06-03 13:27 ` Richard B. Johnson
2003-06-03 13:39 ` William Lee Irwin III
2003-06-03 14:44 ` Henning Schmiedehausen
2003-06-03 15:16 ` William Lee Irwin III
2003-06-03 15:25 ` Randy.Dunlap
2003-06-03 15:38 ` William Lee Irwin III
2003-06-03 15:40 ` Randy.Dunlap
[not found] <20030601060013$0d74@gated-at.bofh.it>
[not found] ` <20030601134006$4765@gated-at.bofh.it>
[not found] ` <20030602022006$78ca@gated-at.bofh.it>
[not found] ` <20030602160025$70e8@gated-at.bofh.it>
2003-06-02 16:09 ` Pascal Schmidt
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=1054523726.19551.156.camel@spc \
--to=elenstev@mesatop.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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