From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 933CEC43463 for ; Mon, 21 Sep 2020 10:42:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6247C21BE5 for ; Mon, 21 Sep 2020 10:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726890AbgIUKmr (ORCPT ); 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 > . > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C5E6C43464 for ; Mon, 21 Sep 2020 10:42:51 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B8E621BE5 for ; Mon, 21 Sep 2020 10:42:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B8E621BE5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 493FF86819; Mon, 21 Sep 2020 10:42:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wE5tHypwEl12; Mon, 21 Sep 2020 10:42:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id AA6308682F; Mon, 21 Sep 2020 10:42:49 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 882E41BF34C for ; Mon, 21 Sep 2020 10:42:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8491A8682F for ; Mon, 21 Sep 2020 10:42:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xwCI9U-FyE4R for ; Mon, 21 Sep 2020 10:42:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by whitealder.osuosl.org (Postfix) with ESMTPS id 4F5C486819 for ; Mon, 21 Sep 2020 10:42:47 +0000 (UTC) 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> 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> X-Originating-IP: [10.174.177.116] X-CFilter-Loop: Reflected X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Todd Kjos , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Suren Baghdasaryan , Hridya Valsaraju , =?UTF-8?Q?Arve_Hj=c3=b8nnev=c3=a5g?= , Joel Fernandes , Martijn Coenen , Christian Brauner Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" 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 > . > _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel