From: Zhang Yanfei <[email protected]>

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.

Signed-off-by: Zhang Yanfei <[email protected]>
---
 fs/proc/vmcore.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 0d5071d..c74a901 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -175,15 +175,16 @@ static ssize_t read_vmcore(struct file *file, char __user 
*buffer,
        start = map_offset_to_paddr(*fpos, &vmcore_list, &curr_m);
        if (!curr_m)
                return -EINVAL;
-       if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
-               tsz = buflen;
-
-       /* Calculate left bytes in current memory segment. */
-       nr_bytes = (curr_m->size - (start - curr_m->paddr));
-       if (tsz > nr_bytes)
-               tsz = nr_bytes;
 
        while (buflen) {
+               if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
+                       tsz = buflen;
+
+               /* Calculate left bytes in current memory segment. */
+               nr_bytes = (curr_m->size - (start - curr_m->paddr));
+               if (tsz > nr_bytes)
+                       tsz = nr_bytes;
+
                tmp = read_from_oldmem(buffer, tsz, &start, 1);
                if (tmp < 0)
                        return tmp;
@@ -198,12 +199,6 @@ static ssize_t read_vmcore(struct file *file, char __user 
*buffer,
                                                struct vmcore, list);
                        start = curr_m->paddr;
                }
-               if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
-                       tsz = buflen;
-               /* Calculate left bytes in current memory segment. */
-               nr_bytes = (curr_m->size - (start - curr_m->paddr));
-               if (tsz > nr_bytes)
-                       tsz = nr_bytes;
        }
        return acc;
 }
-- 
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to