From: ebiederm@xmission.com (Eric W. Biederman)
To: David Howells <dhowells@redhat.com>
Cc: "John Anthony Kazos Jr." <jakj@j-a-k-j.com>,
David Woodhouse <dwmw2@infradead.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Satyam Sharma <satyam.sharma@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Hellwig <hch@infradead.org>,
Roland McGrath <roland@redhat.com>,
Christoph Hellwig <hch@lst.de>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: condingstyle, was Re: utrace comments
Date: Wed, 02 May 2007 05:55:02 -0600 [thread overview]
Message-ID: <m1fy6fxwx5.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <24844.1178098371@redhat.com> (David Howells's message of "Wed, 02 May 2007 10:32:51 +0100")
David Howells <dhowells@redhat.com> writes:
> Eric W. Biederman <ebiederm@xmission.com> wrote:
>
>> Not lining up with the code following the if statement is also
>> a plus. Because it clearly delineates the conditions from the code.
>
> But the condition doesn't line up with the code:
Exactly. The condition not lining up with the following code helps
code helps separate the two.
> if (veryverylengthycondition1 &&
> smallcond2 &&
> (conditionnumber3a ||
> condition3b)) {
> this_is_some_code();
> this_is_some_more_code();
> }
>
> Personally, for complicated conditions like this, I prefer:
>
> if (veryverylengthycondition1 &&
> smallcond2 &&
> (conditionnumber3a ||
> condition3b)
> ) {
> this_is_some_code();
> this_is_some_more_code();
> }
>
> But that seems to offend Andrew for some reason (or was it Christoph? or
> both?).
Yes.
Although I suspect simply not tucking the trailing brace is as
good or better. I believe not putting the beginning brace at
the beginning of the line is a violation of coding style.
if (veryverylengthycondition1 &&
smallcond2 &&
(conditionnumber3a ||
condition3b))
{
this_is_some_code();
this_is_some_more_code();
}
However there is the practical way to solve this if you have
a sufficiently large conditional, or the conditional appears
several times.
static inline int test_func()
{
if (!veryverylengthycondition1)
return 0;
if (!smallcond2)
return 0;
if (conditionnumber3A)
return 1;
if (condition3b)
return 1;
return 0;
}
if (test_func()) {
this_is_some_code();
this_is_some_more_code();
}
Eric
next prev parent reply other threads:[~2007-05-02 11:56 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-27 16:51 Christoph Hellwig
2006-12-05 9:51 ` Roland McGrath
2006-12-06 21:58 ` Christoph Hellwig
2007-04-30 4:02 ` Roland McGrath
2007-04-30 9:08 ` Christoph Hellwig
2007-04-30 9:18 ` Russell King
2007-04-30 9:22 ` Christoph Hellwig
2007-04-30 9:33 ` Russell King
2007-04-30 9:45 ` Russell King
2007-04-30 10:32 ` Christoph Hellwig
2007-04-30 10:18 ` Christoph Hellwig
2007-06-22 2:40 ` Roland McGrath
2007-05-10 8:49 ` Roland McGrath
2007-04-30 9:11 ` condingstyle, was " Christoph Hellwig
2007-04-30 17:09 ` Andrew Morton
2007-04-30 18:19 ` Jan Engelhardt
2007-04-30 18:39 ` Daniel Hazelton
2007-04-30 18:42 ` Satyam Sharma
2007-04-30 22:18 ` Stefan Richter
2007-05-01 9:00 ` Geert Uytterhoeven
2007-05-01 13:11 ` Scott Preece
2007-05-01 14:16 ` David Woodhouse
2007-05-01 15:00 ` John Anthony Kazos Jr.
2007-05-01 20:12 ` Satyam Sharma
2007-05-01 15:05 ` Randy Dunlap
2007-05-01 15:06 ` David Woodhouse
2007-05-01 20:44 ` Satyam Sharma
2007-05-01 15:07 ` Geert Uytterhoeven
2007-05-01 15:11 ` David Woodhouse
2007-05-01 16:07 ` David Howells
2007-05-02 2:18 ` Eric W. Biederman
2007-05-02 9:32 ` David Howells
2007-05-02 11:55 ` Eric W. Biederman [this message]
2007-05-02 12:05 ` David Howells
2007-05-01 16:15 ` Stuart MacDonald
2007-04-30 21:34 ` Luck, Tony
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=m1fy6fxwx5.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=geert@linux-m68k.org \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=jakj@j-a-k-j.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
--cc=satyam.sharma@gmail.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
all inboxes | Powered by JetHome®