From owner-svn-src-head@freebsd.org Tue Apr 26 01:17:06 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEAAAB1D851; Tue, 26 Apr 2016 01:17:06 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C111E1AE7; Tue, 26 Apr 2016 01:17:06 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3Q1H50S085085; Tue, 26 Apr 2016 01:17:05 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3Q1H5xB085083; Tue, 26 Apr 2016 01:17:05 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201604260117.u3Q1H5xB085083@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 26 Apr 2016 01:17:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298600 - in head/lib/libc/db: btree hash X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2016 01:17:07 -0000 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 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