Minor code cleanups
This commit is contained in:
parent
920a86e849
commit
c8cafc8ebb
13 changed files with 80 additions and 41 deletions
|
@ -85,7 +85,7 @@ int undo_available; /* Undo was not requested from last reconfiguration */
|
||||||
* further use. Returns a pointer to the structure.
|
* further use. Returns a pointer to the structure.
|
||||||
*/
|
*/
|
||||||
struct config *
|
struct config *
|
||||||
config_alloc(byte *name)
|
config_alloc(const byte *name)
|
||||||
{
|
{
|
||||||
pool *p = rp_new(&root_pool, "Config");
|
pool *p = rp_new(&root_pool, "Config");
|
||||||
linpool *l = lp_new(p, 4080);
|
linpool *l = lp_new(p, 4080);
|
||||||
|
@ -530,7 +530,7 @@ cf_error(char *msg, ...)
|
||||||
* and we want to preserve it for further use.
|
* and we want to preserve it for further use.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
cfg_strdup(char *c)
|
cfg_strdup(const char *c)
|
||||||
{
|
{
|
||||||
int l = strlen(c) + 1;
|
int l = strlen(c) + 1;
|
||||||
char *z = cfg_allocu(l);
|
char *z = cfg_allocu(l);
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct config {
|
||||||
list protos; /* Configured protocol instances (struct proto_config) */
|
list protos; /* Configured protocol instances (struct proto_config) */
|
||||||
list tables; /* Configured routing tables (struct rtable_config) */
|
list tables; /* Configured routing tables (struct rtable_config) */
|
||||||
list roa_tables; /* Configured ROA tables (struct roa_table_config) */
|
list roa_tables; /* Configured ROA tables (struct roa_table_config) */
|
||||||
list logfiles; /* Configured log fils (sysdep) */
|
list logfiles; /* Configured log files (sysdep) */
|
||||||
|
|
||||||
int mrtdump_file; /* Configured MRTDump file (sysdep, fd in unix) */
|
int mrtdump_file; /* Configured MRTDump file (sysdep, fd in unix) */
|
||||||
char *syslog_name; /* Name used for syslog (NULL -> no syslog) */
|
char *syslog_name; /* Name used for syslog (NULL -> no syslog) */
|
||||||
|
@ -61,7 +61,7 @@ struct config {
|
||||||
extern struct config *config; /* Currently active configuration */
|
extern struct config *config; /* Currently active configuration */
|
||||||
extern struct config *new_config; /* Configuration being parsed */
|
extern struct config *new_config; /* Configuration being parsed */
|
||||||
|
|
||||||
struct config *config_alloc(byte *name);
|
struct config *config_alloc(const byte *name);
|
||||||
int config_parse(struct config *);
|
int config_parse(struct config *);
|
||||||
int cli_parse(struct config *);
|
int cli_parse(struct config *);
|
||||||
void config_free(struct config *);
|
void config_free(struct config *);
|
||||||
|
@ -95,7 +95,7 @@ extern linpool *cfg_mem;
|
||||||
#define cfg_alloc(size) lp_alloc(cfg_mem, size)
|
#define cfg_alloc(size) lp_alloc(cfg_mem, size)
|
||||||
#define cfg_allocu(size) lp_allocu(cfg_mem, size)
|
#define cfg_allocu(size) lp_allocu(cfg_mem, size)
|
||||||
#define cfg_allocz(size) lp_allocz(cfg_mem, size)
|
#define cfg_allocz(size) lp_allocz(cfg_mem, size)
|
||||||
char *cfg_strdup(char *c);
|
char *cfg_strdup(const char *c);
|
||||||
void cfg_copy_list(list *dest, list *src, unsigned node_size);
|
void cfg_copy_list(list *dest, list *src, unsigned node_size);
|
||||||
|
|
||||||
/* Lexer */
|
/* Lexer */
|
||||||
|
|
|
@ -138,7 +138,7 @@ expr_us:
|
||||||
/* Switches */
|
/* Switches */
|
||||||
|
|
||||||
bool:
|
bool:
|
||||||
expr {$$ = !!$1; }
|
expr { $$ = !!$1; }
|
||||||
| ON { $$ = 1; }
|
| ON { $$ = 1; }
|
||||||
| YES { $$ = 1; }
|
| YES { $$ = 1; }
|
||||||
| OFF { $$ = 0; }
|
| OFF { $$ = 0; }
|
||||||
|
|
|
@ -196,10 +196,10 @@ void val_format(struct f_val v, buffer *buf);
|
||||||
#define SA_PROTO 4
|
#define SA_PROTO 4
|
||||||
#define SA_SOURCE 5
|
#define SA_SOURCE 5
|
||||||
#define SA_SCOPE 6
|
#define SA_SCOPE 6
|
||||||
#define SA_CAST 7
|
#define SA_CAST 7
|
||||||
#define SA_DEST 8
|
#define SA_DEST 8
|
||||||
#define SA_IFNAME 9
|
#define SA_IFNAME 9
|
||||||
#define SA_IFINDEX 10
|
#define SA_IFINDEX 10
|
||||||
|
|
||||||
|
|
||||||
struct f_tree {
|
struct f_tree {
|
||||||
|
|
|
@ -63,7 +63,7 @@ tree_compare(const void *p1, const void *p2)
|
||||||
* build_tree
|
* build_tree
|
||||||
* @from: degenerated tree (linked by @tree->left) to be transformed into form suitable for find_tree()
|
* @from: degenerated tree (linked by @tree->left) to be transformed into form suitable for find_tree()
|
||||||
*
|
*
|
||||||
* Transforms denerated tree into balanced tree.
|
* Transforms degenerated tree into balanced tree.
|
||||||
*/
|
*/
|
||||||
struct f_tree *
|
struct f_tree *
|
||||||
build_tree(struct f_tree *from)
|
build_tree(struct f_tree *from)
|
||||||
|
|
16
lib/buffer.h
16
lib/buffer.h
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* BIRD Library -- Generic Buffer Structure
|
||||||
|
*
|
||||||
|
* (c) 2013 Ondrej Zajicek <santiago@crfreenet.org>
|
||||||
|
* (c) 2013 CZ.NIC z.s.p.o.
|
||||||
|
*
|
||||||
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BIRD_BUFFER_H_
|
||||||
|
#define _BIRD_BUFFER_H_
|
||||||
|
|
||||||
|
#include "lib/resource.h"
|
||||||
|
#include "sysdep/config.h"
|
||||||
|
|
||||||
#define BUFFER(type) struct { type *data; uint used, size; }
|
#define BUFFER(type) struct { type *data; uint used, size; }
|
||||||
|
|
||||||
|
@ -32,4 +46,4 @@
|
||||||
|
|
||||||
#define BUFFER_FLUSH(v) ({ (v).used = 0; })
|
#define BUFFER_FLUSH(v) ({ (v).used = 0; })
|
||||||
|
|
||||||
|
#endif /* _BIRD_BUFFER_H_ */
|
||||||
|
|
11
lib/hash.h
11
lib/hash.h
|
@ -1,4 +1,14 @@
|
||||||
|
/*
|
||||||
|
* BIRD Library -- Generic Hash Table
|
||||||
|
*
|
||||||
|
* (c) 2013 Ondrej Zajicek <santiago@crfreenet.org>
|
||||||
|
* (c) 2013 CZ.NIC z.s.p.o.
|
||||||
|
*
|
||||||
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BIRD_HASH_H_
|
||||||
|
#define _BIRD_HASH_H_
|
||||||
|
|
||||||
#define HASH(type) struct { type **data; uint count, order; }
|
#define HASH(type) struct { type **data; uint count, order; }
|
||||||
#define HASH_TYPE(v) typeof(** (v).data)
|
#define HASH_TYPE(v) typeof(** (v).data)
|
||||||
|
@ -178,3 +188,4 @@
|
||||||
|
|
||||||
#define HASH_WALK_FILTER_END } while (0)
|
#define HASH_WALK_FILTER_END } while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -678,7 +678,7 @@ link_back(struct ospf_area *oa, struct top_hash_entry *en, struct top_hash_entry
|
||||||
which may be later used as the next hop. */
|
which may be later used as the next hop. */
|
||||||
|
|
||||||
/* In OSPFv2, en->lb is set here. In OSPFv3, en->lb is just cleared here,
|
/* In OSPFv2, en->lb is set here. In OSPFv3, en->lb is just cleared here,
|
||||||
it is set in process_prefixes() to any global addres in the area */
|
it is set in process_prefixes() to any global address in the area */
|
||||||
|
|
||||||
en->lb = IPA_NONE;
|
en->lb = IPA_NONE;
|
||||||
en->lb_id = 0;
|
en->lb_id = 0;
|
||||||
|
@ -930,7 +930,7 @@ ospf_rt_sum_tr(struct ospf_area *oa)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decide about originating or flushing summary LSAs for condended area networks */
|
/* Decide about originating or flushing summary LSAs for condensed area networks */
|
||||||
static int
|
static int
|
||||||
decide_anet_lsa(struct ospf_area *oa, struct area_net *anet, struct ospf_area *anet_oa)
|
decide_anet_lsa(struct ospf_area *oa, struct area_net *anet, struct ospf_area *anet_oa)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
|
#ifndef _BIRD_SYSPRIV_H_
|
||||||
|
#define _BIRD_SYSPRIV_H_
|
||||||
|
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#include <linux/capability.h>
|
#include <linux/capability.h>
|
||||||
|
|
||||||
|
@ -70,3 +77,5 @@ drop_uid(uid_t uid)
|
||||||
if (setresuid(uid, uid, uid) < 0)
|
if (setresuid(uid, uid, uid) < 0)
|
||||||
die("setresuid: %m");
|
die("setresuid: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* _BIRD_SYSPRIV_H_ */
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
|
|
||||||
/* Unfortunately, some glibc versions hide parts of RFC 3542 API
|
/* Unfortunately, some glibc versions hide parts of RFC 3542 API
|
||||||
if _GNU_SOURCE is not defined. */
|
if _GNU_SOURCE is not defined. */
|
||||||
#define _GNU_SOURCE 1
|
#ifndef _GNU_SOURCE
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -2046,6 +2048,7 @@ watchdog_stop(void)
|
||||||
|
|
||||||
volatile int async_config_flag; /* Asynchronous reconfiguration/dump scheduled */
|
volatile int async_config_flag; /* Asynchronous reconfiguration/dump scheduled */
|
||||||
volatile int async_dump_flag;
|
volatile int async_dump_flag;
|
||||||
|
volatile int async_shutdown_flag;
|
||||||
|
|
||||||
void
|
void
|
||||||
io_init(void)
|
io_init(void)
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
|
|
||||||
#undef LOCAL_DEBUG
|
#undef LOCAL_DEBUG
|
||||||
|
|
||||||
#define _GNU_SOURCE 1
|
#ifndef _GNU_SOURCE
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
Loading…
Reference in a new issue