From nobody Mon Jan 23 15:44:40 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 4P0vYN3BQXz2v51t; Mon, 23 Jan 2023 15:44:40 +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 4P0vYN2gm3z3rb3; Mon, 23 Jan 2023 15:44:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674488680; 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=JfOuruaO69CKUMr4jsGai3+e1toKeaPoQd422aSwhBc=; b=k6PblVThJPqUKDKZyUPJe//fizq0Qr860DKK21YQrWC/FIXa1CcB4VOzI5zzZGH8KCIJQl W1GMDncSjXVsO5JZ4/D0aAO0s06IzntyJSn2bGp59KHCLrO99McmlSgkO+X9U36XvQkhoj j0mN0a7WNYFGBpzZB2vHhM8tbTBP6qPSnYnVtjUft/a5Tgp2AbXNPMhpwCyGtCv6ULdQws J87DV7c8NYRiBedccCPJE8i/O8bQcQVOLRACQ+zG8UO0w3XQluOeOad0Dh5of9XhSjR1mn +6/hQGW30okh93+tK/sGU8an9GfK7nnCLaZYoMsjexm+JppVRUC544UTV+yBPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674488680; 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=JfOuruaO69CKUMr4jsGai3+e1toKeaPoQd422aSwhBc=; b=f+4xpiFzcs6RhAuE1+2l5mVkCIOa2fWmZk2zgdlKtSW/XzguIiVmczuMaMShNYAZkTzgqI yngGj0JzwV7J5/bARVz9gPqlHOWmuKv47UBcMD63D53ckdgj2Sj6tnQUmWub/1SCy3vt4o aM94Ze31ngX5N3JkNFq2VNOLwdw5mp62+zFTcHIn2qKaKz1KTgvPj9PUXPz1LaFe8la4xn sJmnvuGSbeDtl+DjPbD0gQwekyUeEfYefjBdWLc5ppGwUR5h1kqD9fU+NhGrMucXwV0J+t 54BlDL6mBcaC3+Nef0wfbTlcE7GWUSm/l18QenD4MI4VWdqq1wRZrQ8EvI9Ikw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674488680; a=rsa-sha256; cv=none; b=hcC0Yuf9BTveZlKupJLOmfLM8X1Q1R1W3Frt88Usk/NVzGWda70as+dbRYVzBh39vxpX37 NfNobGYp66x29pwkZ95B8mqdf66YN1n6gkkSQi/w5AWmsnUFIlXZ4mLWy1wM0MJJSuYm1K 3PwyF2aNP7GgA0RH7LIBns8dqZXPlZVfCwQuJX3WDHjCWyH6LIjc3RxXrRVrX9xSWwFC4G p6r7HNiyc6uMnDH5SSTjntPg2WAkMt7+ygKBVYtjmNdyx2pSL6LDoNxwZdMoeRFyC0j63z qQHQr8r6mRTHBwXlzj7V2y/5KFePz7umcZHbn81rvsaM2ycOjDuWRx3hjS+UQA== 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 4P0vYN1XmpzZ5X; Mon, 23 Jan 2023 15:44:40 +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 30NFiek4057827; Mon, 23 Jan 2023 15:44:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30NFie1F057826; Mon, 23 Jan 2023 15:44:40 GMT (envelope-from git) Date: Mon, 23 Jan 2023 15:44:40 GMT Message-Id: <202301231544.30NFie1F057826@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gleb Smirnoff Subject: git: 82ed3fb02543 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 82ed3fb02543af31840fdb2b0c26c77f3ae6cd5e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=82ed3fb02543af31840fdb2b0c26c77f3ae6cd5e commit 82ed3fb02543af31840fdb2b0c26c77f3ae6cd5e Author: Gleb Smirnoff AuthorDate: 2023-01-09 16:40:20 +0000 Commit: Gleb Smirnoff CommitDate: 2023-01-23 15:43:46 +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 (cherry picked from commit dd2b23006caa2323a12749dfc0d831a26a79bc5b) --- 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);