From nobody Fri Oct 21 16:39:27 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 4Mv9Cz4n2cz4g7Hg; Fri, 21 Oct 2022 16:39:27 +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 4Mv9Cz4BRHz43K0; Fri, 21 Oct 2022 16:39:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666370367; 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=FbwThKTtP8A1julIQY7ind5Is7QywjwX+7+pSQeen+E=; b=JaGG2R5dgHQY9RsDU//wRkrF49aHrgcbJrN9eaW23dnGIPuqHANWG+qvgbIfQjYeEZH+td d51P2Yv3QS0cIoedtR6JoYGm42bZom/FEIAPyJQ4iy2C2oiGtuEcyztRH4rvL2/yL8gh+3 QLfUN/lbwcN7aebBBzjrHj8d7FaUTgwFFdkUL9LvL63Dmojfak1Q5M882H9JcnDRte6clx wfWV8vSxKBrKjoJrz9H9OOwSMc59cIbKrJMUUksTriOgMIT7ubeTZSTwTcFa+aeUINGSxO MrHOipmkx3dAt93lsop9X62IHpNXcGkcB30XYlnajZ6hnUJDlngvZCMWSdlfDQ== 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 4Mv9Cz3CDLzGvr; Fri, 21 Oct 2022 16:39:27 +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 29LGdR87093681; Fri, 21 Oct 2022 16:39:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29LGdRX9093680; Fri, 21 Oct 2022 16:39:27 GMT (envelope-from git) Date: Fri, 21 Oct 2022 16:39:27 GMT Message-Id: <202210211639.29LGdRX9093680@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: 04f6b9cb1822 - main - w: cosmetic fixes. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 04f6b9cb1822fdd6ab1cbeeafb38a6b354b61ca7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666370367; 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=FbwThKTtP8A1julIQY7ind5Is7QywjwX+7+pSQeen+E=; b=TaKvRpZPvhSFittTfqueLPOyG1g7ci9h5aKLttLk6H38xC5lZ3VMKPWGYv4sdS2aM+cgNe a6A8p5JVMvF5YCfLU8WrI98MBCldtEkFtFEPZ5qqIVfFIGrPMYxU6HzF/02+PHYyv9Hs2y a/ONT1ojv3WGEVQBZCNJ8U1sJJ9X5fA2vmsHs3EFLaKBhiMoIBdai/cpqrRAkTdyxtrOC0 +cgv13rHQ9UtowhQh0nZtXMlK2fV+Ih7ZAAHbwO3JkHAaMn9pyQB/oIqVTCzDVxffyBmo8 4QDob1P1kvd93qpuijwOApGPwQq9+fBSquN7XCAmAhGLeIgpOtdKwtMceCsvnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666370367; a=rsa-sha256; cv=none; b=UQ58mT8PbGUPHFQk8PERvfllGbf2YQpLm86MEm2GFLK3PJwz6gLO9X/4VQUF3p5VBCNR0N eFCf5N6vLSaoazAb4zqg/hG7UL2T2YVSXN7q2FAmS681MD2otZG4pPGPCSQNSdZrDFLfJE kMmJwDn9NiopTeuIHfWwBRYMPcqfW/VnHlukHDmHGs+qSgP8qrcNYS8lQ7YWdbqlosley3 ZE+09WyV8vraZLFePr1a/dxb/JGI1HUgI5i+6xCW+7/gh1Y86KK7OLaJ9fLLBqEHYj2PuL rKEL+q5muDXvo8IwdibETJPjfQtbrB/ZCGIFlXXFj2QFC2kvgbJ8ON9PWor42g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=04f6b9cb1822fdd6ab1cbeeafb38a6b354b61ca7 commit 04f6b9cb1822fdd6ab1cbeeafb38a6b354b61ca7 Author: Dag-Erling Smørgrav AuthorDate: 2022-10-21 16:37:44 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2022-10-21 16:37:44 +0000 w: cosmetic fixes. Sponsored by: Klara, Inc. --- usr.bin/w/pr_time.c | 2 +- usr.bin/w/w.c | 51 +++++++++++++++++++++++++-------------------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/usr.bin/w/pr_time.c b/usr.bin/w/pr_time.c index 13f3180d511b..20b75704c309 100644 --- a/usr.bin/w/pr_time.c +++ b/usr.bin/w/pr_time.c @@ -90,7 +90,7 @@ pr_attime(time_t *started, time_t *now) if (len == width) xo_emit("{:login-time/%-7.7ls/%ls}", buf); else if (width < 7) - xo_emit("{:login-time/%ls}%.*s", buf, 7 - width, " "); + xo_emit("{:login-time/%ls}%.*s", buf, 7 - width, " "); else { xo_emit("{:login-time/%ls}", buf); offset = width - 7; diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 42874242c5ba..4199e64e90f6 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -95,9 +95,9 @@ static struct utmpx *utmp; static struct winsize ws; static kvm_t *kd; static time_t now; /* the current time of day */ -static int ttywidth; /* width of tty */ -static int fromwidth = 0; /* max width of "from" field */ -static int argwidth; /* width of arguments */ +static size_t ttywidth; /* width of tty */ +static size_t fromwidth = 0; /* max width of "from" field */ +static size_t argwidth; /* width of arguments */ static int header = 1; /* true if -h flag: don't print heading */ static int nflag; /* true if -n flag: don't convert addrs */ static int dflag; /* true if -d flag: output debug info */ @@ -140,11 +140,12 @@ main(int argc, char *argv[]) struct kinfo_proc *dkp; struct stat *stp; time_t touched; + size_t width; int ch, i, nentries, nusers, wcmd, longidle, longattime; const char *memf, *nlistf, *p, *save_p; char *x_suffix; - char buf[MAXHOSTNAMELEN], errbuf[_POSIX2_LINE_MAX]; - char fn[MAXHOSTNAMELEN]; + char errbuf[_POSIX2_LINE_MAX]; + char buf[MAXHOSTNAMELEN], fn[MAXHOSTNAMELEN]; char *dot; (void)setlocale(LC_ALL, ""); @@ -188,7 +189,7 @@ main(int argc, char *argv[]) nflag += 1; break; case 'f': case 'l': case 's': case 'u': case 'w': - warnx("[-flsuw] no longer supported"); + warnx("-%c no longer supported", ch); /* FALLTHROUGH */ case '?': default: @@ -310,8 +311,8 @@ main(int argc, char *argv[]) p = buf; } ep->from = strdup(p); - if ((i = strlen(p)) > fromwidth) - fromwidth = i; + if ((width = strlen(p)) > fromwidth) + fromwidth = width; if (save_p != p) ep->save_from = strdup(save_p); } @@ -323,10 +324,9 @@ main(int argc, char *argv[]) #define HEADER_LOGIN_IDLE "LOGIN@ IDLE " #define HEADER_WHAT "WHAT\n" #define WUSED (W_DISPUSERSIZE + W_DISPLINESIZE + fromwidth + \ - sizeof(HEADER_LOGIN_IDLE) + 3) /* header width incl. spaces */ + sizeof(HEADER_LOGIN_IDLE) + 3) /* header width incl. spaces */ - - if ((int) sizeof(HEADER_FROM) > fromwidth) + if (sizeof(HEADER_FROM) > fromwidth) fromwidth = sizeof(HEADER_FROM); fromwidth++; if (fromwidth > W_MAXHOSTSIZE) @@ -339,12 +339,11 @@ main(int argc, char *argv[]) if (wcmd == 0) { xo_close_container("uptime-information"); xo_finish(); - (void)kvm_close(kd); exit(0); } - xo_emit("{T:/%-*.*s} {T:/%-*.*s} {T:/%-*.*s} {T:/%s}", + xo_emit("{T:/%-*.*s} {T:/%-*.*s} {T:/%-*.*s} {T:/%s}", W_DISPUSERSIZE, W_DISPUSERSIZE, HEADER_USER, W_DISPLINESIZE, W_DISPLINESIZE, HEADER_TTY, fromwidth, fromwidth, HEADER_FROM, @@ -430,8 +429,8 @@ main(int argc, char *argv[]) xo_open_instance("user-entry"); if (dflag) { - xo_open_container("process-table"); - xo_open_list("process-entry"); + xo_open_container("process-table"); + xo_open_list("process-entry"); for (dkp = ep->dkp; dkp != NULL; dkp = debugproc(dkp)) { const char *ptr; @@ -445,8 +444,8 @@ main(int argc, char *argv[]) "{:command/%hs}\n", dkp->ki_pid, ptr); xo_close_instance("process-entry"); } - xo_close_list("process-entry"); - xo_close_container("process-table"); + xo_close_list("process-entry"); + xo_close_container("process-table"); } xo_emit("{:user/%-*.*s/%@**@s} {:tty/%-*.*s/%@**@s} ", W_DISPUSERSIZE, W_DISPUSERSIZE, ep->utmp.ut_user, @@ -459,12 +458,12 @@ main(int argc, char *argv[]) if (ep->save_from) xo_attr("address", "%s", ep->save_from); xo_emit("{:from/%-*.*s/%@**@s} ", - fromwidth, fromwidth, ep->from); + (int)fromwidth, (int)fromwidth, ep->from); t = ep->utmp.ut_tv.tv_sec; longattime = pr_attime(&t, &now); longidle = pr_idle(ep->idle); xo_emit("{:command/%.*hs/%@*@hs}\n", - argwidth - longidle - longattime, + (int)argwidth - longidle - longattime, ep->args); xo_close_instance("user-entry"); @@ -510,8 +509,9 @@ pr_header(time_t *nowp, int nusers) mins = uptime / 60; secs = uptime % 60; xo_emit(" up"); - xo_emit("{e:uptime/%lu}", (unsigned long) tp.tv_sec); - xo_emit("{e:days/%d}{e:hours/%d}{e:minutes/%d}{e:seconds/%d}", days, hrs, mins, secs); + xo_emit("{e:uptime/%lu}", (unsigned long)tp.tv_sec); + xo_emit("{e:days/%d}{e:hours/%d}{e:minutes/%d}{e:seconds/%d}", + days, hrs, mins, secs); if (days > 0) sbuf_printf(upbuf, " %d day%s,", @@ -524,7 +524,7 @@ pr_header(time_t *nowp, int nusers) else if (mins > 0) sbuf_printf(upbuf, " %d min%s,", mins, mins > 1 ? "s" : ""); - else + else sbuf_printf(upbuf, " %d sec%s,", secs, secs > 1 ? "s" : ""); if (sbuf_finish(upbuf) != 0) @@ -542,7 +542,7 @@ pr_header(time_t *nowp, int nusers) if (getloadavg(avenrun, nitems(avenrun)) == -1) xo_emit(", no load average information available\n"); else { - static const char *format[] = { + static const char *format[] = { " {:load-average-1/%.2f}", " {:load-average-5/%.2f}", " {:load-average-15/%.2f}", @@ -564,10 +564,9 @@ ttystat(char *line) char ttybuf[MAXPATHLEN]; (void)snprintf(ttybuf, sizeof(ttybuf), "%s%s", _PATH_DEV, line); - if (stat(ttybuf, &sb) == 0 && S_ISCHR(sb.st_mode)) { + if (stat(ttybuf, &sb) == 0 && S_ISCHR(sb.st_mode)) return (&sb); - } else - return (NULL); + return (NULL); } static void