aboutsummaryrefslogtreecommitdiff
path: root/sbin/route
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2013-12-04 20:03:55 +0000
committerEitan Adler <eadler@FreeBSD.org>2013-12-04 20:03:55 +0000
commitb9f2ea4a57757882403b24c4e8041838cc0fd8f7 (patch)
tree6aef1cc4182f5c476b9b059e8ccb00a73d2f97d4 /sbin/route
parentb63940c108110c78eeb1430a2b0f5b1a9c87e99c (diff)
downloadsrc-b9f2ea4a57757882403b24c4e8041838cc0fd8f7.tar.gz
src-b9f2ea4a57757882403b24c4e8041838cc0fd8f7.zip
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
Notes
Notes: svn path=/head/; revision=258934
Diffstat (limited to 'sbin/route')
-rw-r--r--sbin/route/route.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 78a3792e3370..a5e841970fd2 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -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';