All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roland Dreier <rdreier@cisco.com>
To: Mike Isely <isely@pobox.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
	LKML <linux-kernel@vger.kernel.org>,
	v4l-dvb maintainer list <v4l-dvb-maintainer@linuxtv.org>
Subject: Re: CodingStyle question: multiple statements on a single line
Date: Wed, 03 Sep 2008 11:38:01 -0700	[thread overview]
Message-ID: <adaskshvzw6.fsf@cisco.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0809021830400.17907@cnc.isely.net> (Mike Isely's message of "Tue, 2 Sep 2008 18:50:44 -0500 (CDT)")

 > <quote>
 > Don't put multiple statements on a single line unless you have
 > something to hide:
 > </quote>
 > 
 > Then what does "unless you have something to hide" refer to exactly?

I think it's a tongue-in-cheek way of saying "unless you're trying to
make your code hard to read."  In other words, don't do it.

 > So by that reasoning "if (a) b;" - provided it stays under 80 columns - 
 > should be even better.  It occupies less space so that more code can fit 
 > on the screen.

But it is visually hard to distinguish between the condition (a) and the
statement (b) that follows it.  And the arbitrary kernel rule is that we
don't use that style.

 > > And uniformity counts for a lot: most coding style rules are completely
 > > arbitrary, but having a uniform kernel style makes reading kernel code
 > > much easier.

 > What about drivers?  The statement has been made by others that there is 
 > a strong desire for outside drivers to be brought into mainline rather 
 > than being out-of-tree.  So must every chunk of code brought in this way 
 > be sanitized to this level of detail?  In many cases that can be a large 
 > (and some might say arbitrary) hurdle.

Of course having a uniform coding style is important for drivers too.
There are many cases where someone other than the original author is
debugging a driver and needs to read and understand the code, or where
someone is updating all in-tree drivers to cope with an API change and
must read and correctly change lots of driver code.

In general we are pretty lenient about driver code, as long as it pretty
much looks like kernel code.  But really, how much work is it to make a
one-time sweep over a driver and change

	if (a) {
		b;
	}

to

	if (a)
		b;

especially when you have an automated tool (checkpatch.pl) that can help
you find the places that would change?

 > That's great.  How does one reconcile this statement with subsystem 
 > maintainers who treat checkpatch.pl - which is the epitome of 
 > "mechanical rule" and has no notion of common sense - as the gatekeeper 
 > for all incoming changesets?

I don't know of any such maintainers.  In general if someone submitted a
patch that only triggered a few checkpatch warnings and gave a rationale
about why the remaining warnings shouldn't be worried about, then that
would be fine with me.

 - R.

  parent reply	other threads:[~2008-09-03 18:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-02 22:20 CodingStyle question: multiple statements on a single line Hans Verkuil
2008-09-02 22:34 ` Roland Dreier
2008-09-02 23:50   ` Mike Isely
2008-09-03  0:23     ` Randy Dunlap
2008-09-03 12:19     ` Krzysztof Halasa
2008-09-03 18:38     ` Roland Dreier [this message]
2008-09-03 20:22       ` Lennart Sorensen
2008-09-03 12:15   ` Krzysztof Halasa
2008-09-03  6:57 ` Frans Meulenbroeks

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=adaskshvzw6.fsf@cisco.com \
    --to=rdreier@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=isely@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=v4l-dvb-maintainer@linuxtv.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.