From owner-svn-src-head@FreeBSD.ORG Wed May 21 10:04:52 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3A88E1FF; Wed, 21 May 2014 10:04:52 +0000 (UTC) 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 0DE172724; Wed, 21 May 2014 10:04:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4LA4ph8027064; Wed, 21 May 2014 10:04:51 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4LA4pw2027063; Wed, 21 May 2014 10:04:51 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201405211004.s4LA4pw2027063@svn.freebsd.org> From: Hiroki Sato Date: Wed, 21 May 2014 10:04:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266494 - head/usr.bin/netstat 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.18 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: Wed, 21 May 2014 10:04:52 -0000 Author: hrs Date: Wed May 21 10:04:51 2014 New Revision: 266494 URL: http://svnweb.freebsd.org/changeset/base/266494 Log: - Fix a bug which can make sysctl() fail when -F is specified. - Increase WID_IF_DEFAULT() from 6 to 8 (the default for AF_INET6) because we have interfaces with longer names than 6 chars like epairN{a,b}. - Style fixes. Modified: head/usr.bin/netstat/route.c Modified: head/usr.bin/netstat/route.c ============================================================================== --- head/usr.bin/netstat/route.c Wed May 21 09:26:02 2014 (r266493) +++ head/usr.bin/netstat/route.c Wed May 21 10:04:51 2014 (r266494) @@ -230,13 +230,13 @@ pr_family(int af1) #ifndef INET6 #define WID_DST_DEFAULT(af) 18 /* width of destination column */ #define WID_GW_DEFAULT(af) 18 /* width of gateway column */ -#define WID_IF_DEFAULT(af) (Wflag ? 8 : 6) /* width of netif column */ +#define WID_IF_DEFAULT(af) (Wflag ? 10 : 8) /* width of netif column */ #else #define WID_DST_DEFAULT(af) \ ((af) == AF_INET6 ? (numeric_addr ? 33: 18) : 18) #define WID_GW_DEFAULT(af) \ ((af) == AF_INET6 ? (numeric_addr ? 29 : 18) : 18) -#define WID_IF_DEFAULT(af) ((af) == AF_INET6 ? 8 : (Wflag ? 8 : 6)) +#define WID_IF_DEFAULT(af) ((af) == AF_INET6 ? 8 : (Wflag ? 10 : 8)) #endif /*INET6*/ static int wid_dst; @@ -586,17 +586,13 @@ p_rtable_sysctl(int fibnum, int af) mib[4] = NET_RT_DUMP; mib[5] = 0; mib[6] = fibnum; - if (sysctl(mib, nitems(mib), NULL, &needed, NULL, 0) < 0) { + if (sysctl(mib, nitems(mib), NULL, &needed, NULL, 0) < 0) err(EX_OSERR, "sysctl: net.route.0.%d.dump.%d estimate", af, fibnum); - } - - if ((buf = malloc(needed)) == 0) { + if ((buf = malloc(needed)) == NULL) errx(2, "malloc(%lu)", (unsigned long)needed); - } - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { + if (sysctl(mib, nitems(mib), buf, &needed, NULL, 0) < 0) err(1, "sysctl: net.route.0.%d.dump.%d", af, fibnum); - } lim = buf + needed; for (next = buf; next < lim; next += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)next;