[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1200425328.26045.39.camel@twins>
Date: Tue, 15 Jan 2008 20:28:48 +0100
From: Peter Zijlstra <a.p.zijlstra@...llo.nl>
To: Anton Salikhmetov <salikhmetov@...il.com>
Cc: Randy Dunlap <randy.dunlap@...cle.com>,
Christoph Hellwig <hch@...radead.org>, linux-mm@...ck.org,
jakob@...hought.net, linux-kernel@...r.kernel.org,
valdis.kletnieks@...edu, riel@...hat.com, ksm@...dk,
staubach@...hat.com, jesper.juhl@...il.com,
torvalds@...ux-foundation.org, akpm@...ux-foundation.org,
protasnb@...il.com, miklos@...redi.hu
Subject: Re: [PATCH 1/2] Massive code cleanup of sys_msync()
On Tue, 2008-01-15 at 22:26 +0300, Anton Salikhmetov wrote:
> 2008/1/15, Randy Dunlap <randy.dunlap@...cle.com>:
> > On Tue, 15 Jan 2008 22:02:54 +0300 Anton Salikhmetov wrote:
> >
> > > 2008/1/15, Christoph Hellwig <hch@...radead.org>:
> > > > On Tue, Jan 15, 2008 at 07:02:44PM +0300, Anton Salikhmetov wrote:
> >
> > > > > @@ -33,71 +34,65 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
> > > > > unsigned long end;
> > > > > struct mm_struct *mm = current->mm;
> > > > > struct vm_area_struct *vma;
> > > > > - int unmapped_error = 0;
> > > > > - int error = -EINVAL;
> > > > > + int error = 0, unmapped_error = 0;
> > > > >
> > > > > if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
> > > > > - goto out;
> > > > > + return -EINVAL;
> > > > > if (start & ~PAGE_MASK)
> > > > > - goto out;
> > > > > + return -EINVAL;
> > > >
> > > > The goto out for a simple return style is used quite commonly in kernel
> > > > code to have a single return statement which makes code maintaince, e.g.
> > > > adding locks or allocations simpler. Not sure that getting rid of it
> > > > makes a lot of sense.
> > >
> > > Sorry, I can't agree. That's what is written in the CodingStyle document:
> > >
> > > The goto statement comes in handy when a function exits from multiple
> > > locations and some common work such as cleanup has to be done.
> >
> > CodingStyle does not try to cover Everything. Nor do we want it to.
> >
> > At any rate, there is a desire for functions to have a single point
> > of return, regardless of the amount of cleanup to be done, so I agree
> > with Christoph's comments.
>
> Should I replace "return -EINVAL;" statement with the following?
>
> {
> error = -EINVAL;
> goto out;
> }
Notice that error is already -EINVAL, so a simple goto should suffice.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists