* Re: [PATCH -next] binder: simplify the return expression of binder_mmap
2020-09-21 8:24 ` Liu Shixin
@ 2020-09-21 8:08 ` Christian Brauner
-1 siblings, 0 replies; 18+ messages in thread
From: Christian Brauner @ 2020-09-21 8:08 UTC (permalink / raw)
To: Liu Shixin
Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Martijn Coenen, Joel Fernandes, Christian Brauner,
Hridya Valsaraju, Suren Baghdasaryan, devel, linux-kernel
On Mon, Sep 21, 2020 at 04:24:23PM +0800, Liu Shixin wrote:
> Simplify the return expression.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH -next] binder: simplify the return expression of binder_mmap
@ 2020-09-21 8:08 ` Christian Brauner
0 siblings, 0 replies; 18+ messages in thread
From: Christian Brauner @ 2020-09-21 8:08 UTC (permalink / raw)
To: Liu Shixin
Cc: devel, Todd Kjos, Greg Kroah-Hartman, linux-kernel,
Suren Baghdasaryan, Hridya Valsaraju, Arve Hjønnevåg,
Joel Fernandes, Martijn Coenen, Christian Brauner
On Mon, Sep 21, 2020 at 04:24:23PM +0800, Liu Shixin wrote:
> Simplify the return expression.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
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
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH -next] binder: simplify the return expression of binder_mmap
@ 2020-09-21 8:24 ` Liu Shixin
0 siblings, 0 replies; 18+ messages in thread
From: Liu Shixin @ 2020-09-21 8:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Martijn Coenen, Joel Fernandes, Christian Brauner,
Hridya Valsaraju, Suren Baghdasaryan
Cc: devel, linux-kernel, Liu Shixin
Simplify the return expression.
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
drivers/android/binder.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 37a505c41dec..1f929e0cf39f 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -5204,10 +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;
+ return binder_alloc_mmap_handler(&proc->alloc, vma);
err_bad_arg:
pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH -next] binder: simplify the return expression of binder_mmap
@ 2020-09-21 8:24 ` Liu Shixin
0 siblings, 0 replies; 18+ messages in thread
From: Liu Shixin @ 2020-09-21 8:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Martijn Coenen, Joel Fernandes, Christian Brauner,
Hridya Valsaraju, Suren Baghdasaryan
Cc: devel, Liu Shixin, linux-kernel
Simplify the return expression.
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
drivers/android/binder.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 37a505c41dec..1f929e0cf39f 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -5204,10 +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;
+ return binder_alloc_mmap_handler(&proc->alloc, vma);
err_bad_arg:
pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
--
2.25.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH -next] binder: simplify the return expression of binder_mmap
2020-09-21 8:08 ` Christian Brauner
@ 2020-09-21 10:42 ` Liu Shixin
-1 siblings, 0 replies; 18+ messages in thread
From: Liu Shixin @ 2020-09-21 10:42 UTC (permalink / raw)
To: Christian Brauner
Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Martijn Coenen, Joel Fernandes, Christian Brauner,
Hridya Valsaraju, Suren Baghdasaryan, devel, linux-kernel
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 <liushixin2@huawei.com>
>> ---
> 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
> .
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH -next] binder: simplify the return expression of binder_mmap
@ 2020-09-21 10:42 ` Liu Shixin
0 siblings, 0 replies; 18+ messages in thread
From: Liu Shixin @ 2020-09-21 10:42 UTC (permalink / raw)
To: Christian Brauner
Cc: devel, Todd Kjos, Greg Kroah-Hartman, linux-kernel,
Suren Baghdasaryan, Hridya Valsaraju, Arve Hjønnevåg,
Joel Fernandes, Martijn Coenen, Christian Brauner
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 <liushixin2@huawei.com>
>> ---
> 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH -next] binder: simplify the return expression of binder_mmap
2020-09-21 8:08 ` Christian Brauner
@ 2020-09-21 11:47 ` Liu Shixin
-1 siblings, 0 replies; 18+ messages in thread
From: Liu Shixin @ 2020-09-21 11:47 UTC (permalink / raw)
To: Christian Brauner
Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Martijn Coenen, Joel Fernandes, Hridya Valsaraju,
Suren Baghdasaryan, devel, linux-kernel, Liu Shixin
Simplify the return expression.
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH -next] binder: simplify the return expression of binder_mmap
@ 2020-09-21 11:47 ` Liu Shixin
0 siblings, 0 replies; 18+ messages in thread
From: Liu Shixin @ 2020-09-21 11:47 UTC (permalink / raw)
To: Christian Brauner
Cc: devel, Liu Shixin, Todd Kjos, Greg Kroah-Hartman, linux-kernel,
Suren Baghdasaryan, Hridya Valsaraju, Arve Hjønnevåg,
Joel Fernandes, Martijn Coenen
Simplify the return expression.
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
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
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH -next] binder: simplify the return expression of binder_mmap
2020-09-21 11:47 ` Liu Shixin
@ 2020-09-27 12:35 ` Greg Kroah-Hartman
-1 siblings, 0 replies; 18+ messages in thread
From: Greg Kroah-Hartman @ 2020-09-27 12:35 UTC (permalink / raw)
To: Liu Shixin
Cc: Christian Brauner, devel, Todd Kjos, linux-kernel,
Suren Baghdasaryan, Hridya Valsaraju, Arve Hjønnevåg,
Joel Fernandes, Martijn Coenen
On Mon, Sep 21, 2020 at 07:47:34PM +0800, Liu Shixin wrote:
> Simplify the return expression.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
> drivers/android/binder.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
Is this a v2 patch?
If so, please properly label it and say what changed from the v1 version
below the --- line.
Please fix up and resend a v3.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH -next] binder: simplify the return expression of binder_mmap
@ 2020-09-27 12:35 ` Greg Kroah-Hartman
0 siblings, 0 replies; 18+ messages in thread
From: Greg Kroah-Hartman @ 2020-09-27 12:35 UTC (permalink / raw)
To: Liu Shixin
Cc: devel, Todd Kjos, Martijn Coenen, linux-kernel, Joel Fernandes,
Arve Hjønnevåg, Hridya Valsaraju, Suren Baghdasaryan,
Christian Brauner
On Mon, Sep 21, 2020 at 07:47:34PM +0800, Liu Shixin wrote:
> Simplify the return expression.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
> drivers/android/binder.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
Is this a v2 patch?
If so, please properly label it and say what changed from the v1 version
below the --- line.
Please fix up and resend a v3.
thanks,
greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 -next] binder: simplify the return expression of binder_mmap
2020-09-27 12:35 ` Greg Kroah-Hartman
@ 2020-09-29 1:52 ` Liu Shixin
-1 siblings, 0 replies; 18+ messages in thread
From: Liu Shixin @ 2020-09-29 1:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Christian Brauner, Arve Hjønnevåg, Todd Kjos,
Martijn Coenen, Joel Fernandes, Hridya Valsaraju,
Suren Baghdasaryan, devel, linux-kernel, Liu Shixin
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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 -next] binder: simplify the return expression of binder_mmap
@ 2020-09-29 1:52 ` Liu Shixin
0 siblings, 0 replies; 18+ messages in thread
From: Liu Shixin @ 2020-09-29 1:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, Todd Kjos, Suren Baghdasaryan, linux-kernel, Liu Shixin,
Hridya Valsaraju, Arve Hjønnevåg, Joel Fernandes,
Martijn Coenen, Christian Brauner
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
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v3 -next] binder: simplify the return expression of binder_mmap
2020-09-29 1:52 ` Liu Shixin
@ 2020-10-02 13:48 ` Greg Kroah-Hartman
-1 siblings, 0 replies; 18+ messages in thread
From: Greg Kroah-Hartman @ 2020-10-02 13:48 UTC (permalink / raw)
To: Liu Shixin
Cc: devel, Todd Kjos, Suren Baghdasaryan, linux-kernel,
Hridya Valsaraju, Arve Hjønnevåg, Joel Fernandes,
Martijn Coenen, Christian Brauner
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 -next] binder: simplify the return expression of binder_mmap
@ 2020-10-02 13:48 ` Greg Kroah-Hartman
0 siblings, 0 replies; 18+ messages in thread
From: Greg Kroah-Hartman @ 2020-10-02 13:48 UTC (permalink / raw)
To: Liu Shixin
Cc: devel, Todd Kjos, Martijn Coenen, linux-kernel, Joel Fernandes,
Arve Hjønnevåg, Hridya Valsaraju, Suren Baghdasaryan,
Christian Brauner
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 -next] binder: simplify the return expression of binder_mmap
2020-09-29 1:52 ` Liu Shixin
@ 2020-10-02 14:18 ` Martijn Coenen
-1 siblings, 0 replies; 18+ messages in thread
From: Martijn Coenen @ 2020-10-02 14:18 UTC (permalink / raw)
To: Liu Shixin
Cc: Greg Kroah-Hartman, Christian Brauner, Arve Hjønnevåg,
Todd Kjos, Joel Fernandes, Hridya Valsaraju, Suren Baghdasaryan,
open list:ANDROID DRIVERS, LKML
Thanks!
On Tue, Sep 29, 2020 at 3:30 AM Liu Shixin <liushixin2@huawei.com> wrote:
>
> Simplify the return expression.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Acked-by: Martijn Coenen <maco@android.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
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 -next] binder: simplify the return expression of binder_mmap
@ 2020-10-02 14:18 ` Martijn Coenen
0 siblings, 0 replies; 18+ messages in thread
From: Martijn Coenen @ 2020-10-02 14:18 UTC (permalink / raw)
To: Liu Shixin
Cc: open list:ANDROID DRIVERS, Todd Kjos, Greg Kroah-Hartman, LKML,
Hridya Valsaraju, Arve Hjønnevåg, Joel Fernandes,
Suren Baghdasaryan, Christian Brauner
Thanks!
On Tue, Sep 29, 2020 at 3:30 AM Liu Shixin <liushixin2@huawei.com> wrote:
>
> Simplify the return expression.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Acked-by: Martijn Coenen <maco@android.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
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 -next] binder: simplify the return expression of binder_mmap
2020-09-29 1:52 ` Liu Shixin
@ 2020-10-02 14:28 ` Christian Brauner
-1 siblings, 0 replies; 18+ messages in thread
From: Christian Brauner @ 2020-10-02 14:28 UTC (permalink / raw)
To: Liu Shixin
Cc: Greg Kroah-Hartman, Christian Brauner, Arve Hjønnevåg,
Todd Kjos, Martijn Coenen, Joel Fernandes, Hridya Valsaraju,
Suren Baghdasaryan, devel, linux-kernel
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>
> ---
Thanks!
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 -next] binder: simplify the return expression of binder_mmap
@ 2020-10-02 14:28 ` Christian Brauner
0 siblings, 0 replies; 18+ messages in thread
From: Christian Brauner @ 2020-10-02 14:28 UTC (permalink / raw)
To: Liu Shixin
Cc: devel, Todd Kjos, Greg Kroah-Hartman, linux-kernel,
Suren Baghdasaryan, Hridya Valsaraju, Arve Hjønnevåg,
Joel Fernandes, Martijn Coenen, Christian Brauner
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>
> ---
Thanks!
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2020-10-02 14:28 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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.