linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <randy.dunlap@oracle.com>
To: Anton Salikhmetov <salikhmetov@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	linux-mm@kvack.org, jakob@unthought.net,
	linux-kernel@vger.kernel.org, valdis.kletnieks@vt.edu,
	riel@redhat.com, ksm@42.dk, staubach@redhat.com,
	jesper.juhl@gmail.com, torvalds@linux-foundation.org,
	a.p.zijlstra@chello.nl, akpm@linux-foundation.org,
	protasnb@gmail.com, miklos@szeredi.hu
Subject: Re: [PATCH 1/2] Massive code cleanup of sys_msync()
Date: Tue, 15 Jan 2008 11:10:18 -0800	[thread overview]
Message-ID: <20080115111018.1e27a229.randy.dunlap@oracle.com> (raw)
In-Reply-To: <4df4ef0c0801151102l4d72b6b5j702e21beb1ebe459@mail.gmail.com>

On Tue, 15 Jan 2008 22:02:54 +0300 Anton Salikhmetov wrote:

> 2008/1/15, Christoph Hellwig <hch@infradead.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.


> The second part of requirement does not hold true for the sys_msync() routine.
> 
> >
> > > +             file = vma->vm_file;
> > > +             if ((flags & MS_SYNC) && file && (vma->vm_flags & VM_SHARED)) {
> >
> > Given that file is assigned just above it would be more readable to test
> > it first.
> 
> The second part of my solution changes this code, anyway.
> 
> >
> > > +                     if (error)
> > > +                             return error;
> >
> > This should be an goto out, returns out of the middle of the function
> > make reading and maintaining the code not so nice.
> 
> Sorry, I don't think so. No "common cleanup" is needed here.


---
~Randy

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2008-01-15 19:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-15 16:02 [PATCH 0/2] Updating ctime and mtime for memory-mapped files [try #4] Anton Salikhmetov
2008-01-15 16:02 ` [PATCH 1/2] Massive code cleanup of sys_msync() Anton Salikhmetov
2008-01-15 17:57   ` Christoph Hellwig
2008-01-15 19:02     ` Anton Salikhmetov
2008-01-15 19:10       ` Randy Dunlap [this message]
2008-01-15 19:26         ` Anton Salikhmetov
2008-01-15 19:28           ` Peter Zijlstra
2008-01-15 19:32             ` Christoph Hellwig
2008-01-15 20:12               ` Anton Salikhmetov
2008-01-15 20:46         ` Matt Mackall
2008-01-15 21:06           ` Randy Dunlap
2008-01-15 16:02 ` [PATCH 2/2] Updating ctime and mtime at syncing Anton Salikhmetov
     [not found]   ` <1200414911.26045.32.camel@twins>
2008-01-15 17:18     ` Anton Salikhmetov
2008-01-15 19:30       ` Peter Zijlstra
2008-01-15 18:04   ` Christoph Hellwig
2008-01-15 19:04     ` Anton Salikhmetov
2008-01-15 20:27 ` [PATCH 0/2] Updating ctime and mtime for memory-mapped files [try #4] Miklos Szeredi
2008-01-15 20:32   ` Peter Zijlstra
2008-01-15 20:40     ` Miklos Szeredi
2008-01-15 22:15   ` Anton Salikhmetov
  -- strict thread matches above, loose matches on Subject: below --
2008-01-13  4:39 [PATCH 0/2] yet another attempt to fix the ctime and mtime issue Anton Salikhmetov
2008-01-13  4:39 ` [PATCH 1/2] massive code cleanup of sys_msync() Anton Salikhmetov
2008-01-13  4:46   ` Rik van Riel
2008-01-14 10:49   ` Miklos Szeredi
2008-01-14 11:56     ` Anton Salikhmetov

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=20080115111018.1e27a229.randy.dunlap@oracle.com \
    --to=randy.dunlap@oracle.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=jakob@unthought.net \
    --cc=jesper.juhl@gmail.com \
    --cc=ksm@42.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=miklos@szeredi.hu \
    --cc=protasnb@gmail.com \
    --cc=riel@redhat.com \
    --cc=salikhmetov@gmail.com \
    --cc=staubach@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=valdis.kletnieks@vt.edu \
    /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