Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests: kvm: Adds a judgment on the return value
@ 2024-10-21 10:06 Liu Jing
  2024-10-21 11:20 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Jing @ 2024-10-21 10:06 UTC (permalink / raw)
  To: borntraeger
  Cc: frankja, imbrenda, david, pbonzini, shuah, kvm, linux-kselftest,
	linux-kernel, Liu Jing

The global variable errno is not recommended to be assigned,
    and rc in the function does not check its return value, so it is fixed

Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
---
 tools/testing/selftests/kvm/s390x/cmma_test.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/s390x/cmma_test.c b/tools/testing/selftests/kvm/s390x/cmma_test.c
index e32dd59703a0..c59c21f28bbd 100644
--- a/tools/testing/selftests/kvm/s390x/cmma_test.c
+++ b/tools/testing/selftests/kvm/s390x/cmma_test.c
@@ -210,7 +210,7 @@ static int vm_get_cmma_bits(struct kvm_vm *vm, u64 flags, int *errno_out)
 	struct kvm_s390_cmma_log args;
 	int rc;
 
-	errno = 0;
+	*errno_out = 0;
 
 	args = (struct kvm_s390_cmma_log){
 		.start_gfn = 0,
@@ -219,8 +219,10 @@ static int vm_get_cmma_bits(struct kvm_vm *vm, u64 flags, int *errno_out)
 		.values = (__u64)&cmma_value_buf[0]
 	};
 	rc = __vm_ioctl(vm, KVM_S390_GET_CMMA_BITS, &args);
+	if (rc < 0) {
+		*errno_out = errno;
+	}
 
-	*errno_out = errno;
 	return rc;
 }
 
-- 
2.27.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-21 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 10:06 [PATCH] selftests: kvm: Adds a judgment on the return value Liu Jing
2024-10-21 11:20 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox