error in msync(2) or am I missing something?

Tigran Aivazian (tigran@sco.COM)
Fri, 4 Sep 1998 15:01:43 +0100 (BST)


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