From nobody Wed Jan 26 16:14:02 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 156FE197C782; Wed, 26 Jan 2022 16:14:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JkTLM02v9z3RLl; Wed, 26 Jan 2022 16:14:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643213643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oku6XnPr9Kc9BCRbtkKz2/ehNv3O+uttI3HLlg8XHjE=; b=HKjw0wMmkj+xoQt/fiK67FPjfsYepYQue2DYOZ3wX2JjFfc4fUxNm+lc4FmlcSMDAQyiGM 2RVlkr87Jo6AQyQbN7Bek36pYcA12SeUl1RpsPrt3/2FQQf5Dpe8Onrn237vFSJ0paVXon wLfd0SYttCBXJ6jf8tZYyDpUuhqkAh5u8NiTwn3MOcq+dzcuvG+KL0oQ82Q1aKk5Gp0fui 7QdSx3oICdVMSXC9RiyFSmAXQWZoK3W7A4xn8hBJFApQuAznNojii5JO0wwx47npkGnCcY s9J089XFznA6295DL7zMm4PZrU5XDNxPd4lJK/Ryfdd6IoePdQo/DTMSbIiUQg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D58BE202C0; Wed, 26 Jan 2022 16:14:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20QGE22k057501; Wed, 26 Jan 2022 16:14:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20QGE2ra057500; Wed, 26 Jan 2022 16:14:02 GMT (envelope-from git) Date: Wed, 26 Jan 2022 16:14:02 GMT Message-Id: <202201261614.20QGE2ra057500@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wolfram Schneider Subject: git: e48156828f07 - main - switch to 64 bit integers for counting bigrams List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wosch X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e48156828f07fa172adb05776356d2b043544a05 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643213643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oku6XnPr9Kc9BCRbtkKz2/ehNv3O+uttI3HLlg8XHjE=; b=o1OMHaqV3ENuUdqDaHuAttLzIWFgeFmVY+CsXOsbdmxwYN8KZhKNorWQUHKlDSuIAXuBy9 EG+tVL3oG/EuPXrdU9eV06l/xW3ljLhgMFRifZ1S2r8JkQHKtvEsodLDEs3svQkwNg1x/V PPYqdK7vwU48PFw3rA1GehjH5rsgOfHAkdLeznNHcVN2OZU6L54caTtd7Bwr9gK74J6c2e CccduN/h/NO6+gk/FqhtSXlnGGbDGfnBDNY3kKwH1wdgbXKhTgEInqS8qPkxOFg0oSxPPi ONK3eZ1kExa7JmbfhNavjUrUTxgC2qM+hdFvfFWit+ZGiVvJjxGdTM3XsDWNeg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643213643; a=rsa-sha256; cv=none; b=t3DOSzmTvFh+0kh+BUoNVQG9tV4djjhTjsiem2LG5YmypVo6+5LNewstXVJd9aLjb2xMCx x/ykbb6ut3lcGTVanYsrCkl9vmwocxNFrmzilwIYNvbmvRvqKcQm9L84PXywDEJYGyxOvr imxYj+Oa3dFmbmFy+4WLGANwsiWwXkumZBs3VaV81tD+bsdWcrBL2FGIbNXm2MTJ4TZaAa g9kb9WlSFb+FqdbDNGbh5Vg8EahUskM7SIEAqaSuQ4C4t6U27h/gW/+st3PGfh7RzwmTUO NAK47mUgSToTTwcmErb38ZdzRjekPcTlElzMjqpPeektkqAF8bZbysbHZwJMYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wosch: URL: https://cgit.FreeBSD.org/src/commit/?id=e48156828f07fa172adb05776356d2b043544a05 commit e48156828f07fa172adb05776356d2b043544a05 Author: Wolfram Schneider AuthorDate: 2022-01-26 16:11:51 +0000 Commit: Wolfram Schneider CommitDate: 2022-01-26 16:11:51 +0000 switch to 64 bit integers for counting bigrams This fixes an integer overflow for very large partitions around 35 billion filenames (>2PB). However, in an artificially worst case it may occurs by only 17 mio filenames on a partition. --- usr.bin/locate/bigram/locate.bigram.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/locate/bigram/locate.bigram.c b/usr.bin/locate/bigram/locate.bigram.c index 0868a5f89070..d15f8ce170e8 100644 --- a/usr.bin/locate/bigram/locate.bigram.c +++ b/usr.bin/locate/bigram/locate.bigram.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 1995 Wolfram Schneider . Berlin. + * Copyright (c) 1995-2022 Wolfram Schneider * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * @@ -64,7 +64,7 @@ static char sccsid[] = "@(#)locate.bigram.c 8.1 (Berkeley) 6/6/93"; u_char buf1[MAXPATHLEN] = " "; u_char buf2[MAXPATHLEN]; -u_int bigram[UCHAR_MAX + 1][UCHAR_MAX + 1]; +unsigned long bigram[UCHAR_MAX + 1][UCHAR_MAX + 1]; int main(void) @@ -109,7 +109,7 @@ main(void) for (i = ASCII_MIN; i <= ASCII_MAX; i++) for (j = ASCII_MIN; j <= ASCII_MAX; j++) if (bigram[i][j] != 0) - (void)printf("%4u %c%c\n", bigram[i][j], i, j); + printf("%lu %c%c\n", bigram[i][j], i, j); exit(0); }