lkml.org 
[lkml]   [1998]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjecterror in msync(2) or am I missing something?
Hello guys,

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;
or even better:

if (!len)
goto out;
if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
goto out;
because one expects EINVAL when len == 0 anyway.

Since Linux's code is probably right (because), I assume that I must be wrong.
Hence the question - what am I missing there?

Regards,
------ -------- --------- -------- -- - -- ---- --
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | Email: tigran@sco.com

-
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    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site