On 01/21/2017 05:03 PM, SF Markus Elfring wrote: > From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> > 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 <elfring@xxxxxxxxxxxxxxxxxxxxx> 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); >