linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: ebiederm@xmission.com (Eric W. Biederman)
Cc: Zhang Yanfei <zhangyanfei.yes@gmail.com>,
	benh@kernel.crashing.org, mahesh@linux.vnet.ibm.com,
	zhangyanfei@cn.fujitsu.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/proc/vmcore.c: Put if tests in the top of the while loop to reduce duplication
Date: Fri, 8 Feb 2013 09:52:05 -0800	[thread overview]
Message-ID: <20130208095205.ef55159c.akpm@linux-foundation.org> (raw)
In-Reply-To: <87ehgq3msc.fsf@xmission.com>

On Fri, 08 Feb 2013 06:25:39 -0800 ebiederm@xmission.com (Eric W. Biederman) wrote:

> Andrew Morton <akpm@linux-foundation.org> writes:
> 
> > On Sun, 03 Feb 2013 21:13:36 +0800
> > Zhang Yanfei <zhangyanfei.yes@gmail.com> wrote:
> >
> >> From: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
> >> 
> >> In function read_vmcore, two if tests are duplicate. Change the position
> >> of them could reduce the duplication. This change does not affect
> >> the behaviour of the function.
> 
> > While we're there, let's squish that assignment-in-a-if pestilence and
> > use max_t().
> 
> min_t please.  Or do you mean to change the behavior of the code?

oops.

> > --- a/fs/proc/vmcore.c~fs-proc-vmcorec-put-if-tests-in-the-top-of-the-while-loop-to-reduce-duplication-fix
> > +++ a/fs/proc/vmcore.c
> > @@ -178,8 +178,7 @@ static ssize_t read_vmcore(struct file *
> >          	return -EINVAL;
> >  
> >  	while (buflen) {
> > -		if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
> > -			tsz = buflen;
> > +		tsz = max_t(size_t, buflen, PAGE_SIZE - (start & ~PAGE_MASK));
> >  
> >  		/* Calculate left bytes in current memory segment. */
> >  		nr_bytes = (curr_m->size - (start - curr_m->paddr));
> > _

      reply	other threads:[~2013-02-08 17:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-03 13:13 [PATCH] fs/proc/vmcore.c: Put if tests in the top of the while loop to reduce duplication Zhang Yanfei
2013-02-08  0:06 ` Andrew Morton
2013-02-08 14:25   ` Eric W. Biederman
2013-02-08 17:52     ` Andrew Morton [this message]

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=20130208095205.ef55159c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=zhangyanfei.yes@gmail.com \
    --cc=zhangyanfei@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).