diff options
author | Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp> | 2013-01-11 04:27:43 -0500 |
---|---|---|
committer | Gleb Natapov <gleb@redhat.com> | 2013-01-17 07:27:59 -0500 |
commit | a843fac2536d6d81335d7011dd7ec4e438161dd7 (patch) | |
tree | bf08a9989c45f2e7e5d454eae5868b9efd5d630f /virt | |
parent | 0a706beefb1de71bf8551f9860dc529ef14d6753 (diff) |
KVM: set_memory_region: Remove unnecessary variable memslot
One such variable, slot, is enough for holding a pointer temporarily.
We also remove another local variable named slot, which is limited in
a block, since it is confusing to have the same name in this function.
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fca64879f967..5e709ebb7c40 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -728,7 +728,7 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
728 | int r; | 728 | int r; |
729 | gfn_t base_gfn; | 729 | gfn_t base_gfn; |
730 | unsigned long npages; | 730 | unsigned long npages; |
731 | struct kvm_memory_slot *memslot, *slot; | 731 | struct kvm_memory_slot *slot; |
732 | struct kvm_memory_slot old, new; | 732 | struct kvm_memory_slot old, new; |
733 | struct kvm_memslots *slots = NULL, *old_memslots; | 733 | struct kvm_memslots *slots = NULL, *old_memslots; |
734 | 734 | ||
@@ -754,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
754 | if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr) | 754 | if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr) |
755 | goto out; | 755 | goto out; |
756 | 756 | ||
757 | memslot = id_to_memslot(kvm->memslots, mem->slot); | 757 | slot = id_to_memslot(kvm->memslots, mem->slot); |
758 | base_gfn = mem->guest_phys_addr >> PAGE_SHIFT; | 758 | base_gfn = mem->guest_phys_addr >> PAGE_SHIFT; |
759 | npages = mem->memory_size >> PAGE_SHIFT; | 759 | npages = mem->memory_size >> PAGE_SHIFT; |
760 | 760 | ||
@@ -765,7 +765,7 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
765 | if (!npages) | 765 | if (!npages) |
766 | mem->flags &= ~KVM_MEM_LOG_DIRTY_PAGES; | 766 | mem->flags &= ~KVM_MEM_LOG_DIRTY_PAGES; |
767 | 767 | ||
768 | new = old = *memslot; | 768 | new = old = *slot; |
769 | 769 | ||
770 | new.id = mem->slot; | 770 | new.id = mem->slot; |
771 | new.base_gfn = base_gfn; | 771 | new.base_gfn = base_gfn; |
@@ -786,7 +786,8 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
786 | /* Check for overlaps */ | 786 | /* Check for overlaps */ |
787 | r = -EEXIST; | 787 | r = -EEXIST; |
788 | kvm_for_each_memslot(slot, kvm->memslots) { | 788 | kvm_for_each_memslot(slot, kvm->memslots) { |
789 | if (slot->id >= KVM_USER_MEM_SLOTS || slot == memslot) | 789 | if ((slot->id >= KVM_USER_MEM_SLOTS) || |
790 | (slot->id == mem->slot)) | ||
790 | continue; | 791 | continue; |
791 | if (!((base_gfn + npages <= slot->base_gfn) || | 792 | if (!((base_gfn + npages <= slot->base_gfn) || |
792 | (base_gfn >= slot->base_gfn + slot->npages))) | 793 | (base_gfn >= slot->base_gfn + slot->npages))) |
@@ -822,8 +823,6 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
822 | } | 823 | } |
823 | 824 | ||
824 | if (!npages || base_gfn != old.base_gfn) { | 825 | if (!npages || base_gfn != old.base_gfn) { |
825 | struct kvm_memory_slot *slot; | ||
826 | |||
827 | r = -ENOMEM; | 826 | r = -ENOMEM; |
828 | slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots), | 827 | slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots), |
829 | GFP_KERNEL); | 828 | GFP_KERNEL); |