Date: Wed, 4 Dec 2013 20:03:55 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258934 - head/sbin/route Message-ID: <201312042003.rB4K3tjv063973@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sebastian.huber@embedded-brains.de> (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 <err.h> #include <errno.h> #include <paths.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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';
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312042003.rB4K3tjv063973>