aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorZhang Yanfei <zhangyanfei@cn.fujitsu.com>2013-02-27 20:03:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:11 -0500
commitc2c1b089b44b783bd50fae4bccaa6f367f92e492 (patch)
tree222677ea402d630ca50416dc76f9ae187d7f7acc /fs/proc
parent87ebdc00eeb474615496d5f10eed46709e25c707 (diff)
fs/proc/vmcore.c: put if tests in the top of the while loop to reduce duplication
In read_vmcore() two `if' tests are duplicated. Change the position of them could reduce the duplication. This change does not affect the behaviour of the function. [akpm@linux-foundation.org: avoid `if (foo = bar)' thing, use min_t()] [akpm@linux-foundation.org: s/max_t/min_t/] Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/vmcore.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 41dd018f72dd..b870f740ab5a 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -176,15 +176,15 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
176 start = map_offset_to_paddr(*fpos, &vmcore_list, &curr_m); 176 start = map_offset_to_paddr(*fpos, &vmcore_list, &curr_m);
177 if (!curr_m) 177 if (!curr_m)
178 return -EINVAL; 178 return -EINVAL;
179 if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
180 tsz = buflen;
181
182 /* Calculate left bytes in current memory segment. */
183 nr_bytes = (curr_m->size - (start - curr_m->paddr));
184 if (tsz > nr_bytes)
185 tsz = nr_bytes;
186 179
187 while (buflen) { 180 while (buflen) {
181 tsz = min_t(size_t, buflen, PAGE_SIZE - (start & ~PAGE_MASK));
182
183 /* Calculate left bytes in current memory segment. */
184 nr_bytes = (curr_m->size - (start - curr_m->paddr));
185 if (tsz > nr_bytes)
186 tsz = nr_bytes;
187
188 tmp = read_from_oldmem(buffer, tsz, &start, 1); 188 tmp = read_from_oldmem(buffer, tsz, &start, 1);
189 if (tmp < 0) 189 if (tmp < 0)
190 return tmp; 190 return tmp;
@@ -199,12 +199,6 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
199 struct vmcore, list); 199 struct vmcore, list);
200 start = curr_m->paddr; 200 start = curr_m->paddr;
201 } 201 }
202 if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
203 tsz = buflen;
204 /* Calculate left bytes in current memory segment. */
205 nr_bytes = (curr_m->size - (start - curr_m->paddr));
206 if (tsz > nr_bytes)
207 tsz = nr_bytes;
208 } 202 }
209 return acc; 203 return acc;
210} 204}