Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1564505
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 6/9] KVM: Return an error code only as a constant in kvm_get_dirty_log_protect() |
| Date | 2017-01-22 19:20 +0100 |
| Message-ID | <t2uUb-46y-51@gated-at.bofh.it> (permalink) |
| References | <t2uUa-46y-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Jan 2017 17:30:16 +0100
* 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: Markus Elfring <elfring@users.sourceforge.net>
---
virt/kvm/kvm_main.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 6a74a3796b3f..a651a137ef21 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1156,24 +1156,22 @@ int kvm_get_dirty_log_protect(struct kvm *kvm,
{
struct kvm_memslots *slots;
struct kvm_memory_slot *memslot;
- int r, i, as_id, id;
+ int i, as_id, id;
unsigned long n;
unsigned long *dirty_bitmap;
unsigned long *dirty_bitmap_buffer;
- r = -EINVAL;
as_id = log->slot >> 16;
id = (u16)log->slot;
if (as_id >= KVM_ADDRESS_SPACE_NUM || id >= KVM_USER_MEM_SLOTS)
- goto out;
+ return -EINVAL;
slots = __kvm_memslots(kvm, as_id);
memslot = id_to_memslot(slots, id);
dirty_bitmap = memslot->dirty_bitmap;
- r = -ENOENT;
if (!dirty_bitmap)
- goto out;
+ return -ENOENT;
n = kvm_dirty_bitmap_bytes(memslot);
@@ -1202,14 +1200,9 @@ int kvm_get_dirty_log_protect(struct kvm *kvm,
}
spin_unlock(&kvm->mmu_lock);
-
- r = -EFAULT;
if (copy_to_user(log->dirty_bitmap, dirty_bitmap_buffer, n))
- goto out;
-
- r = 0;
-out:
- return r;
+ return -EFAULT;
+ return 0;
}
EXPORT_SYMBOL_GPL(kvm_get_dirty_log_protect);
#endif
--
2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/9] KVM: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
[PATCH 1/9] KVM: Return directly after a failed copy_from_user() in kvm_vm_compat_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
[PATCH 5/9] KVM: Improve size determinations in kvm_vcpu_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
[PATCH 3/9] KVM: Move error code settings in kvm_vcpu_compat_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
[PATCH 6/9] KVM: Return an error code only as a constant in kvm_get_dirty_log_protect() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-22 19:20 +0100
Re: [PATCH 0/9] KVM: Fine-tuning for several function implementations Paolo Bonzini <pbonzini@redhat.com> - 2017-01-23 10:30 +0100
Re: KVM: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-23 10:50 +0100
Re: KVM: Fine-tuning for several function implementations Paolo Bonzini <pbonzini@redhat.com> - 2017-01-23 15:10 +0100
Re: KVM: Fine-tuning for several function implementations Bernd Petrovitsch <bernd@petrovitsch.priv.at> - 2017-01-24 03:40 +0100
Re: KVM: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 12:40 +0100
csiph-web