git: c5bdcd1f10a8 - main - sockstat(1): widen the FD printing format

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Thu, 07 Jul 2022 05:20:36 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=c5bdcd1f10a86e8b7754ba37d4a173294b727521

commit c5bdcd1f10a86e8b7754ba37d4a173294b727521
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-07-07 05:19:08 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-07-07 05:19:08 +0000

    sockstat(1): widen the FD printing format
    
    Three digit file descriptors are very common these days.  So let the
    columns not break with them.
    
    Reviewed by:            tuexen
    Differential revision:  https://reviews.freebsd.org/D35725
---
 usr.bin/sockstat/sockstat.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index 7f9286b95f92..143f4f0f7aca 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -1071,7 +1071,7 @@ displaysock(struct sock *s, int pos)
 	struct addr *laddr, *faddr;
 	struct sock *s_tmp;
 
-	while (pos < 29)
+	while (pos < 30)
 		pos += xprintf(" ");
 	pos += xprintf("%s", s->protoname);
 	if (s->vflag & INP_IPV4)
@@ -1084,7 +1084,7 @@ displaysock(struct sock *s, int pos)
 	faddr = s->faddr;
 	first = 1;
 	while (laddr != NULL || faddr != NULL) {
-		offset = 36;
+		offset = 37;
 		while (pos < offset)
 			pos += xprintf(" ");
 		switch (s->family) {
@@ -1233,7 +1233,7 @@ display(void)
 	int n, pos;
 
 	if (opt_q != 1) {
-		printf("%-8s %-10s %-5s %-2s %-6s %-*s %-*s",
+		printf("%-8s %-10s %-5s %-3s %-6s %-*s %-*s",
 		    "USER", "COMMAND", "PID", "FD", "PROTO",
 		    opt_w ? 45 : 21, "LOCAL ADDRESS",
 		    opt_w ? 45 : 21, "FOREIGN ADDRESS");
@@ -1276,7 +1276,7 @@ display(void)
 			pos += xprintf("%lu ", (u_long)xf->xf_pid);
 			while (pos < 26)
 				pos += xprintf(" ");
-			pos += xprintf("%d ", xf->xf_fd);
+			pos += xprintf("%-3d ", xf->xf_fd);
 			displaysock(s, pos);
 		}
 	}