linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] elf: simpler check for -EEXIST
@ 2019-03-14 20:42 Alexey Dobriyan
  2019-03-14 22:02 ` Tetsuo Handa
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2019-03-14 20:42 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, penguin-kernel

	PTR_ERR((void *)map_addr) == -EEXIST

is a very complicated way of doing the obvious.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/binfmt_elf.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -375,8 +375,7 @@ static unsigned long elf_map(struct file *filep, unsigned long addr,
 	} else
 		map_addr = vm_mmap(filep, addr, size, prot, type, off);
 
-	if ((type & MAP_FIXED_NOREPLACE) &&
-	    PTR_ERR((void *)map_addr) == -EEXIST)
+	if ((type & MAP_FIXED_NOREPLACE) && map_addr == -EEXIST)
 		pr_info("%d (%s): Uhuuh, elf segment at %px requested but the memory is mapped already\n",
 			task_pid_nr(current), current->comm, (void *)addr);
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] elf: simpler check for -EEXIST
  2019-03-14 20:42 [PATCH 1/2] elf: simpler check for -EEXIST Alexey Dobriyan
@ 2019-03-14 22:02 ` Tetsuo Handa
  2019-03-15 16:05   ` Alexey Dobriyan
  0 siblings, 1 reply; 4+ messages in thread
From: Tetsuo Handa @ 2019-03-14 22:02 UTC (permalink / raw)
  To: Alexey Dobriyan, akpm; +Cc: linux-kernel, Michal Hocko

On 2019/03/15 5:42, Alexey Dobriyan wrote:
> 	PTR_ERR((void *)map_addr) == -EEXIST
> 
> is a very complicated way of doing the obvious.

Michal suggested me to explicitly use PTR_ERR() for documentation purpose in
a reply mail to https://lkml.kernel.org/r/20180418115546.GZ17484@dhcp22.suse.cz .

> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
> 
>  fs/binfmt_elf.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -375,8 +375,7 @@ static unsigned long elf_map(struct file *filep, unsigned long addr,
>  	} else
>  		map_addr = vm_mmap(filep, addr, size, prot, type, off);
>  
> -	if ((type & MAP_FIXED_NOREPLACE) &&
> -	    PTR_ERR((void *)map_addr) == -EEXIST)
> +	if ((type & MAP_FIXED_NOREPLACE) && map_addr == -EEXIST)
>  		pr_info("%d (%s): Uhuuh, elf segment at %px requested but the memory is mapped already\n",
>  			task_pid_nr(current), current->comm, (void *)addr);
>  
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] elf: simpler check for -EEXIST
  2019-03-14 22:02 ` Tetsuo Handa
@ 2019-03-15 16:05   ` Alexey Dobriyan
  2019-03-16  8:31     ` Michal Hocko
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2019-03-15 16:05 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: akpm, linux-kernel, Michal Hocko

On Fri, Mar 15, 2019 at 07:02:23AM +0900, Tetsuo Handa wrote:
> On 2019/03/15 5:42, Alexey Dobriyan wrote:
> > 	PTR_ERR((void *)map_addr) == -EEXIST
> > 
> > is a very complicated way of doing the obvious.
> 
> Michal suggested me to explicitly use PTR_ERR()

without any explanation why...

I wonder what documentation does this line need?

	map_addr == -EEXIST


> for documentation purpose in
> a reply mail to https://lkml.kernel.org/r/20180418115546.GZ17484@dhcp22.suse.cz .
> 
> > 
> > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > ---
> > 
> >  fs/binfmt_elf.c |    3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > --- a/fs/binfmt_elf.c
> > +++ b/fs/binfmt_elf.c
> > @@ -375,8 +375,7 @@ static unsigned long elf_map(struct file *filep, unsigned long addr,
> >  	} else
> >  		map_addr = vm_mmap(filep, addr, size, prot, type, off);
> >  
> > -	if ((type & MAP_FIXED_NOREPLACE) &&
> > -	    PTR_ERR((void *)map_addr) == -EEXIST)
> > +	if ((type & MAP_FIXED_NOREPLACE) && map_addr == -EEXIST)
> >  		pr_info("%d (%s): Uhuuh, elf segment at %px requested but the memory is mapped already\n",
> >  			task_pid_nr(current), current->comm, (void *)addr);
> >  
> > 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] elf: simpler check for -EEXIST
  2019-03-15 16:05   ` Alexey Dobriyan
@ 2019-03-16  8:31     ` Michal Hocko
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2019-03-16  8:31 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: Tetsuo Handa, akpm, linux-kernel

On Fri 15-03-19 19:05:17, Alexey Dobriyan wrote:
> On Fri, Mar 15, 2019 at 07:02:23AM +0900, Tetsuo Handa wrote:
> > On 2019/03/15 5:42, Alexey Dobriyan wrote:
> > > 	PTR_ERR((void *)map_addr) == -EEXIST
> > > 
> > > is a very complicated way of doing the obvious.
> > 
> > Michal suggested me to explicitly use PTR_ERR()
> 
> without any explanation why...

The return value is ERR_PTR. This code uses unsigned long which is OK
but I thought it is better to call out the return value convention
explicitly. It is not like I would argue about that though.
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-16  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 20:42 [PATCH 1/2] elf: simpler check for -EEXIST Alexey Dobriyan
2019-03-14 22:02 ` Tetsuo Handa
2019-03-15 16:05   ` Alexey Dobriyan
2019-03-16  8:31     ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).