lkml.org 
[lkml]   [1998]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: error in msync(2) or am I missing something?
Tigran Aivazian wrote:
> In the msync(2) (source mm/filemap.c/sys_msync()) function there is a piece of
> code:
>
> len = (len + ~PAGE_MASK) & PAGE_MASK;
> end = start + len;
> if (end < start)
> goto out;
> if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
> goto out;
> error = 0;
> if (end == start)
> goto out;
>
> Now, len is size_t (unsigned int) so it can hardly ever become negative. So,
> can't one simply rewrite the code as:
>
> if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
> goto out;
> error = 0;
> if (!len)
> goto out;

The test for end < start is meant to catch wrap-around.

Regards,
Bill

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/faq.html

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.245 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site