Re: [PATCH v5 03/14] KVM: ARM: Initial skeleton to compile KVM support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 14, 2013 at 11:24 AM, Russell King - ARM Linux
<linux@xxxxxxxxxxxxxxxx> wrote:
> On Tue, Jan 08, 2013 at 01:38:55PM -0500, Christoffer Dall wrote:
>> +     /* -ENOENT for unknown features, -EINVAL for invalid combinations. */
>> +     for (i = 0; i < sizeof(init->features)*8; i++) {
>> +             if (init->features[i / 32] & (1 << (i % 32))) {
>
> Isn't this an open-coded version of test_bit() ?

indeed, nicely spotted:

commit 608588674144e403ad0ea3c93066f3175bd5cf88
Author: Christoffer Dall <c.dall@xxxxxxxxxxxxxxxxxxxxxx>
Date:   Mon Jan 14 12:30:07 2013 -0500

    KVM: ARM: Use test-bit instead of open-coded version

    Makes the code more readable, also adds spaces around the asterisk.

    Cc: Russell King <linux@xxxxxxxxxxxxxxxx>
    Signed-off-by: Christoffer Dall <c.dall@xxxxxxxxxxxxxxxxxxxxxx>

diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c
index 65ae563..2339d96 100644
--- a/arch/arm/kvm/guest.c
+++ b/arch/arm/kvm/guest.c
@@ -193,8 +193,8 @@ int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
 	bitmap_zero(vcpu->arch.features, KVM_VCPU_MAX_FEATURES);

 	/* -ENOENT for unknown features, -EINVAL for invalid combinations. */
-	for (i = 0; i < sizeof(init->features)*8; i++) {
-		if (init->features[i / 32] & (1 << (i % 32))) {
+	for (i = 0; i < sizeof(init->features) * 8; i++) {
+		if (test_bit(i, (void *)init->features)) {
 			if (i >= KVM_VCPU_MAX_FEATURES)
 				return -ENOENT;
 			set_bit(i, vcpu->arch.features);
--

Thanks,
-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux