From patchwork Mon Oct 21 10:06:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liujing X-Patchwork-Id: 837963 Received: from cmccmta2.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 696951974F4; Mon, 21 Oct 2024 10:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.22.67.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729505218; cv=none; b=js3WYm7LrX4HzNagtYCT+eTQGjbCzz2F2J3r2tKlDOC++tD0cTYB09MmfyQkw+nlw3vKsoww5m+d+4GlDBfFIR2rPVn+XDtPyh41eihdXGdbI0x/CXd3vpI6i9y3EuCWRZ0+7aOSJvN2LvmuNm7waQWdt4TifsHUbuaYQrY6xJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729505218; c=relaxed/simple; bh=jiNx/VbfXMWt8MLnrl4L90+qNhzCBpFOuZw48hxTOKs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=dxLPcrC8n4K0e76vH/UBIcVh65Jstjh0+7UMxYGi+r4y5CFokv5Mz8UZ7l57JfIn3HZ4YG04yY7k2BUgrbN1RtGXOR8yY6LBU80IB5ouzHF/fXLgaoe2z5IyIyENQQK6ebeYiyXh/WN0pKkfxWVckYOt1o0OlyXS8iLl68zYfp8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; arc=none smtp.client-ip=111.22.67.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app05-12005 (RichMail) with SMTP id 2ee5671627bb7b3-557c2; Mon, 21 Oct 2024 18:06:51 +0800 (CST) X-RM-TRANSID: 2ee5671627bb7b3-557c2 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[223.108.79.103]) by rmsmtp-syy-appsvr04-12004 (RichMail) with SMTP id 2ee4671627bad7c-47302; Mon, 21 Oct 2024 18:06:51 +0800 (CST) X-RM-TRANSID: 2ee4671627bad7c-47302 From: Liu Jing To: borntraeger@linux.ibm.com Cc: frankja@linux.ibm.com, imbrenda@linux.ibm.com, david@redhat.com, pbonzini@redhat.com, shuah@kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Liu Jing Subject: [PATCH] selftests: kvm: Adds a judgment on the return value Date: Mon, 21 Oct 2024 18:06:44 +0800 Message-Id: <20241021100644.3591-1-liujing@cmss.chinamobile.com> X-Mailer: git-send-email 2.27.0 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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; }