Commit 843574a3 authored by Markus Elfring's avatar Markus Elfring Committed by Paolo Bonzini

KVM: Return an error code only as a constant in kvm_get_dirty_log()

* Return an error code without storing it in an intermediate variable.

* Delete the local variable "r" and the jump label "out" which became
  unnecessary with this refactoring.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 58d6db34
...@@ -1102,37 +1102,31 @@ int kvm_get_dirty_log(struct kvm *kvm, ...@@ -1102,37 +1102,31 @@ int kvm_get_dirty_log(struct kvm *kvm,
{ {
struct kvm_memslots *slots; struct kvm_memslots *slots;
struct kvm_memory_slot *memslot; struct kvm_memory_slot *memslot;
int r, i, as_id, id; int i, as_id, id;
unsigned long n; unsigned long n;
unsigned long any = 0; unsigned long any = 0;
r = -EINVAL;
as_id = log->slot >> 16; as_id = log->slot >> 16;
id = (u16)log->slot; id = (u16)log->slot;
if (as_id >= KVM_ADDRESS_SPACE_NUM || id >= KVM_USER_MEM_SLOTS) if (as_id >= KVM_ADDRESS_SPACE_NUM || id >= KVM_USER_MEM_SLOTS)
goto out; return -EINVAL;
slots = __kvm_memslots(kvm, as_id); slots = __kvm_memslots(kvm, as_id);
memslot = id_to_memslot(slots, id); memslot = id_to_memslot(slots, id);
r = -ENOENT;
if (!memslot->dirty_bitmap) if (!memslot->dirty_bitmap)
goto out; return -ENOENT;
n = kvm_dirty_bitmap_bytes(memslot); n = kvm_dirty_bitmap_bytes(memslot);
for (i = 0; !any && i < n/sizeof(long); ++i) for (i = 0; !any && i < n/sizeof(long); ++i)
any = memslot->dirty_bitmap[i]; any = memslot->dirty_bitmap[i];
r = -EFAULT;
if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n)) if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n))
goto out; return -EFAULT;
if (any) if (any)
*is_dirty = 1; *is_dirty = 1;
return 0;
r = 0;
out:
return r;
} }
EXPORT_SYMBOL_GPL(kvm_get_dirty_log); EXPORT_SYMBOL_GPL(kvm_get_dirty_log);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment