All of lore.kernel.org
 help / color / mirror / Atom feed
* pointless code in probe_kernel_read
@ 2013-11-11 15:13 Mikulas Patocka
  2013-11-11 21:33 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2013-11-11 15:13 UTC (permalink / raw)
  To: Helge Deller; +Cc: linux-parisc

Hi Helge

I noted that you created this function in commit 
db080f9c530f78dad661257885a1893506077068

long probe_kernel_read(void *dst, const void *src, size_t size)
{
        unsigned long addr = (unsigned long)src;

        if (size < 0 || addr < PAGE_SIZE)
                return -EFAULT;

        /* check for I/O space F_EXTEND(0xfff00000) access as well? */

        return __probe_kernel_read(dst, src, size);
}

size_t is unsigned, so comparison size < 0 doesn't make sense. What 
exactly did you mean by this test?

Mikulas

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

* Re: pointless code in probe_kernel_read
  2013-11-11 15:13 pointless code in probe_kernel_read Mikulas Patocka
@ 2013-11-11 21:33 ` Helge Deller
  0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2013-11-11 21:33 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: linux-parisc

Hi Mikulas,

On 11/11/2013 04:13 PM, Mikulas Patocka wrote:
> Hi Helge
> 
> I noted that you created this function in commit 
> db080f9c530f78dad661257885a1893506077068
> 
> long probe_kernel_read(void *dst, const void *src, size_t size)
> {
>         unsigned long addr = (unsigned long)src;
> 
>         if (size < 0 || addr < PAGE_SIZE)
>                 return -EFAULT;
> 
>         /* check for I/O space F_EXTEND(0xfff00000) access as well? */
> 
>         return __probe_kernel_read(dst, src, size);
> }
> 
> size_t is unsigned, so comparison size < 0 doesn't make sense. What 
> exactly did you mean by this test?

Of course you are right. The "size < 0" check is superfluous.
I noticed that too when the code went upstream, but I was not yet motivated
too much to remove it again - at least the compiler should optimize it out.

The second part (addr < PAGE_SIZE) is relevant though.

Helge

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

end of thread, other threads:[~2013-11-11 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-11 15:13 pointless code in probe_kernel_read Mikulas Patocka
2013-11-11 21:33 ` Helge Deller

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.