Author: pfg
Date: Tue Apr 26 01:17:05 2016
New Revision: 298600
URL: https://svnweb.freebsd.org/changeset/base/298600

Log:
  libc: make more use of the howmany() macro when available.
  
  We have a howmany() macro in the <sys/param.h> header that is
  convenient to re-use as it makes things easier to read.

Modified:
  head/lib/libc/db/btree/bt_open.c
  head/lib/libc/db/hash/hash.c

Modified: head/lib/libc/db/btree/bt_open.c
==============================================================================
--- head/lib/libc/db/btree/bt_open.c    Tue Apr 26 00:29:00 2016        
(r298599)
+++ head/lib/libc/db/btree/bt_open.c    Tue Apr 26 01:17:05 2016        
(r298600)
@@ -277,7 +277,7 @@ __bt_open(const char *fname, int flags, 
                b.cachesize = b.psize * MINCACHE;
 
        /* Calculate number of pages to cache. */
-       ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize;
+       ncache = howmany(b.cachesize, t->bt_psize);
 
        /*
         * The btree data structure requires that at least two keys can fit on

Modified: head/lib/libc/db/hash/hash.c
==============================================================================
--- head/lib/libc/db/hash/hash.c        Tue Apr 26 00:29:00 2016        
(r298599)
+++ head/lib/libc/db/hash/hash.c        Tue Apr 26 01:17:05 2016        
(r298600)
@@ -160,8 +160,7 @@ __hash_open(const char *file, int flags,
                 * maximum bucket number, so the number of buckets is
                 * max_bucket + 1.
                 */
-               nsegs = (hashp->MAX_BUCKET + 1 + hashp->SGSIZE - 1) /
-                        hashp->SGSIZE;
+               nsegs = howmany(hashp->MAX_BUCKET + 1, hashp->SGSIZE);
                if (alloc_segs(hashp, nsegs))
                        /*
                         * If alloc_segs fails, table will have been destroyed
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to