[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20130208095205.ef55159c.akpm@linux-foundation.org>
Date: Fri, 8 Feb 2013 09:52:05 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: ebiederm@...ssion.com (Eric W. Biederman)
Cc: Zhang Yanfei <zhangyanfei.yes@...il.com>, benh@...nel.crashing.org,
mahesh@...ux.vnet.ibm.com, zhangyanfei@...fujitsu.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs/proc/vmcore.c: Put if tests in the top of the while
loop to reduce duplication
On Fri, 08 Feb 2013 06:25:39 -0800 ebiederm@...ssion.com (Eric W. Biederman) wrote:
> Andrew Morton <akpm@...ux-foundation.org> writes:
>
> > On Sun, 03 Feb 2013 21:13:36 +0800
> > Zhang Yanfei <zhangyanfei.yes@...il.com> wrote:
> >
> >> From: Zhang Yanfei <zhangyanfei@...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));
> > _
--
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