From nobody Wed Jan 26 16:17:26 2022 X-Original-To: dev-commits-src-all@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 5AEE2197F8AB; Wed, 26 Jan 2022 16:17:26 +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 4JkTQG1qJYz3jkj; Wed, 26 Jan 2022 16:17:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643213846; 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=TTPx1YFdckMGUA8oqJXYW8/kyB9cJsNA73cCYOgfrAw=; b=F8C01Chhb8XqW/Oq0X0o9QBHDDCsUiDjEEBLQDXt7T78X58mlQpDvCchiFjTHp+mDY9T0S vRYxKrnL2GUKyHi2+lltpqQbYl5v+SmrCpp29uv/xOfpqCVG97jtcsf15jxhOKLl+6hjU3 qgg+6licqk2hKEIMkmZwFlkLt50LnnAP8+QNdOxyzHOEiKnnUytqmCREil9mmJnWH1tom6 unAMT9+MVud1E6YNGtC198ptZjU2AVgIDAtD65fXmb3SwHKnuiKlmlpS3UCm+GGm709LNY vZxj//NEA9qnZ4ACdPcsD7v1s+U51T3ACWj2tjni3D3VUK6GGZfyooUdMhmYew== 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 1FEA120691; Wed, 26 Jan 2022 16:17:26 +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 20QGHQ9r057841; Wed, 26 Jan 2022 16:17:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20QGHQgg057840; Wed, 26 Jan 2022 16:17:26 GMT (envelope-from git) Date: Wed, 26 Jan 2022 16:17:26 GMT Message-Id: <202201261617.20QGHQgg057840@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: 0c178a2a645d - main - support more than 2 billion file names for counting (-c) or limits (-l limit) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 0c178a2a645d8b0cd311cc872af1fd184c6e6663 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643213846; 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=TTPx1YFdckMGUA8oqJXYW8/kyB9cJsNA73cCYOgfrAw=; b=uy92cTUzhscSPt+ZvdchMG6Kni1mwmc+9b4D4Bxm0eYODGfyHSH/tcuYSy7Jfs9HvBhkDx pxgt6611xhTO7n6FMBWMR6LCUsV0s4QmTFJN4XgsXEjUO6TxcAy6wqmwbjvWP6aJe1D36D HURJicuY+MMHTvCue/1AdHv590GFS/HlVmL9PH0O328QIIjMad88bl0CdeaG7jCwLGqCx5 3c3pPSz7vFflZ6FaDTveUmyBH/DcrbvIxeIf4yFcZRrnSQCcatlqrrVG31UHmng7FbT1Ks eT6BtKG7C/RFU9qorvAiI3f63Oh8988rqRfWWOJt68cUYvdgAfD2wgnDP758Kg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643213846; a=rsa-sha256; cv=none; b=INxkx4qyE9G9zQymXlelHzS7qcGcKAr80PsSXmJdGRzRhnbKAjSDdri5mRvtc7pRCuhiaL 1g5ROConRfHjhgj6lvYbSlOgQIwg/k702Otxi9nSYUJvmQyyc8KwKzqN44vebeSxdI2Czc 2CWZuwwHPeGCsYI1SlTuj7JqoxFErYJ4pzHKfpnBHTGzYxlAdDLywO3lR+5uiz8mp0knGY uNH3JTZrF0vUTjcOLEe8vx8z9MkAvSqdbxvpk6y27xUjPrEqXMtoNLSIHuhdmsUijobbL/ G3Xf7M1gqZ+52Xga/w/0fsFypcm/gXa7pJVwgIGhdt2HFTEvnpSqVcd98I9RsA== 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=0c178a2a645d8b0cd311cc872af1fd184c6e6663 commit 0c178a2a645d8b0cd311cc872af1fd184c6e6663 Author: Wolfram Schneider AuthorDate: 2022-01-26 16:15:23 +0000 Commit: Wolfram Schneider CommitDate: 2022-01-26 16:15:23 +0000 support more than 2 billion file names for counting (-c) or limits (-l limit) - this fix (harmless) integer overflows for very large partitions (>1PB) - code cleanup --- usr.bin/locate/locate/fastfind.c | 2 +- usr.bin/locate/locate/locate.c | 11 ++++++----- usr.bin/locate/locate/util.c | 11 +---------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c index 7340ce156675..fdbbb1c3db18 100644 --- a/usr.bin/locate/locate/fastfind.c +++ b/usr.bin/locate/locate/fastfind.c @@ -326,7 +326,7 @@ fastfind if (f_limit >= counter) (void)printf("%s%c",path,separator); else - errx(0, "[show only %d lines]", counter - 1); + errx(0, "[show only %ld lines]", counter - 1); } else (void)printf("%s%c",path,separator); } diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c index d339037c2003..40e183f8d45a 100644 --- a/usr.bin/locate/locate/locate.c +++ b/usr.bin/locate/locate/locate.c @@ -102,8 +102,8 @@ int f_icase; /* ignore case */ int f_stdin; /* read database from stdin */ int f_statistic; /* print statistic */ int f_silent; /* suppress output, show only count of matches */ -int f_limit; /* limit number of output lines, 0 == infinite */ -u_int counter; /* counter for matches [-c] */ +long f_limit; /* limit number of output lines, 0 == infinite */ +long counter; /* counter for matches [-c] */ char separator='\n'; /* line separator */ u_char myctype[UCHAR_MAX + 1]; @@ -119,7 +119,6 @@ void search_fopen(char *, char **); unsigned long cputime(void); extern char **colon(char **, char*, char*); -extern void print_matches(u_int); extern int getwm(caddr_t); extern int getwf(FILE *); extern u_char *tolower_word(u_char *); @@ -146,7 +145,9 @@ main(int argc, char **argv) f_statistic = 1; break; case 'l': /* limit number of output lines, 0 == infinite */ - f_limit = atoi(optarg); + f_limit = atol(optarg); + if (f_limit < 0 ) + errx(1, "invalid argument for -l: '%s'", optarg); break; case 'd': /* database */ dbv = colon(dbv, optarg, _PATH_FCODES); @@ -211,7 +212,7 @@ main(int argc, char **argv) } if (f_silent) - print_matches(counter); + printf("%ld\n", counter); exit(0); } diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c index 42710de9490a..ff64b5a952d3 100644 --- a/usr.bin/locate/locate/util.c +++ b/usr.bin/locate/locate/util.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. * @@ -47,7 +47,6 @@ char **colon(char **, char*, char*); char *patprep(char *); -void print_matches(u_int); u_char *tolower_word(u_char *); int getwm(caddr_t); int getwf(FILE *); @@ -131,14 +130,6 @@ colon(char **dbv, char *path, char *dot) return (dbv); } -void -print_matches(counter) - u_int counter; -{ - (void)printf("%d\n", counter); -} - - /* * extract last glob-free subpattern in name for fast pre-match; prepend * '\0' for backwards match; return end of new pattern