Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3036248pxk; Mon, 21 Sep 2020 03:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEwn4x2ofshmkfgjb5bwj0TaeD1hlRSAxh7EEO1sAr7RmWMFsV4BHd8hTm+RagXMOBgQ6H X-Received: by 2002:aa7:cb0e:: with SMTP id s14mr50383300edt.225.1600685060316; Mon, 21 Sep 2020 03:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600685060; cv=none; d=google.com; s=arc-20160816; b=JLIAK5TU7ekQ3NDQNlFazHfwiezhL+px7BXyBF3pIzb9eY3vnEfqXePUtxX0cGUvM9 TnDsNRw3yKqrTqlKX58PPUTB4SAsgxCYM10BnrQHe7bBhIySzbb7MEivucga2yG7R7fZ 3ypV050Or4aWqBz9YObRKPq8Y+W3VyXb3CAa6nFWKpgiDjk+SP2YmHk5u7VBnqjgXch8 z3bCv/ZqT2zcQVGzTJZ7wz14hGc6LwEBj9xBMKts5UDePvBMYc9/S1v/LACus1CAwovJ aLY3ylIOp6nEWZHkjuaD83mWm6A0VYpCKNRp3nOJG9c+UdTQavDLQQh/QnT0v8l5HnSY xLtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=qzUbwoCq9tB4axzk5tGgr8lQ9TvD0OE6qkiJUUgA8EQ=; b=0w3cQAqZg/R92zGJGA7YqEQbKfmmRgP1UhyZQTljpw48uy/68T7EpGvde5iGolJq0d xgCu3A2Uh31wIq/7ndb1VFeuS1WotGrNzMR7rjkSDIXx9OVKCB91L4hMmZpvNlyEOBNe 0+mVQiZWzExCwYNdBajWrtiy93uLrUb09IE8TOZtMEyEQdnNbvPdl5IPzy7guzoSAhA2 f8j5qRcLkZFfL9zenVaYJX9W5Jb53bAglaBVumtxsQ++hV+WHZlVDqRTpBBVdA3QCcKR dOTLGHqznBO51rDKG0PKv3FjKOOYxkLVqNaRDqP6p/YP5zvxsZhsmy639hcnnpD3V1iO iBMw== 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 a42si10884412edf.535.2020.09.21.03.43.56; Mon, 21 Sep 2020 03:44:20 -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 S1726878AbgIUKmr (ORCPT + 99 others); Mon, 21 Sep 2020 06:42:47 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:39292 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726597AbgIUKmr (ORCPT ); Mon, 21 Sep 2020 06:42:47 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1AE7F8EA4FB39AF6CF93; Mon, 21 Sep 2020 18:42:43 +0800 (CST) Received: from [10.174.177.116] (10.174.177.116) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Mon, 21 Sep 2020 18:42:39 +0800 Subject: Re: [PATCH -next] binder: simplify the return expression of binder_mmap To: Christian Brauner References: <20200921082423.2590938-1-liushixin2@huawei.com> <20200921080830.vrki7dcm64l46ppb@wittgenstein> CC: Greg Kroah-Hartman , =?UTF-8?Q?Arve_Hj=c3=b8nnev=c3=a5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , "Hridya Valsaraju" , Suren Baghdasaryan , , From: Liu Shixin Message-ID: Date: Mon, 21 Sep 2020 18:42:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20200921080830.vrki7dcm64l46ppb@wittgenstein> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.116] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/9/21 16:08, Christian Brauner wrote: > 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__): Thanks for your advice. I will modify and test it. Regards, Liu Shixin > > 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 > . >