Skip to content

Commit

Permalink
Use static local variables instead of global variables whenever possi…
Browse files Browse the repository at this point in the history
…ble.

Also, there's no need to zero initialize global and static variables,
that's done automatically by the compiler.

ok claudio@ benno@
  • Loading branch information
rwestphal committed Sep 2, 2016
1 parent 6a41179 commit 0c82e3c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
5 changes: 3 additions & 2 deletions eigrpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions neighbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 3 additions & 2 deletions rde.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0c82e3c

Please sign in to comment.