WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] xen/privcmd: Declare repeatedly used

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] xen/privcmd: Declare repeatedly used variables just once. Fix types.
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 18 Jan 2010 16:45:02 -0800
Delivery-date: Mon, 18 Jan 2010 16:45:03 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1263826243 0
# Node ID 0bec29c94ce9ed50d5d77f6e694576efd30e98eb
# Parent  3358caa6b3a3c68845a4e4aa2c8b44e7641cb243
xen/privcmd: Declare repeatedly used variables just once. Fix types.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 drivers/xen/privcmd/privcmd.c |   85 ++++++++++++++++++------------------------
 1 files changed, 38 insertions(+), 47 deletions(-)

diff -r 3358caa6b3a3 -r 0bec29c94ce9 drivers/xen/privcmd/privcmd.c
--- a/drivers/xen/privcmd/privcmd.c     Mon Jan 18 10:46:43 2010 +0000
+++ b/drivers/xen/privcmd/privcmd.c     Mon Jan 18 14:50:43 2010 +0000
@@ -55,8 +55,14 @@ static long privcmd_ioctl(struct file *f
 static long privcmd_ioctl(struct file *file,
                          unsigned int cmd, unsigned long data)
 {
-       int ret = -ENOSYS;
+       long ret;
        void __user *udata = (void __user *) data;
+       unsigned long i, addr, nr, nr_pages;
+       int paged_out;
+       struct mm_struct *mm = current->mm;
+       struct vm_area_struct *vma;
+       LIST_HEAD(pagelist);
+       struct list_head *l, *l2;
 
        switch (cmd) {
        case IOCTL_PRIVCMD_HYPERCALL: {
@@ -65,6 +71,7 @@ static long privcmd_ioctl(struct file *f
                if (copy_from_user(&hypercall, udata, sizeof(hypercall)))
                        return -EFAULT;
 
+               ret = -ENOSYS;
 #if defined(__i386__)
                if (hypercall.op >= (PAGE_SIZE >> 5))
                        break;
@@ -108,16 +115,11 @@ static long privcmd_ioctl(struct file *f
        break;
 
        case IOCTL_PRIVCMD_MMAP: {
-#define MMAP_NR_PER_PAGE (int)((PAGE_SIZE-sizeof(struct 
list_head))/sizeof(privcmd_mmap_entry_t))
+#define MMAP_NR_PER_PAGE \
+       (unsigned long)((PAGE_SIZE - sizeof(*l)) / sizeof(*msg))
                privcmd_mmap_t mmapcmd;
                privcmd_mmap_entry_t *msg;
                privcmd_mmap_entry_t __user *p;
-               struct mm_struct *mm = current->mm;
-               struct vm_area_struct *vma;
-               unsigned long va;
-               int i, rc;
-               LIST_HEAD(pagelist);
-               struct list_head *l,*l2;
 
                if (!is_initial_xendomain())
                        return -EPERM;
@@ -130,9 +132,9 @@ static long privcmd_ioctl(struct file *f
 
                p = mmapcmd.entry;
                for (i = 0; i < mmapcmd.num;) {
-                       int nr = min(mmapcmd.num - i, MMAP_NR_PER_PAGE);
-
-                       rc = -ENOMEM;
+                       nr = min(mmapcmd.num - i, MMAP_NR_PER_PAGE);
+
+                       ret = -ENOMEM;
                        l = (struct list_head *) __get_free_page(GFP_KERNEL);
                        if (l == NULL)
                                goto mmap_out;
@@ -141,7 +143,7 @@ static long privcmd_ioctl(struct file *f
                        list_add_tail(l, &pagelist);
                        msg = (privcmd_mmap_entry_t*)(l + 1);
 
-                       rc = -EFAULT;
+                       ret = -EFAULT;
                        if (copy_from_user(msg, p, nr*sizeof(*msg)))
                                goto mmap_out;
                        i += nr;
@@ -154,47 +156,47 @@ static long privcmd_ioctl(struct file *f
                down_write(&mm->mmap_sem);
 
                vma = find_vma(mm, msg->va);
-               rc = -EINVAL;
+               ret = -EINVAL;
                if (!vma || (msg->va != vma->vm_start))
                        goto mmap_out;
 
-               va = vma->vm_start;
+               addr = vma->vm_start;
 
                i = 0;
                list_for_each(l, &pagelist) {
-                       int nr = i + min(mmapcmd.num - i, MMAP_NR_PER_PAGE);
+                       nr = i + min(mmapcmd.num - i, MMAP_NR_PER_PAGE);
 
                        msg = (privcmd_mmap_entry_t*)(l + 1);
                        while (i<nr) {
 
                                /* Do not allow range to wrap the address 
space. */
                                if ((msg->npages > (LONG_MAX >> PAGE_SHIFT)) ||
-                                   ((unsigned long)(msg->npages << PAGE_SHIFT) 
>= -va))
+                                   (((unsigned long)msg->npages << PAGE_SHIFT) 
>= -addr))
                                        goto mmap_out;
 
                                /* Range chunks must be contiguous in va space. 
*/
-                               if ((msg->va != va) ||
+                               if ((msg->va != addr) ||
                                    ((msg->va+(msg->npages<<PAGE_SHIFT)) > 
vma->vm_end))
                                        goto mmap_out;
 
-                               va += msg->npages << PAGE_SHIFT;
+                               addr += msg->npages << PAGE_SHIFT;
                                msg++;
                                i++;
                        }
                }
 
                if (!enforce_singleshot_mapping(vma, vma->vm_start,
-                                               (va - vma->vm_start) >> 
PAGE_SHIFT))
+                                               (addr - vma->vm_start) >> 
PAGE_SHIFT))
                        goto mmap_out;
 
-               va = vma->vm_start;
+               addr = vma->vm_start;
                i = 0;
                list_for_each(l, &pagelist) {
-                       int nr = i + min(mmapcmd.num - i, MMAP_NR_PER_PAGE);
+                       nr = i + min(mmapcmd.num - i, MMAP_NR_PER_PAGE);
 
                        msg = (privcmd_mmap_entry_t*)(l + 1);
                        while (i < nr) {
-                               if ((rc = direct_remap_pfn_range(
+                               if ((ret = direct_remap_pfn_range(
                                             vma,
                                             msg->va & PAGE_MASK,
                                             msg->mfn,
@@ -203,34 +205,28 @@ static long privcmd_ioctl(struct file *f
                                             mmapcmd.dom)) < 0)
                                        goto mmap_out;
 
-                               va += msg->npages << PAGE_SHIFT;
+                               addr += msg->npages << PAGE_SHIFT;
                                msg++;
                                i++;
                        }
                }
 
-               rc = 0;
+               ret = 0;
 
        mmap_out:
                up_write(&mm->mmap_sem);
                list_for_each_safe(l,l2,&pagelist)
                        free_page((unsigned long)l);
-               ret = rc;
        }
 #undef MMAP_NR_PER_PAGE
        break;
 
        case IOCTL_PRIVCMD_MMAPBATCH: {
-#define MMAPBATCH_NR_PER_PAGE (unsigned long)((PAGE_SIZE-sizeof(struct 
list_head))/sizeof(unsigned long))
+#define MMAPBATCH_NR_PER_PAGE \
+       (unsigned long)((PAGE_SIZE - sizeof(*l)) / sizeof(*mfn))
                privcmd_mmapbatch_t m;
-               struct mm_struct *mm = current->mm;
-               struct vm_area_struct *vma;
                xen_pfn_t __user *p;
-               unsigned long addr, *mfn, nr_pages;
-               int i;
-               LIST_HEAD(pagelist);
-               struct list_head *l, *l2;
-               int paged_out = 0;
+               xen_pfn_t *mfn;
 
                if (!is_initial_xendomain())
                        return -EPERM;
@@ -246,7 +242,7 @@ static long privcmd_ioctl(struct file *f
 
                p = m.arr;
                for (i=0; i<nr_pages; ) {
-                       int nr = min(nr_pages - i, MMAPBATCH_NR_PER_PAGE);
+                       nr = min(nr_pages - i, MMAPBATCH_NR_PER_PAGE);
 
                        ret = -ENOMEM;
                        l = (struct list_head *)__get_free_page(GFP_KERNEL);
@@ -278,13 +274,14 @@ static long privcmd_ioctl(struct file *f
 
                i = 0;
                ret = 0;
+               paged_out = 0;
                list_for_each(l, &pagelist) {
-                       int nr = i + min(nr_pages - i, MMAPBATCH_NR_PER_PAGE);
-                       int rc;
-
+                       nr = i + min(nr_pages - i, MMAPBATCH_NR_PER_PAGE);
                        mfn = (unsigned long *)(l + 1);
 
                        while (i<nr) {
+                               int rc;
+
                                rc = direct_remap_pfn_range(vma, addr & 
PAGE_MASK,
                                                            *mfn, PAGE_SIZE,
                                                            vma->vm_page_prot, 
m.dom);
@@ -311,7 +308,7 @@ static long privcmd_ioctl(struct file *f
                        else
                                ret = 0;
                        list_for_each(l, &pagelist) {
-                               int nr = min(nr_pages - i, 
MMAPBATCH_NR_PER_PAGE);
+                               nr = min(nr_pages - i, MMAPBATCH_NR_PER_PAGE);
                                mfn = (unsigned long *)(l + 1);
                                if (copy_to_user(p, mfn, nr*sizeof(*mfn)))
                                        ret = -EFAULT;
@@ -326,15 +323,9 @@ static long privcmd_ioctl(struct file *f
 
        case IOCTL_PRIVCMD_MMAPBATCH_V2: {
                privcmd_mmapbatch_v2_t m;
-               struct mm_struct *mm = current->mm;
-               struct vm_area_struct *vma;
                const xen_pfn_t __user *p;
                xen_pfn_t *mfn;
-               unsigned long addr, nr_pages;
-               unsigned int i, nr;
-               LIST_HEAD(pagelist);
-               struct list_head *l, *l2;
-               int *err, paged_out;
+               int *err;
 
                if (!is_initial_xendomain())
                        return -EPERM;
@@ -382,14 +373,14 @@ static long privcmd_ioctl(struct file *f
                ret = 0;
                paged_out = 0;
                list_for_each(l, &pagelist) {
-                       int rc;
-
                        nr = i + min(nr_pages - i, MMAPBATCH_NR_PER_PAGE);
                        mfn = (void *)(l + 1);
                        err = (void *)(l + 1);
                        BUILD_BUG_ON(sizeof(*err) > sizeof(*mfn));
 
                        while (i < nr) {
+                               int rc;
+
                                rc = direct_remap_pfn_range(vma, addr & 
PAGE_MASK,
                                                            *mfn, PAGE_SIZE,
                                                            vma->vm_page_prot, 
m.dom);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] xen/privcmd: Declare repeatedly used variables just once. Fix types., Xen patchbot-linux-2.6.18-xen <=