From owner-svn-src-head@FreeBSD.ORG Wed Dec 4 20:03:55 2013 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 A6F41D6; Wed, 4 Dec 2013 20:03:55 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 93A3B1D0A; Wed, 4 Dec 2013 20:03:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rB4K3thP063974; Wed, 4 Dec 2013 20:03:55 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rB4K3tjv063973; Wed, 4 Dec 2013 20:03:55 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201312042003.rB4K3tjv063973@svn.freebsd.org> From: Eitan Adler Date: Wed, 4 Dec 2013 20:03:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258934 - head/sbin/route 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.17 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, 04 Dec 2013 20:03:55 -0000 Author: eadler Date: Wed Dec 4 20:03:55 2013 New Revision: 258934 URL: http://svnweb.freebsd.org/changeset/base/258934 Log: route(1): Pull static buffer out of the function and into function scope. This will make it easier to link as a library. Submitted by: Sebastian Huber (older version) Discussed on: -hackers Modified: head/sbin/route/route.c Modified: head/sbin/route/route.c ============================================================================== --- head/sbin/route/route.c Wed Dec 4 20:02:16 2013 (r258933) +++ head/sbin/route/route.c Wed Dec 4 20:03:55 2013 (r258934) @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -92,6 +93,8 @@ static u_long rtm_inits; static uid_t uid; static int defaultfib; static int numfibs; +static char domain[MAXHOSTNAMELEN + 1]; +static bool domain_initialized; static int atalk_aton(const char *, struct at_addr *); static char *atalk_ntoa(struct at_addr, char [ATALK_BUF_SIZE]); @@ -499,12 +502,10 @@ routename(struct sockaddr *sa) const char *cp; char atalk_buf[ATALK_BUF_SIZE]; static char line[NI_MAXHOST]; - static char domain[MAXHOSTNAMELEN + 1]; - static int first = 1; int n; - if (first) { - first = 0; + if (!domain_initialized) { + domain_initialized = true; if (gethostname(domain, MAXHOSTNAMELEN) == 0 && (cp = strchr(domain, '.'))) { domain[MAXHOSTNAMELEN] = '\0';