* Re: [PATCH] selftests: kvm: Fix the check of return value
2021-04-26 19:31 [PATCH] selftests: kvm: Fix the check of return value Zhenzhong Duan
@ 2021-04-26 9:28 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2021-04-26 9:28 UTC (permalink / raw)
To: Zhenzhong Duan, linux-kernel; +Cc: linux-kselftest, kvm, shuah
On 26/04/21 21:31, Zhenzhong Duan wrote:
> In vm_vcpu_rm() and kvm_vm_release(), a stale return value is checked in
> TEST_ASSERT macro.
>
> Fix it by assigning variable ret with correct return value.
>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
> tools/testing/selftests/kvm/lib/kvm_util.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
> index b8849a1aca79..53d3a7eb0d47 100644
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -514,7 +514,7 @@ static void vm_vcpu_rm(struct kvm_vm *vm, struct vcpu *vcpu)
> ret = munmap(vcpu->state, vcpu_mmap_sz());
> TEST_ASSERT(ret == 0, "munmap of VCPU fd failed, rc: %i "
> "errno: %i", ret, errno);
> - close(vcpu->fd);
> + ret = close(vcpu->fd);
> TEST_ASSERT(ret == 0, "Close of VCPU fd failed, rc: %i "
> "errno: %i", ret, errno);
>
> @@ -534,7 +534,7 @@ void kvm_vm_release(struct kvm_vm *vmp)
> TEST_ASSERT(ret == 0, "Close of vm fd failed,\n"
> " vmp->fd: %i rc: %i errno: %i", vmp->fd, ret, errno);
>
> - close(vmp->kvm_fd);
> + ret = close(vmp->kvm_fd);
> TEST_ASSERT(ret == 0, "Close of /dev/kvm fd failed,\n"
> " vmp->kvm_fd: %i rc: %i errno: %i", vmp->kvm_fd, ret, errno);
> }
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] selftests: kvm: Fix the check of return value
@ 2021-04-26 19:31 Zhenzhong Duan
2021-04-26 9:28 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Zhenzhong Duan @ 2021-04-26 19:31 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-kselftest, kvm, pbonzini, shuah, Zhenzhong Duan
In vm_vcpu_rm() and kvm_vm_release(), a stale return value is checked in
TEST_ASSERT macro.
Fix it by assigning variable ret with correct return value.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index b8849a1aca79..53d3a7eb0d47 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -514,7 +514,7 @@ static void vm_vcpu_rm(struct kvm_vm *vm, struct vcpu *vcpu)
ret = munmap(vcpu->state, vcpu_mmap_sz());
TEST_ASSERT(ret == 0, "munmap of VCPU fd failed, rc: %i "
"errno: %i", ret, errno);
- close(vcpu->fd);
+ ret = close(vcpu->fd);
TEST_ASSERT(ret == 0, "Close of VCPU fd failed, rc: %i "
"errno: %i", ret, errno);
@@ -534,7 +534,7 @@ void kvm_vm_release(struct kvm_vm *vmp)
TEST_ASSERT(ret == 0, "Close of vm fd failed,\n"
" vmp->fd: %i rc: %i errno: %i", vmp->fd, ret, errno);
- close(vmp->kvm_fd);
+ ret = close(vmp->kvm_fd);
TEST_ASSERT(ret == 0, "Close of /dev/kvm fd failed,\n"
" vmp->kvm_fd: %i rc: %i errno: %i", vmp->kvm_fd, ret, errno);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-26 9:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 19:31 [PATCH] selftests: kvm: Fix the check of return value Zhenzhong Duan
2021-04-26 9:28 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.