From: "Robert White" <rwhite@casabyte.com>
To: "Steven Cole" <elenstev@mesatop.com>, "Larry McVoy" <lm@bitmover.com>
Cc: "Willy Tarreau" <willy@w.ods.org>, <linux-kernel@vger.kernel.org>
Subject: RE: Question about style when converting from K&R to ANSI C.
Date: Mon, 2 Jun 2003 20:29:25 -0700 [thread overview]
Message-ID: <PEEPIDHAKMCGHDBJLHKGAEBMCOAA.rwhite@casabyte.com> (raw)
In-Reply-To: <1054479734.19552.51.camel@spc>
Um... ich! (ignoring the return type debate)
static unsigned long
insert_bba(unsigned long insn,
long value,
const char **errmsg)
{
return insn | (((insn >> 16) & 0x1f) << 11);
}
...OR...
static unsigned long insert_bba(unsigned long insn,
long value,
const char **errmsg)
{
return insn | (((insn >> 16) & 0x1f) << 11);
}
NEVER line up the return type and the argument type like the text below. It
is mind-clobbering after a couple hundred pages.
Also, though it didn't come up, once you decide to put the arguments on
separate lines for readability never mix the styles in one function call.
int X(int A, int B,
char **errormsg)
{
}
is "very bad". the above "looks ok" in that one instance but it isn't.
Either I have to count the arguments, or there is one per line, but never
seven arguments on five lines (if you please) as that is evil! (It is good
for driving instructors crazy too... 8-)
Also, in your automatics, it is never ok to write
int A, *b;
or even
int A, B;
One variable per line please.
int A;
int *b;
(Especially if you are programming, or ever hope to program, tiny little
embedded systems where you really have to visualize your stack requirements.
8-) The real reason is to facilitate and encourage automatic
initializations. Particularly of classes in C++, but profoundly so in basic
C none the less. Uninitialized variables should look bare and lonely, and
perhaps even a tad wrong. (Not to mention having more than one alphabetic
character as a name, but I was being minimalist... 8-)
Rob.
-----Original Message-----
From: linux-kernel-owner@vger.kernel.org
[mailto:linux-kernel-owner@vger.kernel.org]On Behalf Of Steven Cole
/*ARGSUSED*/
-static unsigned long
-insert_bba (insn, value, errmsg)
- unsigned long insn;
- long value;
- const char **errmsg;
+static unsigned long insert_bba(
+ unsigned long insn,
+ long value,
+ const char **errmsg
+)
{
return insn | (((insn >> 16) & 0x1f) << 11);
}
next prev parent reply other threads:[~2003-06-03 3:16 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-01 5:56 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 [this message]
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
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=PEEPIDHAKMCGHDBJLHKGAEBMCOAA.rwhite@casabyte.com \
--to=rwhite@casabyte.com \
--cc=elenstev@mesatop.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lm@bitmover.com \
--cc=willy@w.ods.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®