]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Minor code cleanups
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 8 Nov 2016 16:46:29 +0000 (17:46 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 8 Nov 2016 16:46:29 +0000 (17:46 +0100)
13 files changed:
conf/cf-lex.l
conf/conf.c
conf/conf.h
conf/confbase.Y
filter/config.Y
filter/filter.h
filter/tree.c
lib/buffer.h
lib/hash.h
proto/ospf/rt.c
sysdep/linux/syspriv.h
sysdep/unix/io.c
sysdep/unix/main.c

index d2aa64028942f23efb726f83dbf8043b7423e8a8..e9e385a68269f4a42b163e7345e3188e5a9be6db 100644 (file)
@@ -589,7 +589,7 @@ cf_lex_init(int is_cli, struct config *c)
     cf_lex_init_kh();
 
   ifs_head = ifs = push_ifs(NULL);
-  if (!is_cli) 
+  if (!is_cli)
     {
       ifs->file_name = c->file_name;
       ifs->fd = c->file_fd;
index 029814c60a400dfdc11e7bcd0943688b9badf21e..0a4e3f8cce5fb72ca81bd3eeb6c976c69c0e7cd7 100644 (file)
@@ -85,7 +85,7 @@ int undo_available;                   /* Undo was not requested from last reconfiguration */
  * further use. Returns a pointer to the structure.
  */
 struct config *
-config_alloc(byte *name)
+config_alloc(const byte *name)
 {
   pool *p = rp_new(&root_pool, "Config");
   linpool *l = lp_new(p, 4080);
@@ -405,7 +405,7 @@ config_confirm(void)
  * if it's been queued due to another reconfiguration being in progress now,
  * %CONF_UNQUEUED if a scheduled reconfiguration is removed, %CONF_NOTHING
  * if there is no relevant configuration to undo (the previous config request
- * was config_undo() too)  or %CONF_SHUTDOWN if BIRD is in shutdown mode and 
+ * was config_undo() too)  or %CONF_SHUTDOWN if BIRD is in shutdown mode and
  * no new configuration changes  are accepted.
  */
 int
@@ -530,7 +530,7 @@ cf_error(char *msg, ...)
  * and we want to preserve it for further use.
  */
 char *
-cfg_strdup(char *c)
+cfg_strdup(const char *c)
 {
   int l = strlen(c) + 1;
   char *z = cfg_allocu(l);
index 89a2c5b715261d89cad0201484681866b9d5e1ee..41cb434fd6b68a89ecfaeee9aec528c54190f341 100644 (file)
@@ -21,7 +21,7 @@ struct config {
   list protos;                         /* Configured protocol instances (struct proto_config) */
   list tables;                         /* Configured routing tables (struct rtable_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) */
   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 *new_config;      /* Configuration being parsed */
 
-struct config *config_alloc(byte *name);
+struct config *config_alloc(const byte *name);
 int config_parse(struct config *);
 int cli_parse(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_allocu(size) lp_allocu(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);
 
 /* Lexer */
index c14c23c73d1745a2ea2e6c2cad094f1c8b7f30fd..96b32028cc1c791dc3f35901383819e69d5e55fa 100644 (file)
@@ -138,7 +138,7 @@ expr_us:
 /* Switches */
 
 bool:
-   expr {$$ = !!$1; }
+   expr { $$ = !!$1; }
  | ON { $$ = 1; }
  | YES { $$ = 1; }
  | OFF { $$ = 0; }
index 29e3a7342f1bd49de0f9bc709292055d96c64731..5ea83f81b21ca55b4fd7b1b2fd405c4cb1c5a335 100644 (file)
@@ -158,7 +158,7 @@ f_new_lc_item(u32 f1, u32 t1, u32 f2, u32 t2, u32 f3, u32 t3)
 
 static inline struct f_inst *
 f_generate_empty(struct f_inst *dyn)
-{ 
+{
   struct f_inst *e = f_new_inst();
   e->code = 'E';
 
@@ -261,7 +261,7 @@ f_generate_ec(u16 kind, struct f_inst *tk, struct f_inst *tv)
 
   if (c1 && c2) {
     u64 ec;
-  
+
     if (kind == EC_GENERIC) {
       ec = ec_generic(key, val2);
     }
@@ -280,7 +280,7 @@ f_generate_ec(u16 kind, struct f_inst *tk, struct f_inst *tv)
     NEW_F_VAL;
     rv = f_new_inst();
     rv->code = 'C';
-    rv->a1.p = val;    
+    rv->a1.p = val;
     val->type = T_EC;
     val->val.ec = ec;
   }
@@ -355,7 +355,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
 %type <e> pair_item ec_item lc_item set_item switch_item set_items switch_items switch_body
 %type <trie> fprefix_set
 %type <v> set_atom switch_atom fprefix fprefix_s fipa
-%type <s> decls declsn one_decl function_params 
+%type <s> decls declsn one_decl function_params
 %type <h> bgp_path bgp_path_tail1 bgp_path_tail2
 
 CF_GRAMMAR
@@ -391,7 +391,7 @@ type:
  | CLIST { $$ = T_CLIST; }
  | ECLIST { $$ = T_ECLIST; }
  | LCLIST { $$ = T_LCLIST; }
- | type SET { 
+ | type SET {
        switch ($1) {
          case T_INT:
          case T_PAIR:
@@ -506,7 +506,7 @@ function_def:
    } function_params function_body {
      $2->def = $5;
      $2->aux2 = $4;
-     DBG("Hmm, we've got one function here - %s\n", $2->name); 
+     DBG("Hmm, we've got one function here - %s\n", $2->name);
      cf_pop_scope();
    }
  ;
@@ -652,7 +652,7 @@ fprefix:
    fprefix_s { $$ = $1; }
  | fprefix_s '+' { $$ = $1; $$.val.px.len |= LEN_PLUS; }
  | fprefix_s '-' { $$ = $1; $$.val.px.len |= LEN_MINUS; }
- | fprefix_s '{' NUM ',' NUM '}' { 
+ | fprefix_s '{' NUM ',' NUM '}' {
      if (! ((0 <= $3) && ($3 <= $5) && ($5 <= MAX_PREFIX_LENGTH))) cf_error("Invalid prefix pattern range: {%d, %d}.", $3, $5);
      $$ = $1; $$.val.px.len |= LEN_RANGE | ($3 << 16) | ($5 << 8);
    }
@@ -671,7 +671,7 @@ switch_body: /* EMPTY */ { $$ = NULL; }
        t->data = $4;
      $$ = f_merge_items($1, $2);
    }
- | switch_body ELSECOL cmds { 
+ | switch_body ELSECOL cmds {
      struct f_tree *t = f_new_tree();
      t->from.type = t->to.type = T_VOID;
      t->right = t;
@@ -683,7 +683,7 @@ switch_body: /* EMPTY */ { $$ = NULL; }
 /* CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_INT; $$->a2.i = $3; } */
 
 bgp_path_expr:
-   symbol       { $$ = $1; }   
+   symbol       { $$ = $1; }
  | '(' term ')' { $$ = $2; }
  ;
 
@@ -836,8 +836,8 @@ term:
  | '-' EMPTY '-' { $$ = f_new_inst(); $$->code = 'E'; $$->aux = T_CLIST; }
  | '-' '-' EMPTY '-' '-' { $$ = f_new_inst(); $$->code = 'E'; $$->aux = T_ECLIST; }
  | '-' '-' '-' EMPTY '-' '-' '-' { $$ = f_new_inst(); $$->code = 'E'; $$->aux = T_LCLIST; }
- | PREPEND '(' term ',' term ')' { $$ = f_new_inst(); $$->code = P('A','p'); $$->a1.p = $3; $$->a2.p = $5; } 
- | ADD '(' term ',' term ')' { $$ = f_new_inst(); $$->code = P('C','a'); $$->a1.p = $3; $$->a2.p = $5; $$->aux = 'a'; } 
+ | PREPEND '(' term ',' term ')' { $$ = f_new_inst(); $$->code = P('A','p'); $$->a1.p = $3; $$->a2.p = $5; }
+ | ADD '(' term ',' term ')' { $$ = f_new_inst(); $$->code = P('C','a'); $$->a1.p = $3; $$->a2.p = $5; $$->aux = 'a'; }
  | DELETE '(' term ',' term ')' { $$ = f_new_inst(); $$->code = P('C','a'); $$->a1.p = $3; $$->a2.p = $5; $$->aux = 'd'; }
  | FILTER '(' term ',' term ')' { $$ = f_new_inst(); $$->code = P('C','a'); $$->a1.p = $3; $$->a2.p = $5; $$->aux = 'f'; }
 
@@ -892,7 +892,7 @@ print_list: /* EMPTY */ { $$ = NULL; }
    }
  ;
 
-var_listn: term { 
+var_listn: term {
      $$ = f_new_inst();
      $$->code = 's';
      $$->a1.p = NULL;
@@ -960,7 +960,7 @@ cmd:
      $$ = f_new_inst();
      $$->code = P('P','S');
      $$->a1.p = $3;
-   } 
+   }
  | UNSET '(' rtadot dynamic_attr ')' ';' {
      $$ = $4;
      $$->aux = EAF_TYPE_UNDEF | EAF_TEMP;
index e0f34e4fa023a882b8fb1c9ac495f892fcdc327a..049ceb767a23f14ed0bb594695f6001a02e1cd9e 100644 (file)
@@ -35,7 +35,7 @@ struct f_inst {               /* Instruction */
 /* Not enough fields in f_inst for three args used by roa_check() */
 struct f_inst_roa_check {
   struct f_inst i;
-  struct roa_table_config *rtc;        
+  struct roa_table_config *rtc;
 };
 
 struct f_inst3 {
@@ -65,7 +65,7 @@ struct f_val {
     uint i;
     u64 ec;
     lcomm lc;
-    /*    ip_addr ip; Folded into prefix */    
+    /*    ip_addr ip; Folded into prefix */
     struct f_prefix px;
     char *s;
     struct f_tree *t;
@@ -190,16 +190,16 @@ void val_format(struct f_val v, buffer *buf);
 #define T_PREFIX_SET 0x81
 
 
-#define SA_FROM                 1    
-#define SA_GW           2      
-#define SA_NET          3     
-#define SA_PROTO        4   
-#define SA_SOURCE       5  
-#define SA_SCOPE        6   
-#define SA_CAST         7
-#define SA_DEST         8
-#define SA_IFNAME       9
-#define SA_IFINDEX     10
+#define SA_FROM                 1
+#define SA_GW           2
+#define SA_NET          3
+#define SA_PROTO        4
+#define SA_SOURCE       5
+#define SA_SCOPE        6
+#define SA_CAST                 7
+#define SA_DEST                 8
+#define SA_IFNAME       9
+#define SA_IFINDEX     10
 
 
 struct f_tree {
index 1196e630f3a107f5d21cde59ad49e602f6cfcc18..f8379fa8b55c39957c9dd768f15f189ea30912cd 100644 (file)
@@ -63,7 +63,7 @@ tree_compare(const void *p1, const void *p2)
  * build_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 *
 build_tree(struct f_tree *from)
@@ -162,7 +162,7 @@ void
 tree_format(struct f_tree *t, buffer *buf)
 {
   buffer_puts(buf, "[");
+
   tree_node_format(t, buf);
 
   if (buf->pos == buf->end)
@@ -171,6 +171,6 @@ tree_format(struct f_tree *t, buffer *buf)
   /* Undo last separator */
   if (buf->pos[-1] != '[')
     buf->pos -= 2;
+
   buffer_puts(buf, "]");
 }
index cf073e88f05c75dfe0e8a0bf5a42349935c3ccaa..2a53f2118b8882ff089bdcca7a67fad6574d4568 100644 (file)
@@ -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; }
 
@@ -32,4 +46,4 @@
 
 #define BUFFER_FLUSH(v)                ({ (v).used = 0; })
 
-
+#endif /* _BIRD_BUFFER_H_ */
index fc5fea14ba6b225fc9c83ce9689d04a329b0c519..4239b1d8991ee495f0f92e18bef1a679f69397c4 100644 (file)
@@ -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(v)           typeof(** (v).data)
 
 #define HASH_WALK_FILTER_END } while (0)
 
+#endif
index 8b3feda90e50de8f2a60d19072f6abbdb7920ae5..19f2d07455cab7beb2d92023d9d4dc5afb84eb22 100644 (file)
@@ -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. */
 
   /* 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_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
 decide_anet_lsa(struct ospf_area *oa, struct area_net *anet, struct ospf_area *anet_oa)
 {
index d2ba95ddb83a26cb7e7152644f3550b9f4afdc16..8b210f066270f3a6c5ea61dc3765173f3cd84c4f 100644 (file)
@@ -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 <linux/capability.h>
 
@@ -70,3 +77,5 @@ drop_uid(uid_t uid)
   if (setresuid(uid, uid, uid) < 0)
     die("setresuid: %m");
 }
+
+#endif /* _BIRD_SYSPRIV_H_ */
index 873b580575b6b435f3ac96aa8ef23ca0edf714dd..644a4fcd7688aa8122d850ec461f980df52bcd95 100644 (file)
@@ -9,7 +9,9 @@
 
 /* Unfortunately, some glibc versions hide parts of RFC 3542 API
    if _GNU_SOURCE is not defined. */
-#define _GNU_SOURCE 1
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -2046,6 +2048,7 @@ watchdog_stop(void)
 
 volatile int async_config_flag;                /* Asynchronous reconfiguration/dump scheduled */
 volatile int async_dump_flag;
+volatile int async_shutdown_flag;
 
 void
 io_init(void)
index 35bc3fd1ecd6fb956092aeb9096e069770aae95e..8aa19fce419109db913cfe8d7d741294aade92b8 100644 (file)
@@ -8,7 +8,9 @@
 
 #undef LOCAL_DEBUG
 
-#define _GNU_SOURCE 1
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>