svn commit: r195693 - in head: lib/libc/sys sys/vm

John Baldwin jhb at freebsd.org
Thu Jul 23 12:45:33 UTC 2009


On Thursday 23 July 2009 6:30:15 am Jaakko Heinonen wrote:
> 
> Hi,
> 
> On 2009-07-14, John Baldwin wrote:
> >   - Change mmap() to fail requests with EINVAL that pass a length of 0.  
This
> >     behavior is mandated by POSIX.
> 
> After this change locate(1) gives an obscure error message for empty
> database files.

Ah, odd.  Perhaps it would be best to just move the original "too small" check 
earlier:

Index: fastfind.c
===================================================================
--- fastfind.c  (revision 195818)
+++ fastfind.c  (working copy)
@@ -154,9 +154,6 @@

        /* init bigram table */
 #ifdef FF_MMAP
-       if (len < (2*NBG))
-               errx(1, "database too small: %s", database);
-
        for (c = 0, p = bigram1, s = bigram2; c < NBG; c++, len-= 2) {
                p[c] = check_bigram_char(*paddr++);
                s[c] = check_bigram_char(*paddr++);
Index: locate.c
===================================================================
--- locate.c    (revision 195818)
+++ locate.c    (working copy)
@@ -291,6 +291,8 @@
            fstat(fd, &sb) == -1)
                err(1, "`%s'", db);
        len = sb.st_size;
+       if (len < (2*NBG))
+               errx(1, "database too small: %s", database);

        if ((p = mmap((caddr_t)0, (size_t)len,
                      PROT_READ, MAP_SHARED,

This should be functionally identical.

-- 
John Baldwin


More information about the svn-src-all mailing list