From nobody Wed Dec 04 18:35:18 2024 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 4Y3R5y4DD7z5g1Q6; Wed, 04 Dec 2024 18:35:18 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y3R5y2GqTz4vMs; Wed, 4 Dec 2024 18:35:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733337318; 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=c2oOHNoEml6FpqUigbeFzEAb/oaWHFJx1Iprjr35mUE=; b=GilmsELCEnNxtL3Mh9oMPMrE4pk5vLBbX1YxmzveivJayOMBI3iaRFKnOxW8EXGzJhI5SP d8qqUvt8Y6wkjKwKma7RLfrnbu6pmnwn+JnfP0p5l6ruqs7MBbBJjGd9oGE//AbaCfFbm3 XdzYlHFHInypa6lpBRxux43xuHAa3my0JGag5EnY5p7YfvDEMmtFABhWv0c0qG/jIP4f5g 8e7yNNlkUeEVPf1ATlSlAkAWiqlZvzoVxIQNbna/my0OMW/B1EOanQsujS9yhw7QjcqKki ce2+JgFBNZ/oq+qgQ3wfgh8wcnCsJIQcr2CFkJFwHFzKVZHkthdttQNKOugD2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733337318; 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=c2oOHNoEml6FpqUigbeFzEAb/oaWHFJx1Iprjr35mUE=; b=k2TYU0JCcbeMFS/qGJVrSncboPj9bAYQr2DeuXWSn2ZTUsMwXoErELb+93P5koeONfrY9G 2mWQkOXnQuwBxoD+H2xHjU2oRgHGiX+V6zw8nhcHYDWMlJ5D853XQ0MIBw1F2A2eupAXfd bUMINEItif4OUiiCa+9Fr137MSXfv7kwJLMs1yBYjfkrBf7dntmCZbVE34qUaFhBnmxh+g GkXkR55KKihnpyoZnyTy6G/CqgZWH4/c00PhYP5jMRJ4plo8BicEMyaU53AeW1HF2FszlG o7JU4Zb8Bc7k3bBVmQ2BG35xWZJTbZwN3qe8f3InHINIYxcAtzkAwsi4L+Zi9g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733337318; a=rsa-sha256; cv=none; b=aWi3GnA2lWKD8EVWWLxiJWH26tMVeObOB+DBNQ9L6wg2K0TMHKsNNwaqUrdw59hCGbABEM AVhSWw9p7ES8pvuvswAF7LsqCxMI4/VfPrDeCv9Nl/Bjx0d0SZaUNUl5JpApuoSYeSUlAf Rj5ImKfgA4M63aLrSFEzNQ1bEl+FFCTQcRU2u0dSXo3kV/42gRmiCP3nLSkJMDlq3a0ShR 3E5iYa8g9VhoiLNjKV4JNt8b2Deng/pd/s2YBigO4lUEAdUlm6YwzuPQIJt/hD6nMygXly O+P0drrJV7n6WOr2kgHNhOQJFr5LagB+HWnP2i+RIF68X1xPL7JpiUyJPOAMFw== 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 4Y3R5y1v1RzJqv; Wed, 4 Dec 2024 18:35:18 +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 4B4IZInq078070; Wed, 4 Dec 2024 18:35:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B4IZID3078067; Wed, 4 Dec 2024 18:35:18 GMT (envelope-from git) Date: Wed, 4 Dec 2024 18:35:18 GMT Message-Id: <202412041835.4B4IZID3078067@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: fbd3448614fb - main - sockstat: Ensure that there is always a space between columns 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fbd3448614fbd7bd92e7d34c3bfd2592a07391e3 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fbd3448614fbd7bd92e7d34c3bfd2592a07391e3 commit fbd3448614fbd7bd92e7d34c3bfd2592a07391e3 Author: Mark Johnston AuthorDate: 2024-12-04 01:12:39 +0000 Commit: Mark Johnston CommitDate: 2024-12-04 16:22:50 +0000 sockstat: Ensure that there is always a space between columns PR: 282978 Reviewed by: asomers MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47840 --- usr.bin/sockstat/sockstat.c | 56 ++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index b18c56ca6f88..3347978c8b47 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -1129,14 +1129,12 @@ displaysock(struct sock *s, int pos) switch (s->family) { case AF_INET: case AF_INET6: - if (laddr != NULL) { + if (laddr != NULL) pos += printaddr(&laddr->address); - if (s->family == AF_INET6 && pos >= 58) - pos += xprintf(" "); - } offset += opt_w ? 46 : 22; - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); if (faddr != NULL) pos += printaddr(&faddr->address); offset += opt_w ? 46 : 22; @@ -1208,8 +1206,9 @@ displaysock(struct sock *s, int pos) abort(); } if (opt_f) { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); pos += xprintf("%d", s->fibnum); offset += 7; } @@ -1220,12 +1219,14 @@ displaysock(struct sock *s, int pos) sp = RB_FIND(socks_t, &socks, &(struct sock) { .socket = s->splice_socket }); if (sp != NULL) { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); pos += printaddr(&sp->laddr->address); } else { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); pos += xprintf("??"); offset += opt_w ? 46 : 22; } @@ -1235,8 +1236,9 @@ displaysock(struct sock *s, int pos) if (opt_i) { if (s->proto == IPPROTO_TCP || s->proto == IPPROTO_UDP) { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); pos += xprintf("%" PRIu64, s->inp_gencnt); } offset += 9; @@ -1250,8 +1252,9 @@ displaysock(struct sock *s, int pos) (s->proto == IPPROTO_TCP && s->state != TCPS_CLOSED && s->state != TCPS_LISTEN))) { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); pos += xprintf("%u", ntohs(faddr->encaps_port)); } @@ -1263,8 +1266,9 @@ displaysock(struct sock *s, int pos) s->state != SCTP_CLOSED && s->state != SCTP_BOUND && s->state != SCTP_LISTEN) { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); pos += xprintf("%s", sctp_path_state(faddr->state)); } @@ -1274,8 +1278,9 @@ displaysock(struct sock *s, int pos) if (opt_s) { if (s->proto == IPPROTO_SCTP || s->proto == IPPROTO_TCP) { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); switch (s->proto) { case IPPROTO_SCTP: pos += xprintf("%s", @@ -1295,8 +1300,9 @@ displaysock(struct sock *s, int pos) } if (opt_S) { if (s->proto == IPPROTO_TCP) { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); pos += xprintf("%.*s", TCP_FUNCTION_NAME_LEN_MAX, s->stack); @@ -1305,8 +1311,9 @@ displaysock(struct sock *s, int pos) } if (opt_C) { if (s->proto == IPPROTO_TCP) { - while (pos < offset) + do pos += xprintf(" "); + while (pos < offset); xprintf("%.*s", TCP_CA_NAME_MAX, s->cc); } offset += TCP_CA_NAME_MAX + 1; @@ -1371,18 +1378,21 @@ display(void) pos = 0; if (opt_n || (pwd = cap_getpwuid(cappwd, xf->xf_uid)) == NULL) - pos += xprintf("%lu ", (u_long)xf->xf_uid); + pos += xprintf("%lu", (u_long)xf->xf_uid); else - pos += xprintf("%s ", pwd->pw_name); - while (pos < 9) + pos += xprintf("%s", pwd->pw_name); + do pos += xprintf(" "); + while (pos < 9); pos += xprintf("%.10s", getprocname(xf->xf_pid)); - while (pos < 20) + do pos += xprintf(" "); - pos += xprintf("%5lu ", (u_long)xf->xf_pid); - while (pos < 26) + while (pos < 20); + pos += xprintf("%5lu", (u_long)xf->xf_pid); + do pos += xprintf(" "); - pos += xprintf("%-3d ", xf->xf_fd); + while (pos < 26); + pos += xprintf("%-3d", xf->xf_fd); displaysock(s, pos); } } @@ -1391,7 +1401,7 @@ display(void) SLIST_FOREACH(s, &nosocks, socket_list) { if (!check_ports(s)) continue; - pos = xprintf("%-8s %-10s %-5s %-2s ", + pos = xprintf("%-8s %-10s %-5s %-3s", "?", "?", "?", "?"); displaysock(s, pos); } @@ -1400,7 +1410,7 @@ display(void) continue; if (!check_ports(s)) continue; - pos = xprintf("%-8s %-10s %-5s %-2s ", + pos = xprintf("%-8s %-10s %-5s %-3s", "?", "?", "?", "?"); displaysock(s, pos); }