From owner-svn-src-head@FreeBSD.ORG Sat Jun 13 19:56:05 2015 Return-Path: Delivered-To: svn-src-head@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BC0BC54F; Sat, 13 Jun 2015 19:56:05 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 903C79AF; Sat, 13 Jun 2015 19:56:05 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5DJu5Ko053601; Sat, 13 Jun 2015 19:56:05 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5DJu5sI053600; Sat, 13 Jun 2015 19:56:05 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201506131956.t5DJu5sI053600@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sat, 13 Jun 2015 19:56:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284351 - head/usr.bin/sockstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jun 2015 19:56:05 -0000 Author: tuexen Date: Sat Jun 13 19:56:04 2015 New Revision: 284351 URL: https://svnweb.freebsd.org/changeset/base/284351 Log: Simplify printaddr(). No functional change. MFC after: 3 days Modified: head/usr.bin/sockstat/sockstat.c Modified: head/usr.bin/sockstat/sockstat.c ============================================================================== --- head/usr.bin/sockstat/sockstat.c Sat Jun 13 19:53:24 2015 (r284350) +++ head/usr.bin/sockstat/sockstat.c Sat Jun 13 19:56:04 2015 (r284351) @@ -496,14 +496,14 @@ getfiles(void) } static int -printaddr(int af, struct sockaddr_storage *ss) +printaddr(struct sockaddr_storage *ss) { char addrstr[INET6_ADDRSTRLEN] = { '\0', '\0' }; struct sockaddr_un *sun; void *addr = NULL; /* Keep compiler happy. */ int off, port = 0; - switch (af) { + switch (ss->ss_family) { case AF_INET: addr = &((struct sockaddr_in *)ss)->sin_addr; if (inet_lnaof(*(struct in_addr *)addr) == INADDR_ANY) @@ -522,7 +522,7 @@ printaddr(int af, struct sockaddr_storag return (xprintf("%.*s", sun->sun_len - off, sun->sun_path)); } if (addrstr[0] == '\0') - inet_ntop(af, addr, addrstr, sizeof addrstr); + inet_ntop(ss->ss_family, addr, addrstr, sizeof addrstr); if (port == 0) return xprintf("%s:*", addrstr); else @@ -613,17 +613,17 @@ displaysock(struct sock *s, int pos) switch (s->family) { case AF_INET: case AF_INET6: - pos += printaddr(s->family, &s->laddr); + pos += printaddr(&s->laddr); if (s->family == AF_INET6 && pos >= 58) pos += xprintf(" "); while (pos < 58) pos += xprintf(" "); - pos += printaddr(s->family, &s->faddr); + pos += printaddr(&s->faddr); break; case AF_UNIX: /* server */ if (s->laddr.ss_len > 0) { - pos += printaddr(s->family, &s->laddr); + pos += printaddr(&s->laddr); break; } /* client */ @@ -643,7 +643,7 @@ displaysock(struct sock *s, int pos) if (s == NULL || s->laddr.ss_len == 0) pos += xprintf("??"); else - pos += printaddr(s->family, &s->laddr); + pos += printaddr(&s->laddr); break; default: abort();