From 5b7b235216708586ef17609857cb01a6048fb90b Mon Sep 17 00:00:00 2001 From: eadler Date: Wed, 4 Dec 2013 20:03:55 +0000 Subject: 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 --- sbin/route/route.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sbin/route') diff --git a/sbin/route/route.c b/sbin/route/route.c index 78a3792..a5e8419 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -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'; -- cgit v1.1