From nobody Mon Jan 09 16:43:48 2023 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 4NrKX51XbJz2p0w7; Mon, 9 Jan 2023 16:43:49 +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 4NrKX510RRz45sG; Mon, 9 Jan 2023 16:43:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673282629; 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=6t0WiDagPCxfNrNF8jwGVksEajxYin8Ly/ZIu04WQtY=; b=H82+r5W5Nph5Tu3kP7ylv6cUJ2+dANY+XBOzvWaCPiMr/BPo5g44nd2hRUpRcn7zktBcmt F3OWT8l3aimA6TydQxjDRjvxYQadUwKMKIzWYKhZqI/Jq0hpJfOwKMS+0+JPT0hHK0LGsD xG6NaMhV8p+sW6ODsDUjmsWQaMapzoQbIpKu8xYsG3/JPkB3m4yzuhNxWdZGPEO8UijnHa Bz61P5Rf490NhkLErB5QNiq+ArsWBPq/0tTTQGYF25X6nFmAn1D+xjINrYQKLJsA4q8sLu vPM/zF+J+HKO/4Fs5U6GrAKB865kOmwCOhD6PXuW4obj34ciXDfziGaHRDc0qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673282629; 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=6t0WiDagPCxfNrNF8jwGVksEajxYin8Ly/ZIu04WQtY=; b=x/5uugWn9olF9yYli7rrNb09khMc+fEKbyH09r2+1J41aeXAQFs49z0uItUG/MGj0+d2lu u4aRIoyV98rNp54K9cfJ8Vvzx85Ji8ejElE/ge3MoiLivCxj9DxGW8K8CcJUwTSxrNSKLR Y4e1pm76ERnWEBs+wWWXiKZa+qLGA5BFDiq5eGVa4sQjnvau3DOwPloT6eBLjYf+o3MFxH UPFbWo+LKT1luTWFtJrMtUBYoLe9jKb73T/BlvVxqWLLQ1Fvs3wCRYjqrTa3IlwP5Mwm5M HZjOeEaShZGJ7GQjPOlVcFlyoVlxlFCPtE3QECViyQuk1/zjuJxAdJ4+ZXBQfw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673282629; a=rsa-sha256; cv=none; b=O4IRvsocnhzwH608mVE/OOY2nUt7cBxMsRIMW9rgrL4Ii1Ffzi5o088mcI4n5XTe0gscV7 mpvAR26EXz+Hj+mPcI8TyUf67hVQJeywPz2HvBXItUtnszKCzdikvTQeCg6lDkx5aLyQYl M703hlm90zfMm2wYjwYC/Ihvsn2xjvih9r3+/fT2kW/XkUYaPe2dzgqnzmJOxRQt/XiErJ LG8g63EYDIpW88g/ayx5YrJpL10a+OdawqjVgoSt14hcoCpimYrTtUHZVMhTPJouQou9cr 7nlOJJARd80meLceBev769VO/u35Wxw8Og1ZSpA1VsvDMhqMjcRjUAU2Ie5oLg== 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 4NrKX503MgzbRG; Mon, 9 Jan 2023 16:43:49 +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 309GhmNp079549; Mon, 9 Jan 2023 16:43:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 309GhmBt079548; Mon, 9 Jan 2023 16:43:48 GMT (envelope-from git) Date: Mon, 9 Jan 2023 16:43:48 GMT Message-Id: <202301091643.309GhmBt079548@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: dd2b23006caa - main - fuser: fix loop over kinfo_proc array 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: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dd2b23006caa2323a12749dfc0d831a26a79bc5b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=dd2b23006caa2323a12749dfc0d831a26a79bc5b commit dd2b23006caa2323a12749dfc0d831a26a79bc5b Author: Gleb Smirnoff AuthorDate: 2023-01-09 16:40:20 +0000 Commit: Gleb Smirnoff CommitDate: 2023-01-09 16:40:20 +0000 fuser: fix loop over kinfo_proc array The previous code would skip as many entries at the end of the array as there were zombies in the list. While here fix type of cnt. Submitted by: Ali Abdallah PR: 232702 MFC After: 2 weeks --- usr.bin/fstat/fuser.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/usr.bin/fstat/fuser.c b/usr.bin/fstat/fuser.c index ad4aebf4a2cb..2d9aa72875f4 100644 --- a/usr.bin/fstat/fuser.c +++ b/usr.bin/fstat/fuser.c @@ -163,12 +163,12 @@ int do_fuser(int argc, char *argv[]) { struct consumer *consumer; - struct kinfo_proc *p, *procs; + struct kinfo_proc *procs; struct procstat *procstat; struct reqfile *reqfiles; char *ep, *nlistf, *memf; - int ch, cnt, sig; - unsigned int i, nfiles; + int ch, sig; + unsigned int i, cnt, nfiles; sig = SIGKILL; /* Default to kill. */ nlistf = NULL; @@ -253,10 +253,9 @@ do_fuser(int argc, char *argv[]) /* * Walk through process table and look for matching files. */ - p = procs; - while(cnt--) - if (p->ki_stat != SZOMB) - dofiles(procstat, p++, reqfiles, nfiles); + for (i = 0; i < cnt; i++) + if (procs[i].ki_stat != SZOMB) + dofiles(procstat, &procs[i], reqfiles, nfiles); for (i = 0; i < nfiles; i++) { fprintf(stderr, "%s:", reqfiles[i].name);