public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: kvm@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 6/9] KVM: Return an error code only as a constant in kvm_get_dirty_log_protect()
Date: Sun, 22 Jan 2017 19:16:14 +0100	[thread overview]
Message-ID: <2f83abd2-cf68-4294-6603-cfab2991e731@users.sourceforge.net> (raw)
In-Reply-To: <a2fb541a-7a7d-1f78-b587-1191b9832088@users.sourceforge.net>

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


  parent reply	other threads:[~2017-01-22 18:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-22 18:09 [PATCH 0/9] KVM: Fine-tuning for several function implementations SF Markus Elfring
2017-01-22 18:11 ` [PATCH 1/9] KVM: Return directly after a failed copy_from_user() in kvm_vm_compat_ioctl() SF Markus Elfring
2017-01-22 18:12 ` [PATCH 2/9] KVM: Move error code settings in kvm_vm_ioctl() SF Markus Elfring
2017-01-22 18:13 ` [PATCH 3/9] KVM: Move error code settings in kvm_vcpu_compat_ioctl() SF Markus Elfring
2017-01-22 18:14 ` [PATCH 4/9] KVM: Move error code settings in kvm_vcpu_ioctl() SF Markus Elfring
2017-01-22 18:15 ` [PATCH 5/9] KVM: Improve size determinations " SF Markus Elfring
2017-01-22 18:16 ` SF Markus Elfring [this message]
2017-01-22 18:17 ` [PATCH 7/9] KVM: Return an error code only as a constant in kvm_get_dirty_log() SF Markus Elfring
2017-01-22 18:18 ` [PATCH 8/9] KVM: Adjust seven checks for null pointers SF Markus Elfring
2017-01-22 20:32   ` kbuild test robot
2017-01-22 21:35   ` kbuild test robot
2017-01-23  9:30   ` Dan Carpenter
2017-01-22 18:19 ` [PATCH 9/9] KVM: Improve another size determination in kvm_create_vm() SF Markus Elfring
2017-01-23  9:22 ` [PATCH 0/9] KVM: Fine-tuning for several function implementations Paolo Bonzini
2017-01-23  9:48   ` SF Markus Elfring
2017-01-23 14:06     ` Paolo Bonzini
2017-01-24  2:15     ` Bernd Petrovitsch
2017-01-24 11:36       ` SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f83abd2-cf68-4294-6603-cfab2991e731@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox