Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2956985pxk; Mon, 21 Sep 2020 01:13:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUwYhxCM5dV1VCq21QfU9FXhKqjZ6gwa/7cyYus8dNUg6Aguk1wG8DzJWCwUDi4ErjY2Dn X-Received: by 2002:a17:906:b097:: with SMTP id x23mr46980262ejy.21.1600676012148; Mon, 21 Sep 2020 01:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600676012; cv=none; d=google.com; s=arc-20160816; b=IjdFncY81CyqCnkf/ToRXuWxeeTJpxlH8SeNUHY5wb/G1W9fmJPGgBfs8hLSLip3Yd HN/KVDTI6wfR8jxa7n0WRWrhdgoRd/D0xj/DO3JLVigixPy1tlUu2HsES9iLMwpi8xmZ NYFJ/Ondw3CFeU+bX6RzxtoXK07TG22x95a+DGb15Bvp+wFzw6JGXgZJh/MC8ATVuZ9v hc9ze+7IZVSG9jyyscvwnbWd9mnFfjNUgAOo0FM1c1JilycRTTt1hY8boUbcHajKGgeC /I8G25XshjmoE6nBVijeuepIHFT2ZDh0oC5rIHqLkqt9ApsgsRJnXm8AZAyXMPAiruYj 572g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=nm2r+uCL7+DsOsUs4HDm/878pgNcKKrBsejThjQ0uuc=; b=T0KtTk0eyXzlYqNWOvVHSuAKH6Y+8UNayrGDBlaRWKj8uaOtjscRZpEzRB36mUFg4j ta3yYxkBK3EaiGkG2dW6d5+n5Jjm6iuINrPHei18p0TqKt0YDcUrsqidh+yDvWCVIYyI tY0URqShULq93MTuDqw1sW8JWi66T/E43EOy5j21tkxyf3ly8jOd8H1m2fgwH1F6kV0t Y8co7MXjLtz5cjB4GLhF1Ajcdgm2gbYbNVInikJPBoPHKvGMYtdk6I3rO3Iy414py1zY i3vOMaRwL7exdBMvc00lu/h0PdwZF4NpV4NMvZ/zltrVJgTvO8re7W/iXflYcWqtZ4As +s3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si7924237edr.259.2020.09.21.01.13.09; Mon, 21 Sep 2020 01:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726762AbgIUIJT (ORCPT + 99 others); Mon, 21 Sep 2020 04:09:19 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:49894 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgIUIIm (ORCPT ); Mon, 21 Sep 2020 04:08:42 -0400 Received: from ip5f5af089.dynamic.kabel-deutschland.de ([95.90.240.137] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kKGsA-0003Dj-SL; Mon, 21 Sep 2020 08:08:30 +0000 Date: Mon, 21 Sep 2020 10:08:30 +0200 From: Christian Brauner To: Liu Shixin Cc: Greg Kroah-Hartman , Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Hridya Valsaraju , Suren Baghdasaryan , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] binder: simplify the return expression of binder_mmap Message-ID: <20200921080830.vrki7dcm64l46ppb@wittgenstein> References: <20200921082423.2590938-1-liushixin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200921082423.2590938-1-liushixin2@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 21, 2020 at 04:24:23PM +0800, Liu Shixin wrote: > Simplify the return expression. > > Signed-off-by: Liu Shixin > --- Why not is all I can really say. :) But if this is about simplifying you could get rid of the "ret" and "failure string" variables, and the goto in that function completely by doing sm like this (__completely untested__): diff --git a/drivers/android/binder.c b/drivers/android/binder.c index f936530a19b0..26f4dc81b008 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -5182,9 +5182,7 @@ static const struct vm_operations_struct binder_vm_ops = { static int binder_mmap(struct file *filp, struct vm_area_struct *vma) { - int ret; struct binder_proc *proc = filp->private_data; - const char *failure_string; if (proc->tsk != current->group_leader) return -EINVAL; @@ -5196,9 +5194,9 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma) (unsigned long)pgprot_val(vma->vm_page_prot)); if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) { - ret = -EPERM; - failure_string = "bad vm_flags"; - goto err_bad_arg; + pr_err("%s: %d %lx-%lx %s failed %d\n", __func__, + proc->pid, vma->vm_start, vma->vm_end, "bad vm_flags", -EPERM); + return -EPERM; } vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP; vma->vm_flags &= ~VM_MAYWRITE; @@ -5206,15 +5204,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma) vma->vm_ops = &binder_vm_ops; vma->vm_private_data = proc; - ret = binder_alloc_mmap_handler(&proc->alloc, vma); - if (ret) - return ret; - return 0; - -err_bad_arg: - pr_err("%s: %d %lx-%lx %s failed %d\n", __func__, - proc->pid, vma->vm_start, vma->vm_end, failure_string, ret); - return ret; + return binder_alloc_mmap_handler(&proc->alloc, vma); } Christian