From nobody Wed Jun 11 23:16:41 2025 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 4bHhPQ0wWVz5yddP; Wed, 11 Jun 2025 23:16:42 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bHhPP5NJ1z3LBn; Wed, 11 Jun 2025 23:16:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1749683801; 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=A0QECKJ2M0rRQj3e1xY2p7n8jVGfzAAuV/wFu5ZAcQw=; b=a4+uIM206cZxqOP81oKhQ3QSjjQZ6RDbFV8IEKBcq4lawQt+PGkvPFYnXpK+hDChPf6URg 7h23NrcqbsSZLoQFpH019eYFElZXOdV6rmXwzZKCarRCDZ/WvIBg4g7D2iZB8feKRVSxjd DiOq2ECCXVN/4SK226EYzuHt5FvhmeqFQLiXqAXR+kSulydJmnAoic8+upVJK1MGOs9iuK a90F8SCA8481FGqd16pPsDMJxzh/E59U7HnR2lHvZiF5CXS9vb1Ylcqf2VgS40nwiv+2uz qMoRAAbRIhWU3Zh7pAxg65ockvV5fxTVi23L+7zBEcEy6APrQJuLtOILo0Ky9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1749683801; 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=A0QECKJ2M0rRQj3e1xY2p7n8jVGfzAAuV/wFu5ZAcQw=; b=xW3FYpIOT302K94AuU/gM0D+WGNzLbu6IAc0zh2CK0I5sdxIimk68wxVFd3HHTkMK9iimk 3Zgx10sizidu1aLlS6PunJICITDSpIld9Y8tRzEGhv75YMk8R6nw/Jrffphg8QLCkrIA4K JBNDPWDCbHHpvvkYnPbeUKLS/UPI5ji8WB3aA3osWy1IkN+99xOucJsotms0s0dzyiiHRw XFioz1is34VD37Bqq9nAD6EqXhelP7RdcntSiwUX60TrJcO0IOh4/VcRQZT1LKLzi6FZeN HVCZvM4hHCax83UmuIuRohuQKrRS9oZweiWhw+etRtoRo9rY/4Ph0xB6j9flIg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1749683801; a=rsa-sha256; cv=none; b=vWbFVSR5n2xN7uI6umEjxl+DZUwN0QLonOgVxbHy9dmYxZyPdFNBnd7QQ81LwxOpCguAvx 25jhBD9MkL4ZudSOtcOG7izpE6Vli5oWrCuoB800W1GLyRqiIlrdANDnDpwVYXd470SYRR sVOkSBhf3dHd8AnTdq3vA2am+Cu80eCppSoIuBmThmXxe1QOItEuRjLa0+1+0xbX/16AA7 DFV+P21aCpLcJAFL9NLZtE01q8+kbFgvGosCr4285xsjTwG3xx4hcDni6DGcuQ7e+sNsvB UKIkYTFd6EroOMBqIT+E27seAV/i+cxiuI8DZhmffbpDTLrzh6ciIT09joGlzg== 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 4bHhPP4t5HznHZ; Wed, 11 Jun 2025 23:16:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 55BNGfXn046250; Wed, 11 Jun 2025 23:16:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55BNGfcP046247; Wed, 11 Jun 2025 23:16:41 GMT (envelope-from git) Date: Wed, 11 Jun 2025 23:16:41 GMT Message-Id: <202506112316.55BNGfcP046247@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: b826e88d38c1 - main - fstat: Use POSIX str2sig(3) 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: b826e88d38c163528aa1b091294a6f4169f0309e Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b826e88d38c163528aa1b091294a6f4169f0309e commit b826e88d38c163528aa1b091294a6f4169f0309e Author: Ricardo Branco AuthorDate: 2025-05-10 21:43:47 +0000 Commit: Warner Losh CommitDate: 2025-06-11 23:16:22 +0000 fstat: Use POSIX str2sig(3) Reviewed by: imp, kib, des, jilles Pull Request: https://github.com/freebsd/freebsd-src/pull/1696 --- usr.bin/fstat/fuser.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/usr.bin/fstat/fuser.c b/usr.bin/fstat/fuser.c index 2e2befde6392..c38a520d4ce3 100644 --- a/usr.bin/fstat/fuser.c +++ b/usr.bin/fstat/fuser.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -108,7 +107,6 @@ struct reqfile { static int flags = 0; /* Option flags. */ static void printflags(struct consumer *consumer); -static int str2sig(const char *str); static void usage(void) __dead2; static int addfile(const char *path, struct reqfile *reqfile); static void dofiles(struct procstat *procstat, struct kinfo_proc *kp, @@ -164,7 +162,7 @@ do_fuser(int argc, char *argv[]) struct kinfo_proc *procs; struct procstat *procstat; struct reqfile *reqfiles; - char *ep, *nlistf, *memf; + char *nlistf, *memf; int ch, sig; unsigned int i, cnt, nfiles; @@ -199,17 +197,8 @@ do_fuser(int argc, char *argv[]) flags |= KFLAG; break; case 's': - if (isdigit(*optarg)) { - sig = strtol(optarg, &ep, 10); - if (*ep != '\0' || sig < 0 || sig >= sys_nsig) - errx(EX_USAGE, "illegal signal number" ": %s", - optarg); - } else { - sig = str2sig(optarg); - if (sig < 0) - errx(EX_USAGE, "illegal signal name: " - "%s", optarg); - } + if (str2sig(optarg, &sig) != 0) + errx(EX_USAGE, "invalid signal: %s", optarg); break; case 'h': /* PASSTHROUGH */ @@ -348,20 +337,3 @@ dofiles(struct procstat *procstat, struct kinfo_proc *kp, } procstat_freefiles(procstat, head); } - -/* - * Returns signal number for it's string representation. - */ -static int -str2sig(const char *str) -{ - int i; - - if (!strncasecmp(str, "SIG", 3)) - str += 3; - for (i = 1; i < sys_nsig; i++) { - if (!strcasecmp(sys_signame[i], str)) - return (i); - } - return (-1); -}