From nobody Sat Feb 03 01:36:21 2024 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 4TRZx14q0Jz58kRv; Sat, 3 Feb 2024 01:36:21 +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 4TRZx13F4Vz4QPT; Sat, 3 Feb 2024 01:36:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706924181; 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=bN/jKR/Anssirja53WTye2NxTgd8l5regvOeltHDe2c=; b=jihqkkMTjSGYTmU0v709cJzfQtTYzqBo/z9Io0Se5XHVdfek5si2dVJ15K0nMHW0H9SgHP ltNcvaN7J/aF6A7Kpn6B3/c28zznVS8F0vcJlMdyzRywN/ApZbxjoIAsx55A1aYL7Mfvmy I54IC2ybfIAKP+jLKFxMSzN6URW7HkKd/sGrR/kFBzD7GeHTQTS5slHWAn56O0uqia1HpH XDG5BA0sc4wnLPvdF1RL3SLNtpshviD2IIujXhUJJCQgleKaV9UcIKgIj8QMouCAMSkF+m AanTKHFhN9LpT3SH+yhfTpyD26bRUlQDrumkJdsqQV70nfrG45fJksbWwG4IRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706924181; 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=bN/jKR/Anssirja53WTye2NxTgd8l5regvOeltHDe2c=; b=A7ayJsu9XyZ6lDMqhom+eayu1W6OtZKLnkjLSViz/hc0ZtZiR+R5wlr19mgcpIjMJ9Nrfa CrQa6mAX+FKij6s5uC8eXbwx0F0UOSIq5wAYsz8eX+uhEa/o5cbX5hY1Nd9s8MT5JFeWKM exeST/bEe65+h9rh8m9Y2EksZdpUcndICsJDaukSGnJw63dY+AIUAdabar5Pq/5aIUcYw/ 5EAWmjuCnXf6vODdREUma5vz/qy4dRgEwppvHuYn1Oep8aCilcwLzE1hhCoHA8Z0bpYq8e LUT/9sBqLXYt1HY2EBGHND+YcE7XJAg6tY8kkIDfWdeH2ocBcli/WiCjeYs1bg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706924181; a=rsa-sha256; cv=none; b=o1V7j9qk6QRBxnDy95ZfKcvxgp+w/QDQ7i0nJx2hfCUooLv9LoMcNL+nr8KGialssjGxWo l0JnloZkjduVJSdUMj4zb2/4qBwxoFdSfnPGpfzSmemaIjF+jjlrc1jB/KWGFj0IztBMUi bDXSDJsEhJ2Z3SYrE3wGtOkmGniIB+aCONDO3VXD5zDQckzsHuysVP7RdPHcoU0JrUm/2q s9Xl/L8h+MIwj1J7S6LQ8AzYCn5916TnwQGiR/k1mbeVA2e+MnxTuSU73h70u5sE6b5oTX /FC0Bjapf7W6CjvSOlPofzdMyjPfWo7/2z+z/U8DhDB0ENy/iv32nmRYDAWP/Q== 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 4TRZx120Lfztyv; Sat, 3 Feb 2024 01:36:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4131aLbi010727; Sat, 3 Feb 2024 01:36:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4131aL3U010724; Sat, 3 Feb 2024 01:36:21 GMT (envelope-from git) Date: Sat, 3 Feb 2024 01:36:21 GMT Message-Id: <202402030136.4131aL3U010724@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 8e05c2373efd - main - wc: Do not use st_size if it equals zero 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e05c2373efd43632b1ec410528552fa01b40a3f Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=8e05c2373efd43632b1ec410528552fa01b40a3f commit 8e05c2373efd43632b1ec410528552fa01b40a3f Author: Ricardo Branco AuthorDate: 2024-02-03 00:05:05 +0000 Commit: Warner Losh CommitDate: 2024-02-03 01:34:59 +0000 wc: Do not use st_size if it equals zero Pseudo-filesystems often cannot compute the size of the file correctly and report 0 for the size. Ignore the size when it's zero and fallback to the size unknown code. PR: 276093 Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/985 --- usr.bin/wc/wc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c index 7cb72212d1cb..76b65e5f870d 100644 --- a/usr.bin/wc/wc.c +++ b/usr.bin/wc/wc.c @@ -230,7 +230,8 @@ cnt(const char *file) (void)close(fd); return (1); } - if (S_ISREG(sb.st_mode)) { + /* pseudo-filesystems advertize a zero size */ + if (S_ISREG(sb.st_mode) && sb.st_size > 0) { reset_siginfo(); charct = sb.st_size; show_cnt(file, linect, wordct, charct, llct);