From patchwork Sat Dec 7 09:25:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 11277299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9D55112B for ; Sat, 7 Dec 2019 09:26:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A884D21835 for ; Sat, 7 Dec 2019 09:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbfLGJZp (ORCPT ); Sat, 7 Dec 2019 04:25:45 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:44710 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726185AbfLGJZp (ORCPT ); Sat, 7 Dec 2019 04:25:45 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 23309637D4E8FC689AC2; Sat, 7 Dec 2019 17:25:42 +0800 (CST) Received: from huawei.com (10.175.105.18) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Sat, 7 Dec 2019 17:25:33 +0800 From: linmiaohe To: , , , , , , , , , , CC: , , , Subject: [PATCH 2/6] KVM: x86: remove always equal to 0 return val of kvm_vm_ioctl_set_pit() Date: Sat, 7 Dec 2019 17:25:19 +0800 Message-ID: <1575710723-32094-3-git-send-email-linmiaohe@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575710723-32094-1-git-send-email-linmiaohe@huawei.com> References: <1575710723-32094-1-git-send-email-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.105.18] X-CFilter-Loop: Reflected Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Miaohe Lin The return val of kvm_vm_ioctl_set_pit() is always equal to 0, which means there is no way to failed with this function. So remove the return val as it's unnecessary to check against it. Also add BUILD_BUG_ON to guard against channels size changed unexpectly. Signed-off-by: Miaohe Lin --- arch/x86/kvm/x86.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 732f03c19fdc..5628dceb9fa5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4607,17 +4607,18 @@ static void kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps) mutex_unlock(&kps->lock); } -static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps) +static void kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps) { int i; struct kvm_pit *pit = kvm->arch.vpit; + BUILD_BUG_ON(sizeof(*ps) != sizeof(pit->pit_state.channels)); + mutex_lock(&pit->pit_state.lock); memcpy(&pit->pit_state.channels, ps, sizeof(*ps)); for (i = 0; i < 3; i++) kvm_pit_load_count(pit, i, ps->channels[i].count, 0); mutex_unlock(&pit->pit_state.lock); - return 0; } static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) @@ -4994,7 +4995,8 @@ long kvm_arch_vm_ioctl(struct file *filp, r = -ENXIO; if (!kvm->arch.vpit) goto out; - r = kvm_vm_ioctl_set_pit(kvm, &u.ps); + kvm_vm_ioctl_set_pit(kvm, &u.ps); + r = 0; break; } case KVM_GET_PIT2: {