The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Larry McVoy <lm@bitmover.com>
To: Dave Jones <davej@codemonkey.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Chris Heath <chris@heathens.co.nz>,
	linux-kernel@vger.kernel.org
Subject: Re: coding style (was Re: [PATCH][2.5] UTF-8 support in console)
Date: Sat, 31 May 2003 08:39:40 -0700	[thread overview]
Message-ID: <20030531153940.GA1280@work.bitmover.com> (raw)
In-Reply-To: <20030531150150.GA14829@suse.de>

On Sat, May 31, 2003 at 04:01:50PM +0100, Dave Jones wrote:
> Saving a line over readability is utterly bogus.

I agree 100%.  If you have anything more complex than

	if (error) return (error);

I want it to look like
	
	if ((expr) || (expr2) || (expr3)) {
		return (error);
	}

> Just look at some of the crap we have in devfs..

No kidding, look at the nested if, that's insane.

>     if (fs_info->devfsd_task == NULL) return (TRUE);
>     if (devfsd_queue_empty (fs_info) && fs_info->devfsd_sleeping) return TRUE;
>     if ( is_devfsd_or_child (fs_info) ) return (FALSE);
>     set_current_state (TASK_UNINTERRUPTIBLE);
>     add_wait_queue (&fs_info->revalidate_wait_queue, &wait);
>     if (!devfsd_queue_empty (fs_info) || !fs_info->devfsd_sleeping)
>         if (fs_info->devfsd_task) schedule ();
>     remove_wait_queue (&fs_info->revalidate_wait_queue, &wait);
>     __set_current_state (TASK_RUNNING);
>     return (TRUE);

I took a pass at this, I think this is better (note the use of 1/2 tabs
as "continuation" lines, that's a Sun thing and it works pretty well:

	if ((fs_info->devfsd_task == NULL) ||
	    (devfsd_queue_empty(fs_info) && fs_info->devfsd_sleeping)) {
		return (TRUE);
	}
	if (is_devfsd_or_child(fs_info)) return (FALSE);
	set_current_state (TASK_UNINTERRUPTIBLE);
	add_wait_queue (&fs_info->revalidate_wait_queue, &wait);
	if ((!devfsd_queue_empty (fs_info) || !fs_info->devfsd_sleeping) &&
	    fs_info->devfsd_task) {
	    	schedule();
	}
	remove_wait_queue(&fs_info->revalidate_wait_queue, &wait);
	__set_current_state(TASK_RUNNING);
	return (TRUE);

-- 
---
Larry McVoy              lm at bitmover.com          http://www.bitmover.com/lm

  reply	other threads:[~2003-05-31 15:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-31 14:10 [PATCH][2.5] UTF-8 support in console Chris Heath
2003-05-31 14:21 ` Christoph Hellwig
2003-05-31 14:43   ` coding style (was Re: [PATCH][2.5] UTF-8 support in console) Larry McVoy
2003-05-31 15:01     ` Dave Jones
2003-05-31 15:39       ` Larry McVoy [this message]
2003-05-31 17:14         ` Steven Cole
2003-05-31 17:56           ` viro
2003-05-31 19:37   ` [PATCH][2.5] UTF-8 support in console Chris Heath
  -- strict thread matches above, loose matches on Subject: below --
2003-05-31 16:06 coding style (was Re: [PATCH][2.5] UTF-8 support in console) john
2003-06-01  4:41 ` Matt Mackall
2003-06-01  5:18   ` Randy.Dunlap

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=20030531153940.GA1280@work.bitmover.com \
    --to=lm@bitmover.com \
    --cc=chris@heathens.co.nz \
    --cc=davej@codemonkey.org.uk \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.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