All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Liu Shixin <liushixin2@huawei.com>
Cc: devel@driverdev.osuosl.org, "Todd Kjos" <tkjos@android.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	linux-kernel@vger.kernel.org,
	"Hridya Valsaraju" <hridya@google.com>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Martijn Coenen" <maco@android.com>,
	"Christian Brauner" <christian@brauner.io>
Subject: Re: [PATCH v3 -next] binder: simplify the return expression of binder_mmap
Date: Fri, 2 Oct 2020 15:48:07 +0200	[thread overview]
Message-ID: <20201002134807.GA3427371@kroah.com> (raw)
In-Reply-To: <20200929015216.1829946-1-liushixin2@huawei.com>

On Tue, Sep 29, 2020 at 09:52:16AM +0800, Liu Shixin wrote:
> Simplify the return expression.
> 
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
> v3: Add the change description.
> v2: Get rid of the "ret" and "failure string" variables.
> v1: Simplify the return expression.
> ---
>  drivers/android/binder.c | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 37a505c41dec..49c0700816a5 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -5180,9 +5180,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;
> @@ -5194,9 +5192,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;
> @@ -5204,15 +5202,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);
>  }
>  
>  static int binder_open(struct inode *nodp, struct file *filp)
> -- 
> 2.25.1

Todd and other Binder maintainers, what do you think of this?

thanks,

greg k-h

WARNING: multiple messages have this Message-ID (diff)
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Liu Shixin <liushixin2@huawei.com>
Cc: devel@driverdev.osuosl.org, "Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	linux-kernel@vger.kernel.org,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Hridya Valsaraju" <hridya@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Christian Brauner" <christian@brauner.io>
Subject: Re: [PATCH v3 -next] binder: simplify the return expression of binder_mmap
Date: Fri, 2 Oct 2020 15:48:07 +0200	[thread overview]
Message-ID: <20201002134807.GA3427371@kroah.com> (raw)
In-Reply-To: <20200929015216.1829946-1-liushixin2@huawei.com>

On Tue, Sep 29, 2020 at 09:52:16AM +0800, Liu Shixin wrote:
> Simplify the return expression.
> 
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
> v3: Add the change description.
> v2: Get rid of the "ret" and "failure string" variables.
> v1: Simplify the return expression.
> ---
>  drivers/android/binder.c | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 37a505c41dec..49c0700816a5 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -5180,9 +5180,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;
> @@ -5194,9 +5192,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;
> @@ -5204,15 +5202,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);
>  }
>  
>  static int binder_open(struct inode *nodp, struct file *filp)
> -- 
> 2.25.1

Todd and other Binder maintainers, what do you think of this?

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  reply	other threads:[~2020-10-02 13:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21  8:24 [PATCH -next] binder: simplify the return expression of binder_mmap Liu Shixin
2020-09-21  8:24 ` Liu Shixin
2020-09-21  8:08 ` Christian Brauner
2020-09-21  8:08   ` Christian Brauner
2020-09-21 10:42   ` Liu Shixin
2020-09-21 10:42     ` Liu Shixin
2020-09-21 11:47   ` Liu Shixin
2020-09-21 11:47     ` Liu Shixin
2020-09-27 12:35     ` Greg Kroah-Hartman
2020-09-27 12:35       ` Greg Kroah-Hartman
2020-09-29  1:52       ` [PATCH v3 " Liu Shixin
2020-09-29  1:52         ` Liu Shixin
2020-10-02 13:48         ` Greg Kroah-Hartman [this message]
2020-10-02 13:48           ` Greg Kroah-Hartman
2020-10-02 14:18         ` Martijn Coenen
2020-10-02 14:18           ` Martijn Coenen
2020-10-02 14:28         ` Christian Brauner
2020-10-02 14:28           ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201002134807.GA3427371@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arve@android.com \
    --cc=christian@brauner.io \
    --cc=devel@driverdev.osuosl.org \
    --cc=hridya@google.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liushixin2@huawei.com \
    --cc=maco@android.com \
    --cc=surenb@google.com \
    --cc=tkjos@android.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.