summaryrefslogtreecommitdiff
path: root/usr.sbin/eigrpd
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-09-02 16:39:45 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-09-02 16:39:45 +0000
commitdcaa3316f517f3e75debd2dc1ae2838de28a7b02 (patch)
tree1d368be1e3f0dc8ba13cabdddf40977e5448a78f /usr.sbin/eigrpd
parent2ef6995d8b15a299fca10407d44600592771f223 (diff)
Use static local variables instead of global variables whenever possible.
Also, there's no need to zero initialize global and static variables, that's done automatically by the compiler. ok claudio@ benno@
Diffstat (limited to 'usr.sbin/eigrpd')
-rw-r--r--usr.sbin/eigrpd/eigrpe.c7
-rw-r--r--usr.sbin/eigrpd/interface.c5
-rw-r--r--usr.sbin/eigrpd/neighbor.c6
-rw-r--r--usr.sbin/eigrpd/parse.y10
-rw-r--r--usr.sbin/eigrpd/rde.c7
5 files changed, 18 insertions, 17 deletions
diff --git a/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c
index 779a795a69b..fba71a9d162 100644
--- a/usr.sbin/eigrpd/eigrpe.c
+++ b/usr.sbin/eigrpd/eigrpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpe.c,v 1.30 2016/09/02 16:36:33 renato Exp $ */
+/* $OpenBSD: eigrpe.c,v 1.31 2016/09/02 16:39:44 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -42,7 +42,7 @@ __dead void eigrpe_shutdown(void);
static struct event ev4;
static struct event ev6;
-struct eigrpd_conf *econf = NULL, *nconf;
+struct eigrpd_conf *econf;
struct imsgev *iev_main;
struct imsgev *iev_rde;
@@ -227,7 +227,8 @@ eigrpe_imsg_compose_rde(int type, uint32_t peerid, pid_t pid,
void
eigrpe_dispatch_main(int fd, short event, void *bula)
{
- static struct iface *niface = NULL;
+ static struct eigrpd_conf *nconf;
+ static struct iface *niface;
static struct eigrp *neigrp;
struct eigrp_iface *nei;
struct imsg imsg;
diff --git a/usr.sbin/eigrpd/interface.c b/usr.sbin/eigrpd/interface.c
index 8821919819c..e02107eefe5 100644
--- a/usr.sbin/eigrpd/interface.c
+++ b/usr.sbin/eigrpd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.21 2016/09/02 16:34:20 renato Exp $ */
+/* $OpenBSD: interface.c,v 1.22 2016/09/02 16:39:44 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -50,8 +50,6 @@ RB_GENERATE(iface_id_head, eigrp_iface, id_tree, iface_id_compare)
struct iface_id_head ifaces_by_id = RB_INITIALIZER(&ifaces_by_id);
-static uint32_t ifacecnt = 1;
-
struct iface *
if_new(struct eigrpd_conf *xconf, struct kif *kif)
{
@@ -294,6 +292,7 @@ eigrp_if_new(struct eigrpd_conf *xconf, struct eigrp *eigrp, struct kif *kif)
{
struct iface *iface;
struct eigrp_iface *ei;
+ static uint32_t ifacecnt = 1;
iface = if_lookup(xconf, kif->ifindex);
if (iface == NULL)
diff --git a/usr.sbin/eigrpd/neighbor.c b/usr.sbin/eigrpd/neighbor.c
index c6a2388c832..d8b5a2375db 100644
--- a/usr.sbin/eigrpd/neighbor.c
+++ b/usr.sbin/eigrpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.8 2016/09/02 16:29:55 renato Exp $ */
+/* $OpenBSD: neighbor.c,v 1.9 2016/09/02 16:39:44 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -53,8 +53,6 @@ nbr_pid_compare(struct nbr *a, struct nbr *b)
struct nbr_pid_head nbrs_by_pid = RB_INITIALIZER(&nbrs_by_pid);
-uint32_t peercnt = NBR_CNTSTART;
-
extern struct eigrpd_conf *econf;
struct nbr *
@@ -150,6 +148,8 @@ nbr_del(struct nbr *nbr)
void
nbr_update_peerid(struct nbr *nbr)
{
+ static uint32_t peercnt = NBR_CNTSTART;
+
if (nbr->peerid)
RB_REMOVE(nbr_pid_head, &nbrs_by_pid, nbr);
diff --git a/usr.sbin/eigrpd/parse.y b/usr.sbin/eigrpd/parse.y
index 6a38b338921..a821a04be3d 100644
--- a/usr.sbin/eigrpd/parse.y
+++ b/usr.sbin/eigrpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.17 2016/09/02 16:29:55 renato Exp $ */
+/* $OpenBSD: parse.y,v 1.18 2016/09/02 16:39:44 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -79,11 +79,11 @@ uint32_t get_rtr_id(void);
int get_prefix(const char *, union eigrpd_addr *, uint8_t *);
static struct eigrpd_conf *conf;
-static int errors = 0;
+static int errors;
-int af = AF_UNSPEC;
-struct eigrp *eigrp = NULL;
-struct eigrp_iface *ei = NULL;
+int af;
+struct eigrp *eigrp;
+struct eigrp_iface *ei;
struct config_defaults {
uint8_t kvalues[6];
diff --git a/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c
index cf40aacdef4..6eb797ca0b2 100644
--- a/usr.sbin/eigrpd/rde.c
+++ b/usr.sbin/eigrpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.20 2016/09/02 16:29:55 renato Exp $ */
+/* $OpenBSD: rde.c,v 1.21 2016/09/02 16:39:44 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -40,7 +40,7 @@ __dead void rde_shutdown(void);
void rde_dispatch_imsg(int, short, void *);
void rde_dispatch_parent(int, short, void *);
-struct eigrpd_conf *rdeconf = NULL, *nconf;
+struct eigrpd_conf *rdeconf;
struct imsgev *iev_eigrpe;
struct imsgev *iev_main;
@@ -304,7 +304,8 @@ rde_dispatch_imsg(int fd, short event, void *bula)
void
rde_dispatch_parent(int fd, short event, void *bula)
{
- static struct iface *niface = NULL;
+ static struct eigrpd_conf *nconf;
+ static struct iface *niface;
static struct eigrp *neigrp;
struct eigrp_iface *nei;
struct imsg imsg;