From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750753AbdAWIXM (ORCPT ); Mon, 23 Jan 2017 03:23:12 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40804 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbdAWIXK (ORCPT ); Mon, 23 Jan 2017 03:23:10 -0500 Subject: Re: [PATCH] KVM: s390: Move two error code assignments in kvm_vm_ioctl_get_dirty_log() To: SF Markus Elfring , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Cornelia Huck , Heiko Carstens , Martin Schwidefsky , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <70f41e59-d8a4-de42-6064-80ecf6acc065@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: Christian Borntraeger Date: Mon, 23 Jan 2017 09:22:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <70f41e59-d8a4-de42-6064-80ecf6acc065@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17012308-0028-0000-0000-000006D8AC2D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006482; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000200; SDB=6.00811434; UDB=6.00395614; IPR=6.00588850; BA=6.00005084; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014010; XFM=3.00000011; UTC=2017-01-23 08:23:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17012308-0029-0000-0000-000032EF9861 Message-Id: <35411200-2bd6-1c65-7d7f-21a6353875ea@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-23_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701230119 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/21/2017 05:03 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sat, 21 Jan 2017 16:52:23 +0100 > > A local variable was set to an error code in two cases before a concrete > error situation was detected. Thus move the corresponding assignments into > if branches to indicate a software failure there. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring Patches that changes open coded things to common helpers or things like kmalloc_array where appropriate or things that make the code more robust are fine and welcome, but I am not going to take this as it just shuffles things around. It does not fix anything and it does not improve the code, but it certainly carries the risk of breaking something (yes in this case it looks perfectly fine, though). PS: When you look at the kvm/mips change that you have recently made, this case is better and qualifies as in improvement, because you remove lines and the code does get simpler. Due to the locking requirements we cannot do such a simplification here. Christian > --- > arch/s390/kvm/kvm-s390.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > index 4f74511015b8..bc875d08b838 100644 > --- a/arch/s390/kvm/kvm-s390.c > +++ b/arch/s390/kvm/kvm-s390.c > @@ -443,16 +443,17 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, > int is_dirty = 0; > > mutex_lock(&kvm->slots_lock); > - > - r = -EINVAL; > - if (log->slot >= KVM_USER_MEM_SLOTS) > + if (log->slot >= KVM_USER_MEM_SLOTS) { > + r = -EINVAL; > goto out; > + } > > slots = kvm_memslots(kvm); > memslot = id_to_memslot(slots, log->slot); > - r = -ENOENT; > - if (!memslot->dirty_bitmap) > + if (!memslot->dirty_bitmap) { > + r = -ENOENT; > goto out; > + } > > kvm_s390_sync_dirty_log(kvm, memslot); > r = kvm_get_dirty_log(kvm, log, &is_dirty); >