Browse Source

2005-05-06 Paul Jakma <paul@dishone.st>

	* (general) extern and static'ification of functions in code and
	  header.
	  Cleanup any definitions with unspecified arguments.
	  Add casts for callback assignments where the callback is defined,
	  typically, as passing void *, but the function being assigned has
	  some other pointer type defined as its argument, as gcc complains
	  about casts from void * to X* via function arguments.
	  Fix some old K&R style function argument definitions.
	  Add noreturn gcc attribute to some functions, as appropriate.
	  Add unused gcc attribute to some functions (eg ones meant to help
	  while debugging)
	  Add guard defines to headers which were missing them.
	* command.c: (install_node) add const qualifier, still doesnt shut
	  up the warning though, because of the double pointer.
	  (cmp_node) ditto
	* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
	  fromn vty.h ones to fix some of the (long) < 0 warnings.
	* thread.c: (various) use thread_empty
	  (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
	* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
	  removed from ospfd/ospf_vty.h
	* zebra.h: Move definition of ZEBRA_PORT to here, to remove
	  dependence of lib on zebra/zserv.h
paul 13 years ago
parent
commit
8cc4198f9f
53 changed files with 722 additions and 666 deletions
  1. 26 0
      lib/ChangeLog
  2. 3 3
      lib/buffer.h
  3. 1 3
      lib/checksum.c
  4. 5 5
      lib/command.c
  5. 21 21
      lib/command.h
  6. 14 13
      lib/distribute.c
  7. 10 10
      lib/distribute.h
  8. 31 31
      lib/filter.c
  9. 6 6
      lib/filter.h
  10. 1 1
      lib/getopt.h
  11. 5 4
      lib/hash.c
  12. 13 11
      lib/hash.h
  13. 17 11
      lib/if.c
  14. 26 26
      lib/if.h
  15. 19 15
      lib/if_rmap.c
  16. 6 6
      lib/if_rmap.h
  17. 5 5
      lib/jhash.h
  18. 41 36
      lib/keychain.c
  19. 5 5
      lib/keychain.h
  20. 2 2
      lib/linklist.c
  21. 14 14
      lib/linklist.h
  22. 21 21
      lib/log.h
  23. 7 23
      lib/md5.c
  24. 1 1
      lib/memory.c
  25. 20 33
      lib/memory.h
  26. 2 2
      lib/network.h
  27. 13 13
      lib/plist.c
  28. 17 12
      lib/plist.h
  29. 1 1
      lib/pqueue.c
  30. 5 5
      lib/pqueue.h
  31. 5 5
      lib/prefix.c
  32. 43 40
      lib/prefix.h
  33. 3 3
      lib/privs.h
  34. 18 18
      lib/routemap.c
  35. 25 31
      lib/routemap.h
  36. 2 2
      lib/sigevent.c
  37. 2 2
      lib/sigevent.h
  38. 12 11
      lib/smux.h
  39. 15 16
      lib/sockopt.h
  40. 4 4
      lib/sockunion.c
  41. 27 27
      lib/sockunion.h
  42. 6 5
      lib/str.h
  43. 52 49
      lib/stream.h
  44. 5 5
      lib/table.c
  45. 17 13
      lib/table.h
  46. 19 17
      lib/thread.c
  47. 29 23
      lib/thread.h
  48. 13 13
      lib/vector.h
  49. 39 16
      lib/vty.h
  50. 7 6
      lib/workqueue.h
  51. 0 3
      lib/zclient.c
  52. 18 18
      lib/zclient.h
  53. 3 0
      lib/zebra.h

+ 26 - 0
lib/ChangeLog

@@ -1,3 +1,29 @@
+2005-05-06 Paul Jakma <paul@dishone.st>
+
+	* (general) extern and static'ification of functions in code and
+	  header.
+	  Cleanup any definitions with unspecified arguments.
+	  Add casts for callback assignments where the callback is defined,
+	  typically, as passing void *, but the function being assigned has
+	  some other pointer type defined as its argument, as gcc complains 
+	  about casts from void * to X* via function arguments.
+	  Fix some old K&R style function argument definitions.
+	  Add noreturn gcc attribute to some functions, as appropriate.
+	  Add unused gcc attribute to some functions (eg ones meant to help
+	  while debugging)
+	  Add guard defines to headers which were missing them.
+	* command.c: (install_node) add const qualifier, still doesnt shut
+	  up the warning though, because of the double pointer.
+	  (cmp_node) ditto
+	* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived 
+	  fromn vty.h ones to fix some of the (long) < 0 warnings.
+	* thread.c: (various) use thread_empty
+	  (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
+	* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
+	  removed from ospfd/ospf_vty.h
+	* zebra.h: Move definition of ZEBRA_PORT to here, to remove
+	  dependence of lib on zebra/zserv.h
+
 2005-05-06 Hasso Tepper <hasso at quagga.net>
 
 	* sockunion.c: Fix warning message.

+ 3 - 3
lib/buffer.h

@@ -27,14 +27,14 @@
 /* Create a new buffer.  Memory will be allocated in chunks of the given
    size.  If the argument is 0, the library will supply a reasonable
    default size suitable for buffering socket I/O. */
-struct buffer *buffer_new (size_t);
+extern struct buffer *buffer_new (size_t);
 
 /* Free all data in the buffer. */
-void buffer_reset (struct buffer *);
+extern void buffer_reset (struct buffer *);
 
 /* This function first calls buffer_reset to release all buffered data.
    Then it frees the struct buffer itself. */
-void buffer_free (struct buffer *);
+extern void buffer_free (struct buffer *);
 
 /* Add the given data to the end of the buffer. */
 extern void buffer_put (struct buffer *, const void *, size_t);

+ 1 - 3
lib/checksum.c

@@ -9,9 +9,7 @@
 #include <zebra.h>
 
 int				/* return checksum in low-order 16 bits */
-in_cksum(ptr, nbytes)
-register u_short	*ptr;
-register int		nbytes;
+in_cksum(u_short *ptr, int nbytes)
 {
 	register long		sum;		/* assumes long == 32 bits */
 	u_short			oddbyte;

+ 5 - 5
lib/command.c

@@ -1,5 +1,5 @@
 /*
-   $Id: command.c,v 1.47 2005/04/25 16:26:42 paul Exp $
+   $Id: command.c,v 1.48 2005/05/06 21:25:49 paul Exp $
  
    Command interpreter routine for virtual terminal [aka TeletYpe]
    Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
@@ -193,8 +193,8 @@ install_node (struct cmd_node *node,
 static int
 cmp_node (const void *p, const void *q)
 {
-  struct cmd_element *a = *(struct cmd_element **)p;
-  struct cmd_element *b = *(struct cmd_element **)q;
+  const struct cmd_element *a = *(struct cmd_element **)p;
+  const struct cmd_element *b = *(struct cmd_element **)q;
 
   return strcmp (a->string, b->string);
 }
@@ -202,8 +202,8 @@ cmp_node (const void *p, const void *q)
 static int
 cmp_desc (const void *p, const void *q)
 {
-  struct desc *a = *(struct desc **)p;
-  struct desc *b = *(struct desc **)q;
+  const struct desc *a = *(struct desc **)p;
+  const struct desc *b = *(struct desc **)q;
 
   return strcmp (a->cmd, b->cmd);
 }

+ 21 - 21
lib/command.h

@@ -318,27 +318,27 @@ struct desc
 #endif /* HAVE_IPV6 */
 
 /* Prototypes. */
-void install_node (struct cmd_node *, int (*) (struct vty *));
-void install_default (enum node_type);
-void install_element (enum node_type, struct cmd_element *);
-void sort_node ();
+extern void install_node (struct cmd_node *, int (*) (struct vty *));
+extern void install_default (enum node_type);
+extern void install_element (enum node_type, struct cmd_element *);
+extern void sort_node (void);
 
 /* Concatenates argv[shift] through argv[argc-1] into a single NUL-terminated
    string with a space between each element (allocated using
    XMALLOC(MTYPE_TMP)).  Returns NULL if shift >= argc. */
-char *argv_concat (const char **argv, int argc, int shift);
-
-vector cmd_make_strvec (const char *);
-void cmd_free_strvec (vector);
-vector cmd_describe_command ();
-char **cmd_complete_command ();
-const char *cmd_prompt (enum node_type);
-int config_from_file (struct vty *, FILE *);
-enum node_type node_parent (enum node_type);
-int cmd_execute_command (vector, struct vty *, struct cmd_element **, int);
-int cmd_execute_command_strict (vector, struct vty *, struct cmd_element **);
-void config_replace_string (struct cmd_element *, char *, ...);
-void cmd_init (int);
+extern char *argv_concat (const char **argv, int argc, int shift);
+
+extern vector cmd_make_strvec (const char *);
+extern void cmd_free_strvec (vector);
+extern vector cmd_describe_command (vector, struct vty *, int *status);
+extern char **cmd_complete_command (vector, struct vty *, int *status);
+extern const char *cmd_prompt (enum node_type);
+extern int config_from_file (struct vty *, FILE *);
+extern enum node_type node_parent (enum node_type);
+extern int cmd_execute_command (vector, struct vty *, struct cmd_element **, int);
+extern int cmd_execute_command_strict (vector, struct vty *, struct cmd_element **);
+extern void config_replace_string (struct cmd_element *, char *, ...);
+extern void cmd_init (int);
 
 /* Export typical functions. */
 extern struct cmd_element config_end_cmd;
@@ -346,9 +346,9 @@ extern struct cmd_element config_exit_cmd;
 extern struct cmd_element config_quit_cmd;
 extern struct cmd_element config_help_cmd;
 extern struct cmd_element config_list_cmd;
-char *host_config_file ();
-void host_config_set (char *);
-
-void print_version (const char *);
+extern char *host_config_file (void);
+extern void host_config_set (char *);
 
+extern void print_version (const char *);
+  
 #endif /* _ZEBRA_COMMAND_H */

+ 14 - 13
lib/distribute.c

@@ -35,8 +35,8 @@ struct hash *disthash;
 void (*distribute_add_hook) (struct distribute *);
 void (*distribute_delete_hook) (struct distribute *);
 
-struct distribute *
-distribute_new ()
+static struct distribute *
+distribute_new (void)
 {
   struct distribute *new;
 
@@ -47,7 +47,7 @@ distribute_new ()
 }
 
 /* Free distribute object. */
-void
+static void
 distribute_free (struct distribute *dist)
 {
   if (dist->ifname)
@@ -93,7 +93,7 @@ distribute_list_delete_hook (void (*func) (struct distribute *))
   distribute_delete_hook = func;
 }
 
-void *
+static void *
 distribute_hash_alloc (struct distribute *arg)
 {
   struct distribute *dist;
@@ -107,7 +107,7 @@ distribute_hash_alloc (struct distribute *arg)
 }
 
 /* Make new distribute list and push into hash. */
-struct distribute *
+static struct distribute *
 distribute_get (const char *ifname)
 {
   struct distribute key;
@@ -115,10 +115,10 @@ distribute_get (const char *ifname)
   /* temporary reference */
   key.ifname = (char *)ifname;
   
-  return hash_get (disthash, &key, distribute_hash_alloc);
+  return hash_get (disthash, &key, (void * (*) (void *))distribute_hash_alloc);
 }
 
-unsigned int
+static unsigned int
 distribute_hash_make (struct distribute *dist)
 {
   unsigned int i, key;
@@ -133,7 +133,7 @@ distribute_hash_make (struct distribute *dist)
 
 /* If two distribute-list have same value then return 1 else return
    0. This function is used by hash package. */
-int
+static int
 distribute_cmp (struct distribute *dist1, struct distribute *dist2)
 {
   if (dist1->ifname && dist2->ifname)
@@ -145,7 +145,7 @@ distribute_cmp (struct distribute *dist1, struct distribute *dist2)
 }
 
 /* Set access-list name to the distribute list. */
-struct distribute *
+static struct distribute *
 distribute_list_set (const char *ifname, enum distribute_type type, 
                      const char *alist_name)
 {
@@ -174,7 +174,7 @@ distribute_list_set (const char *ifname, enum distribute_type type,
 
 /* Unset distribute-list.  If matched distribute-list exist then
    return 1. */
-int
+static int
 distribute_list_unset (const char *ifname, enum distribute_type type, 
 		       const char *alist_name)
 {
@@ -223,7 +223,7 @@ distribute_list_unset (const char *ifname, enum distribute_type type,
 }
 
 /* Set access-list name to the distribute list. */
-struct distribute *
+static struct distribute *
 distribute_list_prefix_set (const char *ifname, enum distribute_type type,
 			    const char *plist_name)
 {
@@ -252,7 +252,7 @@ distribute_list_prefix_set (const char *ifname, enum distribute_type type,
 
 /* Unset distribute-list.  If matched distribute-list exist then
    return 1. */
-int
+static int
 distribute_list_prefix_unset (const char *ifname, enum distribute_type type,
 			      const char *plist_name)
 {
@@ -768,7 +768,8 @@ distribute_list_reset ()
 void
 distribute_list_init (int node)
 {
-  disthash = hash_create (distribute_hash_make, distribute_cmp);
+  disthash = hash_create ((unsigned int (*) (void *)) distribute_hash_make,
+                          (int (*) (void *, void *)) distribute_cmp);
 
   if(node==RIP_NODE) {
     install_element (RIP_NODE, &distribute_list_all_cmd);

+ 10 - 10
lib/distribute.h

@@ -43,15 +43,15 @@ struct distribute
 };
 
 /* Prototypes for distribute-list. */
-void distribute_list_init (int);
-void distribute_list_reset (void);
-void distribute_list_add_hook (void (*) (struct distribute *));
-void distribute_list_delete_hook (void (*) (struct distribute *));
-struct distribute *distribute_lookup (const char *);
-int config_write_distribute (struct vty *);
-int config_show_distribute (struct vty *);
-
-enum filter_type distribute_apply_in (struct interface *, struct prefix *);
-enum filter_type distribute_apply_out (struct interface *, struct prefix *);
+extern void distribute_list_init (int);
+extern void distribute_list_reset (void);
+extern void distribute_list_add_hook (void (*) (struct distribute *));
+extern void distribute_list_delete_hook (void (*) (struct distribute *));
+extern struct distribute *distribute_lookup (const char *);
+extern int config_write_distribute (struct vty *);
+extern int config_show_distribute (struct vty *);
+
+extern enum filter_type distribute_apply_in (struct interface *, struct prefix *);
+extern enum filter_type distribute_apply_out (struct interface *, struct prefix *);
 
 #endif /* _ZEBRA_DISTRIBUTE_H */

+ 31 - 31
lib/filter.c

@@ -84,10 +84,10 @@ struct access_master
   struct access_list_list str;
 
   /* Hook function which is executed when new access_list is added. */
-  void (*add_hook) ();
+  void (*add_hook) (struct access_list *);
 
   /* Hook function which is executed when access_list is deleted. */
-  void (*delete_hook) ();
+  void (*delete_hook) (struct access_list *);
 };
 
 /* Static structure for IPv4 access_list's master. */
@@ -110,7 +110,7 @@ static struct access_master access_master_ipv6 =
 };
 #endif /* HAVE_IPV6 */
 
-struct access_master *
+static struct access_master *
 access_master_get (afi_t afi)
 {
   if (afi == AFI_IP)
@@ -123,14 +123,14 @@ access_master_get (afi_t afi)
 }
 
 /* Allocate new filter structure. */
-struct filter *
-filter_new ()
+static struct filter *
+filter_new (void)
 {
   return (struct filter *) XCALLOC (MTYPE_ACCESS_FILTER,
 				    sizeof (struct filter));
 }
 
-void
+static void
 filter_free (struct filter *filter)
 {
   XFREE (MTYPE_ACCESS_FILTER, filter);
@@ -209,22 +209,22 @@ filter_match_zebra (struct filter *mfilter, struct prefix *p)
 }
 
 /* Allocate new access list structure. */
-struct access_list *
-access_list_new ()
+static struct access_list *
+access_list_new (void)
 {
   return (struct access_list *) XCALLOC (MTYPE_ACCESS_LIST,
 					 sizeof (struct access_list));
 }
 
 /* Free allocated access_list. */
-void
+static void
 access_list_free (struct access_list *access)
 {
   XFREE (MTYPE_ACCESS_LIST, access);
 }
 
 /* Delete access_list from access_master and free it. */
-void
+static void
 access_list_delete (struct access_list *access)
 {
   struct filter *filter;
@@ -266,7 +266,7 @@ access_list_delete (struct access_list *access)
 
 /* Insert new access list to list of access_list.  Each acceess_list
    is sorted by the name. */
-struct access_list *
+static struct access_list *
 access_list_insert (afi_t afi, const char *name)
 {
   unsigned int i;
@@ -383,7 +383,7 @@ access_list_lookup (afi_t afi, const char *name)
 
 /* Get access list from list of access_list.  If there isn't matched
    access_list create new one and return it. */
-struct access_list *
+static struct access_list *
 access_list_get (afi_t afi, const char *name)
 {
   struct access_list *access;
@@ -444,7 +444,7 @@ access_list_delete_hook (void (*func) (struct access_list *access))
 }
 
 /* Add new filter to the end of specified access_list. */
-void
+static void
 access_list_filter_add (struct access_list *access, struct filter *filter)
 {
   filter->next = NULL;
@@ -473,7 +473,7 @@ access_list_empty (struct access_list *access)
 
 /* Delete filter from specified access_list.  If there is hook
    function execute it. */
-void
+static void
 access_list_filter_delete (struct access_list *access, struct filter *filter)
 {
   struct access_master *master;
@@ -513,7 +513,7 @@ access_list_filter_delete (struct access_list *access, struct filter *filter)
   host                 A single host address
 */
 
-struct filter *
+static struct filter *
 filter_lookup_cisco (struct access_list *access, struct filter *mnew)
 {
   struct filter *mfilter;
@@ -547,7 +547,7 @@ filter_lookup_cisco (struct access_list *access, struct filter *mnew)
   return NULL;
 }
 
-struct filter *
+static struct filter *
 filter_lookup_zebra (struct access_list *access, struct filter *mnew)
 {
   struct filter *mfilter;
@@ -568,7 +568,7 @@ filter_lookup_zebra (struct access_list *access, struct filter *mnew)
   return NULL;
 }
 
-int
+static int
 vty_access_list_remark_unset (struct vty *vty, afi_t afi, const char *name)
 {
   struct access_list *access;
@@ -593,7 +593,7 @@ vty_access_list_remark_unset (struct vty *vty, afi_t afi, const char *name)
   return CMD_SUCCESS;
 }
 
-int
+static int
 filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str,
 		  const char *addr_str, const char *addr_mask_str,
 		  const char *mask_str, const char *mask_mask_str,
@@ -1152,7 +1152,7 @@ DEFUN (no_access_list_extended_host_any,
 			   "255.255.255.255", 1, 0);
 }
 
-int
+static int
 filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
 		  afi_t afi, const char *prefix_str, int exact, int set)
 {
@@ -1567,7 +1567,7 @@ void config_write_access_zebra (struct vty *, struct filter *);
 void config_write_access_cisco (struct vty *, struct filter *);
 
 /* show access-list command. */
-int
+static int
 filter_show (struct vty *vty, const char *name, afi_t afi)
 {
   struct access_list *access;
@@ -1782,7 +1782,7 @@ config_write_access_zebra (struct vty *vty, struct filter *mfilter)
   vty_out (vty, "%s", VTY_NEWLINE);
 }
 
-int
+static int
 config_write_access (struct vty *vty, afi_t afi)
 {
   struct access_list *access;
@@ -1858,14 +1858,14 @@ struct cmd_node access_node =
   1
 };
 
-int
+static int
 config_write_access_ipv4 (struct vty *vty)
 {
   return config_write_access (vty, AFI_IP);
 }
 
-void
-access_list_reset_ipv4 ()
+static void
+access_list_reset_ipv4 (void)
 {
   struct access_list *access;
   struct access_list *next;
@@ -1894,8 +1894,8 @@ access_list_reset_ipv4 ()
 }
 
 /* Install vty related command. */
-void
-access_list_init_ipv4 ()
+static void
+access_list_init_ipv4 (void)
 {
   install_node (&access_node, config_write_access_ipv4);
 
@@ -1954,14 +1954,14 @@ struct cmd_node access_ipv6_node =
   1
 };
 
-int
+static int
 config_write_access_ipv6 (struct vty *vty)
 {
   return config_write_access (vty, AFI_IP6);
 }
 
-void
-access_list_reset_ipv6 ()
+static void
+access_list_reset_ipv6 (void)
 {
   struct access_list *access;
   struct access_list *next;
@@ -1989,8 +1989,8 @@ access_list_reset_ipv6 ()
   assert (master->str.tail == NULL);
 }
 
-void
-access_list_init_ipv6 ()
+static void
+access_list_init_ipv6 (void)
 {
   install_node (&access_ipv6_node, config_write_access_ipv6);
 

+ 6 - 6
lib/filter.h

@@ -57,11 +57,11 @@ struct access_list
 };
 
 /* Prototypes for access-list. */
-void access_list_init (void);
-void access_list_reset (void);
-void access_list_add_hook (void (*func)(struct access_list *));
-void access_list_delete_hook (void (*func)(struct access_list *));
-struct access_list *access_list_lookup (afi_t, const char *);
-enum filter_type access_list_apply (struct access_list *, void *);
+extern void access_list_init (void);
+extern void access_list_reset (void);
+extern void access_list_add_hook (void (*func)(struct access_list *));
+extern void access_list_delete_hook (void (*func)(struct access_list *));
+extern struct access_list *access_list_lookup (afi_t, const char *);
+extern enum filter_type access_list_apply (struct access_list *, void *);
 
 #endif /* _ZEBRA_FILTER_H */

+ 1 - 1
lib/getopt.h

@@ -105,7 +105,7 @@ struct option
    errors, only prototype getopt for the GNU C library.  */
 extern int getopt (int argc, char *const *argv, const char *shortopts);
 #else /* not __GNU_LIBRARY__ */
-extern int getopt ();
+extern int getopt (void);
 #endif /* __GNU_LIBRARY__ */
 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
 		        const struct option *longopts, int *longind);

+ 5 - 4
lib/hash.c

@@ -26,8 +26,8 @@
 
 /* Allocate a new hash.  */
 struct hash *
-hash_create_size (unsigned int size, 
-		  unsigned int (*hash_key) (), int (*hash_cmp) ())
+hash_create_size (unsigned int size, unsigned int (*hash_key) (void *),
+                                     int (*hash_cmp) (void *, void *))
 {
   struct hash *hash;
 
@@ -45,7 +45,8 @@ hash_create_size (unsigned int size,
 
 /* Allocate a new hash with default hash size.  */
 struct hash *
-hash_create (unsigned int (*hash_key) (), int (*hash_cmp) ())
+hash_create (unsigned int (*hash_key) (void *), 
+             int (*hash_cmp) (void *, void *))
 {
   return hash_create_size (HASHTABSIZE, hash_key, hash_cmp);
 }
@@ -63,7 +64,7 @@ hash_alloc_intern (void *arg)
    corresponding hash backet and alloc_func is specified, create new
    hash backet.  */
 void *
-hash_get (struct hash *hash, void *data, void * (*alloc_func) ())
+hash_get (struct hash *hash, void *data, void * (*alloc_func) (void *))
 {
   unsigned int key;
   unsigned int index;

+ 13 - 11
lib/hash.h

@@ -45,27 +45,29 @@ struct hash
   unsigned int size;
 
   /* Key make function. */
-  unsigned int (*hash_key) ();
+  unsigned int (*hash_key) (void *);
 
   /* Data compare function. */
-  int (*hash_cmp) ();
+  int (*hash_cmp) (void *, void *);
 
   /* Backet alloc. */
   unsigned long count;
 };
 
-struct hash *hash_create (unsigned int (*) (), int (*) ());
-struct hash *hash_create_size (unsigned int, unsigned int (*) (), int (*) ());
+extern struct hash *hash_create (unsigned int (*) (void *), 
+                          int (*) (void *, void *));
+extern struct hash *hash_create_size (unsigned int, unsigned int (*) (void *), 
+                                             int (*) (void *, void *));
 
-void *hash_get (struct hash *, void *, void * (*) ());
-void *hash_alloc_intern (void *);
-void *hash_lookup (struct hash *, void *);
-void *hash_release (struct hash *, void *);
+extern void *hash_get (struct hash *, void *, void * (*) (void *));
+extern void *hash_alloc_intern (void *);
+extern void *hash_lookup (struct hash *, void *);
+extern void *hash_release (struct hash *, void *);
 
-void hash_iterate (struct hash *, 
+extern void hash_iterate (struct hash *, 
 		   void (*) (struct hash_backet *, void *), void *);
 
-void hash_clean (struct hash *, void (*) (void *));
-void hash_free (struct hash *);
+extern void hash_clean (struct hash *, void (*) (void *));
+extern void hash_free (struct hash *);
 
 #endif /* _ZEBRA_HASH_H */

+ 17 - 11
lib/if.c

@@ -191,13 +191,13 @@ if_lookup_by_index (unsigned int index)
   return NULL;
 }
 
-char *
+const char *
 ifindex2ifname (unsigned int index)
 {
   struct interface *ifp;
 
   return ((ifp = if_lookup_by_index(index)) != NULL) ?
-  	 ifp->name : (char *)"unknown";
+  	 ifp->name : "unknown";
 }
 
 unsigned int
@@ -434,7 +434,7 @@ if_flag_dump (unsigned long flag)
 }
 
 /* For debugging */
-void
+static void
 if_dump (struct interface *ifp)
 {
   struct listnode *node;
@@ -587,7 +587,7 @@ DEFUN (show_address,
 
 /* Allocate connected structure. */
 struct connected *
-connected_new ()
+connected_new (void)
 {
   struct connected *new = XMALLOC (MTYPE_CONNECTED, sizeof (struct connected));
   memset (new, 0, sizeof (struct connected));
@@ -611,7 +611,7 @@ connected_free (struct connected *connected)
 }
 
 /* Print if_addr structure. */
-void
+static void __attribute__ ((unused))
 connected_log (struct connected *connected, char *str)
 {
   struct prefix *p;
@@ -637,7 +637,7 @@ connected_log (struct connected *connected, char *str)
 }
 
 /* If two connected address has same prefix return 1. */
-int
+static int
 connected_same_prefix (struct prefix *p1, struct prefix *p2)
 {
   if (p1->family == p2->family)
@@ -767,13 +767,16 @@ if_indextoname (unsigned int ifindex, char *name)
 }
 #endif
 
+#if 0 /* this route_table of struct connected's is unused
+       * however, it would be good to use a route_table rather than
+       * a list..
+       */
 /* Interface looking up by interface's address. */
-
 /* Interface's IPv4 address reverse lookup table. */
 struct route_table *ifaddr_ipv4_table;
 /* struct route_table *ifaddr_ipv6_table; */
 
-void
+static void
 ifaddr_ipv4_add (struct in_addr *ifaddr, struct interface *ifp)
 {
   struct route_node *rn;
@@ -794,7 +797,7 @@ ifaddr_ipv4_add (struct in_addr *ifaddr, struct interface *ifp)
   rn->info = ifp;
 }
 
-void
+static void
 ifaddr_ipv4_delete (struct in_addr *ifaddr, struct interface *ifp)
 {
   struct route_node *rn;
@@ -817,7 +820,7 @@ ifaddr_ipv4_delete (struct in_addr *ifaddr, struct interface *ifp)
 }
 
 /* Lookup interface by interface's IP address or interface index. */
-struct interface *
+static struct interface *
 ifaddr_ipv4_lookup (struct in_addr *addr, unsigned int ifindex)
 {
   struct prefix_ipv4 p;
@@ -841,13 +844,16 @@ ifaddr_ipv4_lookup (struct in_addr *addr, unsigned int ifindex)
   else
     return if_lookup_by_index(ifindex);
 }
+#endif /* ifaddr_ipv4_table */
 
 /* Initialize interface list. */
 void
-if_init ()
+if_init (void)
 {
   iflist = list_new ();
+#if 0
   ifaddr_ipv4_table = route_table_init ();
+#endif /* ifaddr_ipv4_table */
 
   if (iflist) {
     iflist->cmp = (int (*)(void *, void *))if_cmp_func;

+ 26 - 26
lib/if.h

@@ -211,16 +211,16 @@ struct connected
 #endif /* IFF_VIRTUAL */
 
 /* Prototypes. */
-int if_cmp_func (struct interface *, struct interface *);
-struct interface *if_create (const char *name, int namelen);
-struct interface *if_lookup_by_index (unsigned int);
-struct interface *if_lookup_exact_address (struct in_addr);
-struct interface *if_lookup_address (struct in_addr);
+extern int if_cmp_func (struct interface *, struct interface *);
+extern struct interface *if_create (const char *name, int namelen);
+extern struct interface *if_lookup_by_index (unsigned int);
+extern struct interface *if_lookup_exact_address (struct in_addr);
+extern struct interface *if_lookup_address (struct in_addr);
 
 /* These 2 functions are to be used when the ifname argument is terminated
    by a '\0' character: */
-struct interface *if_lookup_by_name (const char *ifname);
-struct interface *if_get_by_name (const char *ifname);
+extern struct interface *if_lookup_by_name (const char *ifname);
+extern struct interface *if_get_by_name (const char *ifname);
 
 /* For these 2 functions, the namelen argument should be the precise length
    of the ifname string (not counting any optional trailing '\0' character).
@@ -239,22 +239,22 @@ extern void if_delete_retain (struct interface *);
    deletes it from the interface list and frees the structure. */
 extern void if_delete (struct interface *);
 
-int if_is_up (struct interface *);
-int if_is_running (struct interface *);
-int if_is_operative (struct interface *);
-int if_is_loopback (struct interface *);
-int if_is_broadcast (struct interface *);
-int if_is_pointopoint (struct interface *);
-int if_is_multicast (struct interface *);
-void if_add_hook (int, int (*)(struct interface *));
-void if_init ();
-void if_dump_all ();
+extern int if_is_up (struct interface *);
+extern int if_is_running (struct interface *);
+extern int if_is_operative (struct interface *);
+extern int if_is_loopback (struct interface *);
+extern int if_is_broadcast (struct interface *);
+extern int if_is_pointopoint (struct interface *);
+extern int if_is_multicast (struct interface *);
+extern void if_add_hook (int, int (*)(struct interface *));
+extern void if_init (void);
+extern void if_dump_all (void);
 extern const char *if_flag_dump(unsigned long);
 
 /* Please use ifindex2ifname instead of if_indextoname where possible;
    ifindex2ifname uses internal interface info, whereas if_indextoname must
    make a system call. */
-extern char *ifindex2ifname (unsigned int);
+extern const char *ifindex2ifname (unsigned int);
 
 /* Please use ifname2ifindex instead of if_nametoindex where possible;
    ifname2ifindex uses internal interface info, whereas if_nametoindex must
@@ -262,22 +262,22 @@ extern char *ifindex2ifname (unsigned int);
 extern unsigned int ifname2ifindex(const char *ifname);
 
 /* Connected address functions. */
-struct connected *connected_new ();
-void connected_free (struct connected *);
-void connected_add (struct interface *, struct connected *);
-struct connected  *connected_add_by_prefix (struct interface *,
+extern struct connected *connected_new (void);
+extern void connected_free (struct connected *);
+extern void connected_add (struct interface *, struct connected *);
+extern struct connected  *connected_add_by_prefix (struct interface *,
                                             struct prefix *,
                                             struct prefix *);
-struct connected  *connected_delete_by_prefix (struct interface *, 
+extern struct connected  *connected_delete_by_prefix (struct interface *, 
                                                struct prefix *);
-struct connected  *connected_lookup_address (struct interface *, 
+extern struct connected  *connected_lookup_address (struct interface *, 
                                              struct in_addr);
 
 #ifndef HAVE_IF_NAMETOINDEX
-unsigned int if_nametoindex (const char *);
+extern unsigned int if_nametoindex (const char *);
 #endif
 #ifndef HAVE_IF_INDEXTONAME
-char *if_indextoname (unsigned int, char *);
+extern char *if_indextoname (unsigned int, char *);
 #endif
 
 /* Exported variables. */

+ 19 - 15
lib/if_rmap.c

@@ -30,11 +30,11 @@
 struct hash *ifrmaphash;
 
 /* Hook functions. */
-void (*if_rmap_add_hook) (struct if_rmap *) = NULL;
-void (*if_rmap_delete_hook) (struct if_rmap *) = NULL;
+static void (*if_rmap_add_hook) (struct if_rmap *) = NULL;
+static void (*if_rmap_delete_hook) (struct if_rmap *) = NULL;
 
-struct if_rmap *
-if_rmap_new ()
+static struct if_rmap *
+if_rmap_new (void)
 {
   struct if_rmap *new;
 
@@ -43,7 +43,7 @@ if_rmap_new ()
   return new;
 }
 
-void
+static void
 if_rmap_free (struct if_rmap *if_rmap)
 {
   if (if_rmap->ifname)
@@ -83,18 +83,19 @@ if_rmap_hook_delete (void (*func) (struct if_rmap *))
   if_rmap_delete_hook = func;
 }
 
-void *
-if_rmap_hash_alloc (struct if_rmap *arg)
+static void *
+if_rmap_hash_alloc (void *arg)
 {
+  struct if_rmap *ifarg = arg;
   struct if_rmap *if_rmap;
 
   if_rmap = if_rmap_new ();
-  if_rmap->ifname = strdup (arg->ifname);
+  if_rmap->ifname = strdup (ifarg->ifname);
 
   return if_rmap;
 }
 
-struct if_rmap *
+static struct if_rmap *
 if_rmap_get (const char *ifname)
 {
   struct if_rmap key;
@@ -105,9 +106,10 @@ if_rmap_get (const char *ifname)
   return (struct if_rmap *) hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
 }
 
-unsigned int
-if_rmap_hash_make (struct if_rmap *if_rmap)
+static unsigned int
+if_rmap_hash_make (void *data)
 {
+  struct if_rmap *if_rmap = data;
   unsigned int i, key;
 
   key = 0;
@@ -117,15 +119,17 @@ if_rmap_hash_make (struct if_rmap *if_rmap)
   return key;
 }
 
-int
-if_rmap_hash_cmp (struct if_rmap *if_rmap1, struct if_rmap *if_rmap2)
+static int
+if_rmap_hash_cmp (void *arg1, void* arg2)
 {
+  struct if_rmap *if_rmap1 = arg1;
+  struct if_rmap *if_rmap2 = arg2;
   if (strcmp (if_rmap1->ifname, if_rmap2->ifname) == 0)
     return 1;
   return 0;
 }
 
-struct if_rmap *
+static struct if_rmap *
 if_rmap_set (const char *ifname, enum if_rmap_type type, 
              const char *routemap_name)
 {
@@ -152,7 +156,7 @@ if_rmap_set (const char *ifname, enum if_rmap_type type,
   return if_rmap;
 }
 
-int
+static int
 if_rmap_unset (const char *ifname, enum if_rmap_type type, 
                const char *routemap_name)
 {

+ 6 - 6
lib/if_rmap.h

@@ -37,11 +37,11 @@ struct if_rmap
   char *routemap[IF_RMAP_MAX];
 };
 
-void if_rmap_init (int);
-void if_rmap_reset (void);
-void if_rmap_hook_add (void (*) (struct if_rmap *));
-void if_rmap_hook_delete (void (*) (struct if_rmap *));
-struct if_rmap *if_rmap_lookup (const char *);
-int config_write_if_rmap (struct vty *);
+extern void if_rmap_init (int);
+extern void if_rmap_reset (void);
+extern void if_rmap_hook_add (void (*) (struct if_rmap *));
+extern void if_rmap_hook_delete (void (*) (struct if_rmap *));
+extern struct if_rmap *if_rmap_lookup (const char *);
+extern int config_write_if_rmap (struct vty *);
 
 #endif /* _ZEBRA_IF_RMAP_H */

+ 5 - 5
lib/jhash.h

@@ -24,12 +24,12 @@
  * of bytes.  No alignment or length assumptions are made about
  * the input key.
  */
-u_int32_t jhash(void *key, u_int32_t length, u_int32_t initval);
+extern u_int32_t jhash(void *key, u_int32_t length, u_int32_t initval);
 
 /* A special optimized version that handles 1 or more of u_int32_ts.
  * The length parameter here is the number of u_int32_ts in the key.
  */
-u_int32_t jhash2(u_int32_t *k, u_int32_t length, u_int32_t initval);
+extern u_int32_t jhash2(u_int32_t *k, u_int32_t length, u_int32_t initval);
 
 /* A special ultra-optimized versions that knows they are hashing exactly
  * 3, 2 or 1 word(s).
@@ -37,8 +37,8 @@ u_int32_t jhash2(u_int32_t *k, u_int32_t length, u_int32_t initval);
  * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
  *       done at the end is not done here.
  */
-u_int32_t jhash_3words(u_int32_t a, u_int32_t b, u_int32_t c, u_int32_t initval);
-u_int32_t jhash_2words(u_int32_t a, u_int32_t b, u_int32_t initval);
-u_int32_t jhash_1word(u_int32_t a, u_int32_t initval);
+extern u_int32_t jhash_3words(u_int32_t a, u_int32_t b, u_int32_t c, u_int32_t initval);
+extern u_int32_t jhash_2words(u_int32_t a, u_int32_t b, u_int32_t initval);
+extern u_int32_t jhash_1word(u_int32_t a, u_int32_t initval);
 
 #endif /* _QUAGGA_JHASH_H */

+ 41 - 36
lib/keychain.c

@@ -28,8 +28,8 @@ Boston, MA 02111-1307, USA.  */
 /* Master list of key chain. */
 struct list *keychain_list;
 
-struct keychain *
-keychain_new ()
+static struct keychain *
+keychain_new (void)
 {
   struct keychain *new;
   new = XMALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain));
@@ -37,14 +37,14 @@ keychain_new ()
   return new;
 }
 
-void
+static void
 keychain_free (struct keychain *keychain)
 {
   XFREE (MTYPE_KEYCHAIN, keychain);
 }
 
-struct key *
-key_new ()
+static struct key *
+key_new (void)
 {
   struct key *new;
   new = XMALLOC (MTYPE_KEY, sizeof (struct key));
@@ -52,7 +52,7 @@ key_new ()
   return new;
 }
 
-void
+static void
 key_free (struct key *key)
 {
   XFREE (MTYPE_KEY, key);
@@ -75,9 +75,12 @@ keychain_lookup (const char *name)
   return NULL;
 }
 
-int
-key_cmp_func (const struct key *k1, const struct key *k2)
+static int
+key_cmp_func (void *arg1, void *arg2)
 {
+  const struct key *k1 = arg1;
+  const struct key *k2 = arg2;
+  
   if (k1->index > k2->index)
     return 1;
   if (k1->index < k2->index)
@@ -85,7 +88,7 @@ key_cmp_func (const struct key *k1, const struct key *k2)
   return 0;
 }
 
-void
+static void
 key_delete_func (struct key *key)
 {
   if (key->string)
@@ -93,7 +96,7 @@ key_delete_func (struct key *key)
   key_free (key);
 }
 
-struct keychain *
+static struct keychain *
 keychain_get (const char *name)
 {
   struct keychain *keychain;
@@ -113,7 +116,7 @@ keychain_get (const char *name)
   return keychain;
 }
 
-void
+static void
 keychain_delete (struct keychain *keychain)
 {
   if (keychain->name)
@@ -124,7 +127,7 @@ keychain_delete (struct keychain *keychain)
   keychain_free (keychain);
 }
 
-struct key *
+static struct key *
 key_lookup (const struct keychain *keychain, u_int32_t index)
 {
   struct listnode *node;
@@ -203,7 +206,7 @@ key_lookup_for_send (const struct keychain *keychain)
   return NULL;
 }
 
-struct key *
+static struct key *
 key_get (const struct keychain *keychain, u_int32_t index)
 {
   struct key *key;
@@ -220,7 +223,7 @@ key_get (const struct keychain *keychain, u_int32_t index)
   return key;
 }
 
-void
+static void
 key_delete (struct keychain *keychain, struct key *key)
 {
   listnode_delete (keychain->key, key);
@@ -356,7 +359,7 @@ DEFUN (no_key_string,
 
 /* Convert HH:MM:SS MON DAY YEAR to time_t value.  -1 is returned when
    given string is malformed. */
-time_t 
+static time_t 
 key_str2time (const char *time_str, const char *day_str, const char *month_str,
 	      const char *year_str)
 {
@@ -366,7 +369,6 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
   time_t time;
   unsigned int sec, min, hour;
   unsigned int day, month, year;
-  char *endptr = NULL;
 
   const char *month_name[] = 
   {
@@ -385,6 +387,18 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
     NULL
   };
 
+#define GET_LONG_RANGE(V,STR,MIN,MAX) \
+{ \
+  unsigned long tmpl; \
+  char *endptr = NULL; \
+  tmpl = strtoul ((STR), &endptr, 10); \
+  if (*endptr != '\0' || tmpl == ULONG_MAX) \
+    return -1; \
+  if ( tmpl < (MIN) || tmpl > (MAX)) \
+    return -1; \
+  (V) = tmpl; \
+}
+      
   /* Check hour field of time_str. */
   colon = strchr (time_str, ':');
   if (colon == NULL)
@@ -392,9 +406,7 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
   *colon = '\0';
 
   /* Hour must be between 0 and 23. */
-  hour = strtoul (time_str, &endptr, 10);
-  if (hour == ULONG_MAX || *endptr != '\0' || hour < 0 || hour > 23)
-    return -1;
+  GET_LONG_RANGE (hour, time_str, 0, 23);
 
   /* Check min field of time_str. */
   time_str = colon + 1;
@@ -404,9 +416,7 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
   *colon = '\0';
 
   /* Min must be between 0 and 59. */
-  min = strtoul (time_str, &endptr, 10);
-  if (min == ULONG_MAX || *endptr != '\0' || min < 0 || min > 59)
-    return -1;
+  GET_LONG_RANGE (min, time_str, 0, 59);
 
   /* Check sec field of time_str. */
   time_str = colon + 1;
@@ -414,14 +424,10 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
     return -1;
   
   /* Sec must be between 0 and 59. */
-  sec = strtoul (time_str, &endptr, 10);
-  if (sec == ULONG_MAX || *endptr != '\0' || sec < 0 || sec > 59)
-    return -1;
+  GET_LONG_RANGE (sec, time_str, 0, 59);
   
   /* Check day_str.  Day must be <1-31>. */
-  day = strtoul (day_str, &endptr, 10);
-  if (day == ULONG_MAX || *endptr != '\0' || day < 0 || day > 31)
-    return -1;
+  GET_LONG_RANGE (day, day_str, 1, 31);
 
   /* Check month_str.  Month must match month_name. */
   month = 0;
@@ -436,9 +442,7 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
     return -1;
 
   /* Check year_str.  Year must be <1993-2035>. */
-  year = strtoul (year_str, &endptr, 10);
-  if (year == ULONG_MAX || *endptr != '\0' || year < 1993 || year > 2035)
-    return -1;
+  GET_LONG_RANGE (year, year_str, 1993, 2035);
   
   memset (&tm, 0, sizeof (struct tm));
   tm.tm_sec = sec;
@@ -451,9 +455,10 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
   time = mktime (&tm);
   
   return time;
+#undef GET_LONG_RANGE
 }
 
-int
+static int
 key_lifetime_set (struct vty *vty, struct key_range *krange,
 		  const char *stime_str, const char *sday_str,
 		  const char *smonth_str, const char *syear_str,
@@ -489,7 +494,7 @@ key_lifetime_set (struct vty *vty, struct key_range *krange,
   return CMD_SUCCESS;
 }
 
-int
+static int
 key_lifetime_duration_set (struct vty *vty, struct key_range *krange,
 			   const char *stime_str, const char *sday_str,
 			   const char *smonth_str, const char *syear_str,
@@ -513,7 +518,7 @@ key_lifetime_duration_set (struct vty *vty, struct key_range *krange,
   return CMD_SUCCESS;
 }
 
-int
+static int
 key_lifetime_infinite_set (struct vty *vty, struct key_range *krange,
 			   const char *stime_str, const char *sday_str,
 			   const char *smonth_str, const char *syear_str)
@@ -863,7 +868,7 @@ struct cmd_node keychain_key_node =
   1
 };
 
-int
+static int
 keychain_strftime (char *buf, int bufsiz, time_t *time)
 {
   struct tm *tm;
@@ -876,7 +881,7 @@ keychain_strftime (char *buf, int bufsiz, time_t *time)
   return len;
 }
 
-int
+static int
 keychain_config_write (struct vty *vty)
 {
   struct keychain *keychain;

+ 5 - 5
lib/keychain.h

@@ -47,10 +47,10 @@ struct key
   struct key_range accept;
 };
 
-void keychain_init ();
-struct keychain *keychain_lookup (const char *);
-struct key *key_lookup_for_accept (const struct keychain *, u_int32_t);
-struct key *key_match_for_accept (const struct keychain *, const char *);
-struct key *key_lookup_for_send (const struct keychain *);
+extern void keychain_init (void);
+extern struct keychain *keychain_lookup (const char *);
+extern struct key *key_lookup_for_accept (const struct keychain *, u_int32_t);
+extern struct key *key_match_for_accept (const struct keychain *, const char *);
+extern struct key *key_lookup_for_send (const struct keychain *);
 
 #endif /* _ZEBRA_KEYCHAIN_H */

+ 2 - 2
lib/linklist.c

@@ -26,7 +26,7 @@
 
 /* Allocate new list. */
 struct list *
-list_new ()
+list_new (void)
 {
   struct list *new;
 
@@ -44,7 +44,7 @@ list_free (struct list *l)
 
 /* Allocate new listnode.  Internal use only. */
 static struct listnode *
-listnode_new ()
+listnode_new (void)
 {
   struct listnode *node;
 

+ 14 - 14
lib/linklist.h

@@ -62,26 +62,26 @@ struct list
 #define listgetdata(X) (assert((X)->data != NULL), (X)->data)
 
 /* Prototypes. */
-struct list *list_new(); /* encouraged: set list.del callback on new lists */
-void list_free (struct list *);
+extern struct list *list_new(void); /* encouraged: set list.del callback on new lists */
+extern void list_free (struct list *);
 
-void listnode_add (struct list *, void *);
-void listnode_add_sort (struct list *, void *);
-void listnode_add_after (struct list *, struct listnode *, void *);
-void listnode_delete (struct list *, void *);
-struct listnode *listnode_lookup (struct list *, void *);
-void *listnode_head (struct list *);
+extern void listnode_add (struct list *, void *);
+extern void listnode_add_sort (struct list *, void *);
+extern void listnode_add_after (struct list *, struct listnode *, void *);
+extern void listnode_delete (struct list *, void *);
+extern struct listnode *listnode_lookup (struct list *, void *);
+extern void *listnode_head (struct list *);
 
-void list_delete (struct list *);
-void list_delete_all_node (struct list *);
+extern void list_delete (struct list *);
+extern void list_delete_all_node (struct list *);
 
 /* For ospfd and ospf6d. */
-void list_delete_node (struct list *, struct listnode *);
+extern void list_delete_node (struct list *, struct listnode *);
 
 /* For ospf_spf.c */
-void list_add_node_prev (struct list *, struct listnode *, void *);
-void list_add_node_next (struct list *, struct listnode *, void *);
-void list_add_list (struct list *, struct list *);
+extern void list_add_node_prev (struct list *, struct listnode *, void *);
+extern void list_add_node_next (struct list *, struct listnode *, void *);
+extern void list_add_list (struct list *, struct list *);
 
 /* List iteration macro. 
  * Usage: for (ALL_LIST_ELEMENTS (...) { ... }

+ 21 - 21
lib/log.h

@@ -1,5 +1,5 @@
 /*
- * $Id: log.h,v 1.17 2005/01/18 22:18:59 ajs Exp $
+ * $Id: log.h,v 1.18 2005/05/06 21:25:49 paul Exp $
  *
  * Zebra logging funcions.
  * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
@@ -96,11 +96,11 @@ struct message
 extern struct zlog *zlog_default;
 
 /* Open zlog function */
-struct zlog *openzlog (const char *progname, zlog_proto_t protocol,
-		       int syslog_options, int syslog_facility);
+extern struct zlog *openzlog (const char *progname, zlog_proto_t protocol,
+		              int syslog_options, int syslog_facility);
 
 /* Close zlog function. */
-void closezlog (struct zlog *zl);
+extern void closezlog (struct zlog *zl);
 
 /* GCC have printf type attribute check.  */
 #ifdef __GNUC__
@@ -110,41 +110,41 @@ void closezlog (struct zlog *zl);
 #endif /* __GNUC__ */
 
 /* Generic function for zlog. */
-void zlog (struct zlog *zl, int priority, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
+extern void zlog (struct zlog *zl, int priority, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
 
 /* Handy zlog functions. */
-void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
+extern void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
+extern void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
+extern void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
+extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
+extern void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
 
 /* For bgpd's peer oriented log. */
-void plog_err (struct zlog *, const char *format, ...);
-void plog_warn (struct zlog *, const char *format, ...);
-void plog_info (struct zlog *, const char *format, ...);
-void plog_notice (struct zlog *, const char *format, ...);
-void plog_debug (struct zlog *, const char *format, ...);
+extern void plog_err (struct zlog *, const char *format, ...);
+extern void plog_warn (struct zlog *, const char *format, ...);
+extern void plog_info (struct zlog *, const char *format, ...);
+extern void plog_notice (struct zlog *, const char *format, ...);
+extern void plog_debug (struct zlog *, const char *format, ...);
 
 /* Set logging level for the given destination.  If the log_level
    argument is ZLOG_DISABLED, then the destination is disabled.
    This function should not be used for file logging (use zlog_set_file
    or zlog_reset_file instead). */
-void zlog_set_level (struct zlog *zl, zlog_dest_t, int log_level);
+extern void zlog_set_level (struct zlog *zl, zlog_dest_t, int log_level);
 
 /* Set logging to the given filename at the specified level. */
-int zlog_set_file (struct zlog *zl, const char *filename, int log_level);
+extern int zlog_set_file (struct zlog *zl, const char *filename, int log_level);
 /* Disable file logging. */
-int zlog_reset_file (struct zlog *zl);
+extern int zlog_reset_file (struct zlog *zl);
 
 /* Rotate log. */
-int zlog_rotate (struct zlog *);
+extern int zlog_rotate (struct zlog *);
 
 /* For hackey massage lookup and check */
 #define LOOKUP(x, y) mes_lookup(x, x ## _max, y)
 
-const char *lookup (struct message *, int);
-const char *mes_lookup (struct message *meslist, int max, int index);
+extern const char *lookup (struct message *, int);
+extern const char *mes_lookup (struct message *meslist, int max, int index);
 
 extern const char *zlog_priority[];
 extern const char *zlog_proto_names[];

+ 7 - 23
lib/md5.c

@@ -69,8 +69,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
 /* Initialize structure containing state of computation.
    (RFC 1321, 3.3: Step 3)  */
 void
-md5_init_ctx (ctx)
-     struct md5_ctx *ctx;
+md5_init_ctx (struct md5_ctx *ctx)
 {
   ctx->A = 0x67452301;
   ctx->B = 0xefcdab89;
@@ -87,9 +86,7 @@ md5_init_ctx (ctx)
    IMPORTANT: On some systems it is required that RESBUF is correctly
    aligned for a 32 bits value.  */
 void *
-md5_read_ctx (ctx, resbuf)
-     const struct md5_ctx *ctx;
-     void *resbuf;
+md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
 {
   ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A);
   ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B);
@@ -105,9 +102,7 @@ md5_read_ctx (ctx, resbuf)
    IMPORTANT: On some systems it is required that RESBUF is correctly
    aligned for a 32 bits value.  */
 void *
-md5_finish_ctx (ctx, resbuf)
-     struct md5_ctx *ctx;
-     void *resbuf;
+md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
 {
   /* Take yet unprocessed bytes into account.  */
   md5_uint32 bytes = ctx->buflen;
@@ -136,9 +131,7 @@ md5_finish_ctx (ctx, resbuf)
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
 int
-md5_stream (stream, resblock)
-     FILE *stream;
-     void *resblock;
+md5_stream (FILE *stream, void *resblock)
 {
   /* Important: BLOCKSIZE must be a multiple of 64.  */
 #define BLOCKSIZE 4096
@@ -193,10 +186,7 @@ md5_stream (stream, resblock)
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-md5_buffer (buffer, len, resblock)
-     const char *buffer;
-     size_t len;
-     void *resblock;
+md5_buffer (const char *buffer, size_t len, void *resblock)
 {
   struct md5_ctx ctx;
 
@@ -212,10 +202,7 @@ md5_buffer (buffer, len, resblock)
 
 
 void
-md5_process_bytes (buffer, len, ctx)
-     const void *buffer;
-     size_t len;
-     struct md5_ctx *ctx;
+md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
 {
   /* When we already have some bits in our internal buffer concatenate
      both inputs first.  */
@@ -270,10 +257,7 @@ md5_process_bytes (buffer, len, ctx)
    It is assumed that LEN % 64 == 0.  */
 
 void
-md5_process_block (buffer, len, ctx)
-     const void *buffer;
-     size_t len;
-     struct md5_ctx *ctx;
+md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
 {
   md5_uint32 correct_words[16];
   const md5_uint32 *words = buffer;

+ 1 - 1
lib/memory.c

@@ -40,7 +40,7 @@ static struct message mstr [] =
 };
 
 /* Fatal memory allocation error occured. */
-static void
+static void __attribute__ ((noreturn))
 zerror (const char *fname, int type, size_t size)
 {
   zlog_err ("%s : can't allocate memory for `%s' size %d: %s\n", 

+ 20 - 33
lib/memory.h

@@ -58,38 +58,25 @@ extern struct mlist mlists[];
 #endif /* MEMORY_LOG */
 
 /* Prototypes of memory function. */
-void *zmalloc (int type, size_t size);
-void *zcalloc (int type, size_t size);
-void *zrealloc (int type, void *ptr, size_t size);
-void  zfree (int type, void *ptr);
-char *zstrdup (int type, const char *str);
-
-void *mtype_zmalloc (const char *file,
-		     int line,
-		     int type,
-		     size_t size);
-
-void *mtype_zcalloc (const char *file,
-		     int line,
-		     int type,
-		     size_t num,
-		     size_t size);
-
-void *mtype_zrealloc (const char *file,
-		     int line,
-		     int type, 
-		     void *ptr,
-		     size_t size);
-
-void mtype_zfree (const char *file,
-		  int line,
-		  int type,
-		  void *ptr);
-
-char *mtype_zstrdup (const char *file,
-		     int line,
-		     int type,
-		     const char *str);
-void memory_init (void);
+extern void *zmalloc (int type, size_t size);
+extern void *zcalloc (int type, size_t size);
+extern void *zrealloc (int type, void *ptr, size_t size);
+extern void  zfree (int type, void *ptr);
+extern char *zstrdup (int type, const char *str);
+
+extern void *mtype_zmalloc (const char *file, int line, int type, size_t size);
+
+extern void *mtype_zcalloc (const char *file, int line, int type, 
+                            size_t num, size_t size);
+
+extern void *mtype_zrealloc (const char *file, int line, int type, void *ptr,
+		             size_t size);
+
+extern void mtype_zfree (const char *file, int line, int type,
+		         void *ptr);
+
+extern char *mtype_zstrdup (const char *file, int line, int type,
+		            const char *str);
+extern void memory_init (void);
 
 #endif /* _ZEBRA_MEMORY_H */

+ 2 - 2
lib/network.h

@@ -26,8 +26,8 @@
 /* Both readn and writen are deprecated and will be removed.  They are not
    suitable for use with non-blocking file descriptors.
  */
-int readn (int, u_char *, int);
-int writen (int, const u_char *, int);
+extern int readn (int, u_char *, int);
+extern int writen (int, const u_char *, int);
 
 /* Set the file descriptor to use non-blocking I/O.  Returns 0 for success,
    -1 on error. */

+ 13 - 13
lib/plist.c

@@ -72,10 +72,10 @@ struct prefix_master
   struct prefix_list *recent;
 
   /* Hook function which is executed when new prefix_list is added. */
-  void (*add_hook) ();
+  void (*add_hook) (struct prefix_list *);
 
   /* Hook function which is executed when prefix_list is deleted. */
-  void (*delete_hook) ();
+  void (*delete_hook) (struct prefix_list *);
 };
 
 /* Static structure of IPv4 prefix_list's master. */
@@ -150,7 +150,7 @@ prefix_list_lookup (afi_t afi, const char *name)
 }
 
 static struct prefix_list *
-prefix_list_new ()
+prefix_list_new (void)
 {
   struct prefix_list *new;
 
@@ -165,7 +165,7 @@ prefix_list_free (struct prefix_list *plist)
 }
 
 static struct prefix_list_entry *
-prefix_list_entry_new ()
+prefix_list_entry_new (void)
 {
   struct prefix_list_entry *new;
 
@@ -326,11 +326,11 @@ prefix_list_delete (struct prefix_list *plist)
 
   if (plist->name)
     XFREE (MTYPE_PREFIX_LIST_STR, plist->name);
-
+  
   prefix_list_free (plist);
-
+  
   if (master->delete_hook)
-    (*master->delete_hook) ();
+    (*master->delete_hook) (NULL);
 }
 
 static struct prefix_list_entry *
@@ -586,7 +586,7 @@ prefix_list_apply (struct prefix_list *plist, void *object)
   return PREFIX_DENY;
 }
 
-void
+static void __attribute__ ((unused))
 prefix_list_print (struct prefix_list *plist)
 {
   struct prefix_list_entry *pentry;
@@ -2578,7 +2578,7 @@ prefix_bgp_show_prefix_list (struct vty *vty, afi_t afi, char *name)
 }
 
 static void
-prefix_list_reset_orf ()
+prefix_list_reset_orf (void)
 {
   struct prefix_list *plist;
   struct prefix_list *next;
@@ -2625,7 +2625,7 @@ config_write_prefix_ipv4 (struct vty *vty)
 }
 
 static void
-prefix_list_reset_ipv4 ()
+prefix_list_reset_ipv4 (void)
 {
   struct prefix_list *plist;
   struct prefix_list *next;
@@ -2657,7 +2657,7 @@ prefix_list_reset_ipv4 ()
 }
 
 static void
-prefix_list_init_ipv4 ()
+prefix_list_init_ipv4 (void)
 {
   install_node (&prefix_node, config_write_prefix_ipv4);
 
@@ -2734,7 +2734,7 @@ config_write_prefix_ipv6 (struct vty *vty)
 }
 
 static void
-prefix_list_reset_ipv6 ()
+prefix_list_reset_ipv6 (void)
 {
   struct prefix_list *plist;
   struct prefix_list *next;
@@ -2766,7 +2766,7 @@ prefix_list_reset_ipv6 ()
 }
 
 static void
-prefix_list_init_ipv6 ()
+prefix_list_init_ipv6 (void)
 {
   install_node (&prefix_ipv6_node, config_write_prefix_ipv6);
 

+ 17 - 12
lib/plist.h

@@ -20,6 +20,9 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#ifndef _QUAGGA_PLIST_H
+#define _QUAGGA_PLIST_H
+
 #define AFI_ORF_PREFIX 65535
 
 enum prefix_list_type 
@@ -62,17 +65,19 @@ struct orf_prefix
 };
 
 /* Prototypes. */
-void prefix_list_init (void);
-void prefix_list_reset (void);
-void prefix_list_add_hook (void (*func) (struct prefix_list *));
-void prefix_list_delete_hook (void (*func) (struct prefix_list *));
+extern void prefix_list_init (void);
+extern void prefix_list_reset (void);
+extern void prefix_list_add_hook (void (*func) (struct prefix_list *));
+extern void prefix_list_delete_hook (void (*func) (struct prefix_list *));
+
+extern struct prefix_list *prefix_list_lookup (afi_t, const char *);
+extern enum prefix_list_type prefix_list_apply (struct prefix_list *, void *);
 
-struct prefix_list *prefix_list_lookup (afi_t, const char *);
-enum prefix_list_type prefix_list_apply (struct prefix_list *, void *);
+extern struct stream * prefix_bgp_orf_entry (struct stream *,
+                                             struct prefix_list *,
+                                             u_char, u_char, u_char);
+extern int prefix_bgp_orf_set (char *, afi_t, struct orf_prefix *, int, int);
+extern void prefix_bgp_orf_remove_all (char *);
+extern int prefix_bgp_show_prefix_list (struct vty *, afi_t, char *);
 
-struct stream *
-prefix_bgp_orf_entry (struct stream *, struct prefix_list *,
-                      u_char, u_char, u_char);
-int prefix_bgp_orf_set (char *, afi_t, struct orf_prefix *, int, int);
-void prefix_bgp_orf_remove_all (char *);
-int prefix_bgp_show_prefix_list (struct vty *, afi_t, char *);
+#endif /* _QUAGGA_PLIST_H */

+ 1 - 1
lib/pqueue.c

@@ -106,7 +106,7 @@ trickle_down (int index, struct pqueue *queue)
 }
 
 struct pqueue *
-pqueue_create ()
+pqueue_create (void)
 {
   struct pqueue *queue;
 

+ 5 - 5
lib/pqueue.h

@@ -33,12 +33,12 @@ struct pqueue
 
 #define PQUEUE_INIT_ARRAYSIZE  32
 
-struct pqueue *pqueue_create ();
-void pqueue_delete (struct pqueue *queue);
+extern struct pqueue *pqueue_create (void);
+extern void pqueue_delete (struct pqueue *queue);
 
-void pqueue_enqueue (void *data, struct pqueue *queue);
-void *pqueue_dequeue (struct pqueue *queue);
+extern void pqueue_enqueue (void *data, struct pqueue *queue);
+extern void *pqueue_dequeue (struct pqueue *queue);
 
-void trickle_down (int index, struct pqueue *queue);
+extern void trickle_down (int index, struct pqueue *queue);
 
 #endif /* _ZEBRA_PQUEUE_H */

+ 5 - 5
lib/prefix.c

@@ -72,8 +72,8 @@ prefix_match (const struct prefix *n, const struct prefix *p)
   int shift;
 
   /* Set both prefix's head pointer. */
-  u_char *np = (u_char *)&n->u.prefix;
-  u_char *pp = (u_char *)&p->u.prefix;
+  const u_char *np = (const u_char *)&n->u.prefix;
+  const u_char *pp = (const u_char *)&p->u.prefix;
 
   /* If n's prefix is longer than p's one return 0. */
   if (n->prefixlen > p->prefixlen)
@@ -160,8 +160,8 @@ prefix_cmp (const struct prefix *p1, const struct prefix *p2)
   int shift;
 
   /* Set both prefix's head pointer. */
-  u_char *pp1 = (u_char *)&p1->u.prefix;
-  u_char *pp2 = (u_char *)&p2->u.prefix;
+  const u_char *pp1 = (const u_char *)&p1->u.prefix;
+  const u_char *pp2 = (const u_char *)&p2->u.prefix;
 
   if (p1->family != p2->family || p1->prefixlen != p2->prefixlen)
     return 1;
@@ -344,7 +344,7 @@ prefix_ipv4_any (const struct prefix_ipv4 *p)
 
 /* Allocate a new ip version 6 route */
 struct prefix_ipv6 *
-prefix_ipv6_new ()
+prefix_ipv6_new (void)
 {
   struct prefix_ipv6 *p;
 

+ 43 - 40
lib/prefix.h

@@ -23,6 +23,8 @@
 #ifndef _ZEBRA_PREFIX_H
 #define _ZEBRA_PREFIX_H
 
+#include "sockunion.h"
+
 /*
  * A struct prefix contains an address family, a prefix length, and an
  * address.  This can represent either a 'network prefix' as defined
@@ -125,58 +127,59 @@ struct prefix_rd
 #define PREFIX_FAMILY(p)  ((p)->family)
 
 /* Prototypes. */
-int afi2family (int);
-int family2afi (int);
-
-struct prefix *prefix_new ();
-void prefix_free (struct prefix *);
-const char *prefix_family_str (const struct prefix *);
-int prefix_blen (const struct prefix *);
-int str2prefix (const char *, struct prefix *);
-int prefix2str (const struct prefix *, char *, int);
-int prefix_match (const struct prefix *, const struct prefix *);
-int prefix_same (const struct prefix *, const struct prefix *);
-int prefix_cmp (const struct prefix *, const struct prefix *);
-void prefix_copy (struct prefix *dest, const struct prefix *src);
-void apply_mask (struct prefix *);
-
-struct prefix *sockunion2prefix ();
-struct prefix *sockunion2hostprefix ();
-
-struct prefix_ipv4 *prefix_ipv4_new ();
-void prefix_ipv4_free (struct prefix_ipv4 *);
-int str2prefix_ipv4 (const char *, struct prefix_ipv4 *);
-void apply_mask_ipv4 (struct prefix_ipv4 *);
-
-int prefix_ipv4_any (const struct prefix_ipv4 *);
-void apply_classful_mask_ipv4 (struct prefix_ipv4 *);
-
-u_char ip_masklen (struct in_addr);
-void masklen2ip (int, struct in_addr *);
+extern int afi2family (int);
+extern int family2afi (int);
+
+extern struct prefix *prefix_new (void);
+extern void prefix_free (struct prefix *);
+extern const char *prefix_family_str (const struct prefix *);
+extern int prefix_blen (const struct prefix *);
+extern int str2prefix (const char *, struct prefix *);
+extern int prefix2str (const struct prefix *, char *, int);
+extern int prefix_match (const struct prefix *, const struct prefix *);
+extern int prefix_same (const struct prefix *, const struct prefix *);
+extern int prefix_cmp (const struct prefix *, const struct prefix *);
+extern void prefix_copy (struct prefix *dest, const struct prefix *src);
+extern void apply_mask (struct prefix *);
+
+extern struct prefix *sockunion2prefix (const union sockunion *dest,
+                                        const union sockunion *mask);
+extern struct prefix *sockunion2hostprefix (const union sockunion *);
+
+extern struct prefix_ipv4 *prefix_ipv4_new (void);
+extern void prefix_ipv4_free (struct prefix_ipv4 *);
+extern int str2prefix_ipv4 (const char *, struct prefix_ipv4 *);
+extern void apply_mask_ipv4 (struct prefix_ipv4 *);
+
+extern int prefix_ipv4_any (const struct prefix_ipv4 *);
+extern void apply_classful_mask_ipv4 (struct prefix_ipv4 *);
+
+extern u_char ip_masklen (struct in_addr);
+extern void masklen2ip (int, struct in_addr *);
 /* returns the network portion of the host address */
-in_addr_t ipv4_network_addr (in_addr_t hostaddr, int masklen);
+extern in_addr_t ipv4_network_addr (in_addr_t hostaddr, int masklen);
 /* given the address of a host on a network and the network mask length,
  * calculate the broadcast address for that network;
  * special treatment for /31: returns the address of the other host
  * on the network by flipping the host bit */
-in_addr_t ipv4_broadcast_addr (in_addr_t hostaddr, int masklen);
+extern in_addr_t ipv4_broadcast_addr (in_addr_t hostaddr, int masklen);
 
-int netmask_str2prefix_str (const char *, const char *, char *);
+extern int netmask_str2prefix_str (const char *, const char *, char *);
 
 #ifdef HAVE_IPV6
-struct prefix_ipv6 *prefix_ipv6_new ();
-void prefix_ipv6_free (struct prefix_ipv6 *);
-int str2prefix_ipv6 (const char *, struct prefix_ipv6 *);
-void apply_mask_ipv6 (struct prefix_ipv6 *);
+extern struct prefix_ipv6 *prefix_ipv6_new (void);
+extern void prefix_ipv6_free (struct prefix_ipv6 *);
+extern int str2prefix_ipv6 (const char *, struct prefix_ipv6 *);
+extern void apply_mask_ipv6 (struct prefix_ipv6 *);
 
-int ip6_masklen (struct in6_addr);
-void masklen2ip6 (int, struct in6_addr *);
+extern int ip6_masklen (struct in6_addr);
+extern void masklen2ip6 (int, struct in6_addr *);
 
-void str2in6_addr (const char *, struct in6_addr *);
-const char *inet6_ntoa (struct in6_addr);
+extern void str2in6_addr (const char *, struct in6_addr *);
+extern const char *inet6_ntoa (struct in6_addr);
 
 #endif /* HAVE_IPV6 */
 
-int all_digit (const char *);
+extern int all_digit (const char *);
 
 #endif /* _ZEBRA_PREFIX_H */

+ 3 - 3
lib/privs.h

@@ -82,10 +82,10 @@ struct zprivs_ids_t
 };
 
   /* initialise zebra privileges */
-void zprivs_init (struct zebra_privs_t *zprivs);
+extern void zprivs_init (struct zebra_privs_t *zprivs);
   /* drop all and terminate privileges */ 
-void zprivs_terminate (void);
+extern void zprivs_terminate (void);
   /* query for runtime uid's and gid's, eg vty needs this */
-void zprivs_get_ids(struct zprivs_ids_t *);
+extern void zprivs_get_ids(struct zprivs_ids_t *);
 
 #endif /* _ZEBRA_PRIVS_H */

+ 18 - 18
lib/routemap.c

@@ -159,7 +159,7 @@ route_map_lookup_by_name (const char *name)
 
 /* Lookup route map.  If there isn't route map create one and return
    it. */
-struct route_map *
+static struct route_map *
 route_map_get (const char *name)
 {
   struct route_map *map;
@@ -171,7 +171,7 @@ route_map_get (const char *name)
 }
 
 /* Return route map's type string. */
-const static char *
+static const char *
 route_map_type_str (enum route_map_type type)
 {
   switch (type)
@@ -188,7 +188,7 @@ route_map_type_str (enum route_map_type type)
     }
 }
 
-int
+static int
 route_map_empty (struct route_map *map)
 {
   if (map->head == NULL && map->tail == NULL)
@@ -245,7 +245,7 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
     }
 }
 
-int
+static int
 vty_show_route_map (struct vty *vty, const char *name)
 {
   struct route_map *map;
@@ -271,8 +271,8 @@ vty_show_route_map (struct vty *vty, const char *name)
 
 /* New route map allocation. Please note route map's name must be
    specified. */
-struct route_map_index *
-route_map_index_new ()
+static struct route_map_index *
+route_map_index_new (void)
 {
   struct route_map_index *new;
 
@@ -319,7 +319,7 @@ route_map_index_delete (struct route_map_index *index, int notify)
 }
 
 /* Lookup index from route map. */
-struct route_map_index *
+static struct route_map_index *
 route_map_index_lookup (struct route_map *map, enum route_map_type type,
 			int pref)
 {
@@ -333,7 +333,7 @@ route_map_index_lookup (struct route_map *map, enum route_map_type type,
 }
 
 /* Add new index to route map. */
-struct route_map_index *
+static struct route_map_index *
 route_map_index_add (struct route_map *map, enum route_map_type type,
 		     int pref)
 {
@@ -385,7 +385,7 @@ route_map_index_add (struct route_map *map, enum route_map_type type,
 }
 
 /* Get route map index. */
-struct route_map_index *
+static struct route_map_index *
 route_map_index_get (struct route_map *map, enum route_map_type type, 
 		     int pref)
 {
@@ -404,8 +404,8 @@ route_map_index_get (struct route_map *map, enum route_map_type type,
 }
 
 /* New route map rule */
-struct route_map_rule *
-route_map_rule_new ()
+static struct route_map_rule *
+route_map_rule_new (void)
 {
   struct route_map_rule *new;
 
@@ -428,7 +428,7 @@ route_map_install_set (struct route_map_rule_cmd *cmd)
 }
 
 /* Lookup rule command from match list. */
-struct route_map_rule_cmd *
+static struct route_map_rule_cmd *
 route_map_lookup_match (const char *name)
 {
   unsigned int i;
@@ -442,7 +442,7 @@ route_map_lookup_match (const char *name)
 }
 
 /* Lookup rule command from set list. */
-struct route_map_rule_cmd *
+static struct route_map_rule_cmd *
 route_map_lookup_set (const char *name)
 {
   unsigned int i;
@@ -493,7 +493,7 @@ route_map_rule_delete (struct route_map_rule_list *list,
 }
 
 /* strcmp wrapper function which don't crush even argument is NULL. */
-int
+static int
 rulecmp (const char *dst, const char *src)
 {
   if (dst == NULL)
@@ -731,7 +731,7 @@ route_map_delete_set (struct route_map_index *index, const char *set_name,
    We need to make sure our route-map processing matches the above
 */
 
-route_map_result_t
+static route_map_result_t
 route_map_apply_match (struct route_map_rule_list *match_list,
                        struct prefix *prefix, route_map_object_t type,
                        void *object)
@@ -875,7 +875,7 @@ route_map_event_hook (void (*func) (route_map_event_t, const char *))
 }
 
 void
-route_map_init ()
+route_map_init (void)
 {
   /* Make vector for match and set. */
   route_match_vec = vector_init (1);
@@ -1230,7 +1230,7 @@ DEFUN (no_rmap_description,
 }
 
 /* Configuration write function. */
-int
+static int
 route_map_config_write (struct vty *vty)
 {
   struct route_map *map;
@@ -1286,7 +1286,7 @@ struct cmd_node rmap_node =
 
 /* Initialization of route map vector. */
 void
-route_map_init_vty ()
+route_map_init_vty (void)
 {
   /* Install route map top node. */
   install_node (&rmap_node, route_map_config_write);

+ 25 - 31
lib/routemap.h

@@ -150,52 +150,46 @@ struct route_map
 };
 
 /* Prototypes. */
-void route_map_init ();
-void route_map_init_vty ();
+extern void route_map_init (void);
+extern void route_map_init_vty (void);
 
 /* Add match statement to route map. */
-int
-route_map_add_match (struct route_map_index *index,
-		     const char *match_name,
-		     const char *match_arg);
+extern int route_map_add_match (struct route_map_index *index,
+		                const char *match_name,
+		                const char *match_arg);
 
 /* Delete specified route match rule. */
-int
-route_map_delete_match (struct route_map_index *index,
-			const char *match_name,
-			const char *match_arg);
+extern int route_map_delete_match (struct route_map_index *index,
+			           const char *match_name,
+			           const char *match_arg);
 
 /* Add route-map set statement to the route map. */
-int
-route_map_add_set (struct route_map_index *index, 
-		   const char *set_name,
-		   const char *set_arg);
+extern int route_map_add_set (struct route_map_index *index, 
+		              const char *set_name,
+		              const char *set_arg);
 
 /* Delete route map set rule. */
-int
-route_map_delete_set (struct route_map_index *index, const char *set_name,
-		      const char *set_arg);
+extern int route_map_delete_set (struct route_map_index *index,
+                                 const char *set_name,
+                                 const char *set_arg);
 
 /* Install rule command to the match list. */
-void
-route_map_install_match (struct route_map_rule_cmd *cmd);
+extern void route_map_install_match (struct route_map_rule_cmd *cmd);
 
 /* Install rule command to the set list. */
-void
-route_map_install_set (struct route_map_rule_cmd *cmd);
+extern void route_map_install_set (struct route_map_rule_cmd *cmd);
 
 /* Lookup route map by name. */
-struct route_map *
-route_map_lookup_by_name (const char *name);
+extern struct route_map * route_map_lookup_by_name (const char *name);
 
 /* Apply route map to the object. */
-route_map_result_t
-route_map_apply (struct route_map *map, struct prefix *, 
-		 route_map_object_t object_type, void *object);
-
-void route_map_add_hook (void (*func) (const char *));
-void route_map_delete_hook (void (*func) (const char *));
-void route_map_event_hook (void (*func) (route_map_event_t, const char *));
-
+extern route_map_result_t route_map_apply (struct route_map *map,
+                                           struct prefix *,
+                                           route_map_object_t object_type,
+                                           void *object);
+
+extern void route_map_add_hook (void (*func) (const char *));
+extern void route_map_delete_hook (void (*func) (const char *));
+extern void route_map_event_hook (void (*func) (route_map_event_t, const char *));
 
 #endif /* _ZEBRA_ROUTEMAP_H */

+ 2 - 2
lib/sigevent.c

@@ -185,7 +185,7 @@ program_counter(void *context)
 
 #endif /* SA_SIGINFO */
 
-static void
+static void __attribute__ ((noreturn))
 exit_handler(int signo
 #ifdef SA_SIGINFO
 	     , siginfo_t *siginfo, void *context
@@ -200,7 +200,7 @@ exit_handler(int signo
   _exit(128+signo);
 }
 
-static void
+static void __attribute__ ((noreturn))
 core_handler(int signo
 #ifdef SA_SIGINFO
 	     , siginfo_t *siginfo, void *context

+ 2 - 2
lib/sigevent.h

@@ -44,10 +44,10 @@ struct quagga_signal_t
  * - array of quagga_signal_t's describing signals to handle
  *   and handlers to use for each signal
  */
-void signal_init (struct thread_master *m, int sigc, 
+extern void signal_init (struct thread_master *m, int sigc, 
                          struct quagga_signal_t *signals);
 
 /* check whether there are signals to handle, process any found */
-int quagga_sigevent_process (void);
+extern int quagga_sigevent_process (void);
 
 #endif /* _QUAGGA_SIGNAL_H */

+ 12 - 11
lib/smux.h

@@ -144,16 +144,17 @@ struct trap_object
     (u_char *) &snmp_in_addr_val \
   )
 
-void smux_init (struct thread_master *tm);
-void smux_start (void);
-void smux_register_mib(const char *, struct variable *, size_t, int, oid [], size_t);
-int smux_header_generic (struct variable *, oid [], size_t *, int, size_t *, 
-    WriteMethod **);
-int smux_trap (oid *, size_t, oid *, size_t, struct trap_object *, size_t, unsigned int, u_char);
-
-int oid_compare (oid *, int, oid *, int);
-void oid2in_addr (oid [], int, struct in_addr *);
-void *oid_copy (void *, void *, size_t);
-void oid_copy_addr (oid [], struct in_addr *, int);
+extern void smux_init (struct thread_master *tm);
+extern void smux_start (void);
+extern void smux_register_mib(const char *, struct variable *, 
+                              size_t, int, oid [], size_t);
+extern int smux_header_generic (struct variable *, oid [], size_t *, 
+                                int, size_t *, WriteMethod **);
+extern int smux_trap (oid *, size_t, oid *, size_t, struct trap_object *, 
+                      size_t, unsigned int, u_char);
+extern int oid_compare (oid *, int, oid *, int);
+extern void oid2in_addr (oid [], int, struct in_addr *);
+extern void *oid_copy (void *, void *, size_t);
+extern void oid_copy_addr (oid [], struct in_addr *, int);
 
 #endif /* _ZEBRA_SNMP_H */

+ 15 - 16
lib/sockopt.h

@@ -22,15 +22,15 @@
 #ifndef _ZEBRA_SOCKOPT_H
 #define _ZEBRA_SOCKOPT_H
 
-int setsockopt_so_recvbuf (int sock, int size);
+extern int setsockopt_so_recvbuf (int sock, int size);
 
 #ifdef HAVE_IPV6
-int setsockopt_ipv6_pktinfo (int, int);
-int setsockopt_ipv6_checksum (int, int);
-int setsockopt_ipv6_multicast_hops (int, int);
-int setsockopt_ipv6_unicast_hops (int, int);
-int setsockopt_ipv6_hoplimit (int, int);
-int setsockopt_ipv6_multicast_loop (int, int);
+extern int setsockopt_ipv6_pktinfo (int, int);
+extern int setsockopt_ipv6_checksum (int, int);
+extern int setsockopt_ipv6_multicast_hops (int, int);
+extern int setsockopt_ipv6_unicast_hops (int, int);
+extern int setsockopt_ipv6_hoplimit (int, int);
+extern int setsockopt_ipv6_multicast_loop (int, int);
 #endif /* HAVE_IPV6 */
 
 /*
@@ -78,20 +78,19 @@ int setsockopt_ipv6_multicast_loop (int, int);
   (((af) == AF_INET) : SOPT_SIZE_CMSG_IFINDEX_IPV4() \
                     ? SOPT_SIZE_CMSG_PKTINFO_IPV6())
 
-int setsockopt_multicast_ipv4(int sock, 
-			     int optname, 
-			     struct in_addr if_addr,
-			     unsigned int mcast_addr,
-			     unsigned int ifindex);
+extern int setsockopt_multicast_ipv4(int sock, int optname, 
+			             struct in_addr if_addr,
+                                     unsigned int mcast_addr,
+			             unsigned int ifindex);
 
 /* Ask for, and get, ifindex, by whatever method is supported. */
-int setsockopt_ifindex (int, int, int);
-int getsockopt_ifindex (int, struct msghdr *);
+extern int setsockopt_ifindex (int, int, int);
+extern int getsockopt_ifindex (int, struct msghdr *);
 
 /* swab the fields in iph between the host order and system order expected 
  * for IP_HDRINCL.
  */
-void sockopt_iphdrincl_swab_htosys (struct ip *iph);
-void sockopt_iphdrincl_swab_systoh (struct ip *iph);
+extern void sockopt_iphdrincl_swab_htosys (struct ip *iph);
+extern void sockopt_iphdrincl_swab_systoh (struct ip *iph);
 
 #endif /*_ZEBRA_SOCKOPT_H */

+ 4 - 4
lib/sockunion.c

@@ -273,7 +273,7 @@ sockunion_accept (int sock, union sockunion *su)
 }
 
 /* Return sizeof union sockunion.  */
-int
+static int
 sockunion_sizeof (union sockunion *su)
 {
   int ret;
@@ -294,7 +294,7 @@ sockunion_sizeof (union sockunion *su)
 }
 
 /* return sockunion structure : this function should be revised. */
-char *
+static char *
 sockunion_log (union sockunion *su)
 {
   static char buf[SU_ADDRSTRLEN];
@@ -662,7 +662,7 @@ sockunion_getpeername (int fd)
 }
 
 /* Print sockunion structure */
-void
+static void __attribute__ ((unused))
 sockunion_print (union sockunion *su)
 {
   if (su == NULL)
@@ -701,7 +701,7 @@ sockunion_print (union sockunion *su)
 }
 
 #ifdef HAVE_IPV6
-int
+static int
 in6addr_cmp (struct in6_addr *addr1, struct in6_addr *addr2)
 {
   unsigned int i;

+ 27 - 27
lib/sockunion.h

@@ -87,42 +87,42 @@ enum connect_result
 #define sockunion_family(X)  (X)->sa.sa_family
 
 /* Prototypes. */
-int str2sockunion (const char *, union sockunion *);
-const char *sockunion2str (union sockunion *, char *, size_t);
-int sockunion_cmp (union sockunion *, union sockunion *);
-int sockunion_same (union sockunion *, union sockunion *);
+extern int str2sockunion (const char *, union sockunion *);
+extern const char *sockunion2str (union sockunion *, char *, size_t);
+extern int sockunion_cmp (union sockunion *, union sockunion *);
+extern int sockunion_same (union sockunion *, union sockunion *);
 
-char *sockunion_su2str (union sockunion *su);
-union sockunion *sockunion_str2su (const char *str);
-struct in_addr sockunion_get_in_addr (union sockunion *su);
-int sockunion_accept (int sock, union sockunion *);
-int sockunion_stream_socket (union sockunion *);
-int sockopt_reuseaddr (int);
-int sockopt_reuseport (int);
-int sockunion_bind (int sock, union sockunion *, unsigned short, union sockunion *);
-int sockopt_ttl (int family, int sock, int ttl);
-int sockunion_socket (union sockunion *su);
-const char *inet_sutop (union sockunion *su, char *str);
-enum connect_result
-sockunion_connect (int fd, union sockunion *su, unsigned short port, unsigned int);
-union sockunion *sockunion_getsockname (int);
-union sockunion *sockunion_getpeername (int);
-union sockunion *sockunion_dup (union sockunion *);
-void sockunion_free (union sockunion *);
+extern char *sockunion_su2str (union sockunion *su);
+extern union sockunion *sockunion_str2su (const char *str);
+extern struct in_addr sockunion_get_in_addr (union sockunion *su);
+extern int sockunion_accept (int sock, union sockunion *);
+extern int sockunion_stream_socket (union sockunion *);
+extern int sockopt_reuseaddr (int);
+extern int sockopt_reuseport (int);
+extern int sockunion_bind (int sock, union sockunion *, 
+                           unsigned short, union sockunion *);
+extern int sockopt_ttl (int family, int sock, int ttl);
+extern int sockunion_socket (union sockunion *su);
+extern const char *inet_sutop (union sockunion *su, char *str);
+extern enum connect_result sockunion_connect (int fd, union sockunion *su, 
+                                              unsigned short port,
+                                              unsigned int);
+extern union sockunion *sockunion_getsockname (int);
+extern union sockunion *sockunion_getpeername (int);
+extern union sockunion *sockunion_dup (union sockunion *);
+extern void sockunion_free (union sockunion *);
 
 #ifndef HAVE_INET_NTOP
-const char *
-inet_ntop (int family, const void *addrptr, char *strptr, size_t len);
+extern const char * inet_ntop (int family, const void *addrptr, 
+                               char *strptr, size_t len);
 #endif /* HAVE_INET_NTOP */
 
 #ifndef HAVE_INET_PTON
-int
-inet_pton (int family, const char *strptr, void *addrptr);
+extern int inet_pton (int family, const char *strptr, void *addrptr);
 #endif /* HAVE_INET_PTON */
 
 #ifndef HAVE_INET_ATON
-int
-inet_aton (const char *cp, struct in_addr *inaddr);
+extern int inet_aton (const char *cp, struct in_addr *inaddr);
 #endif
 
 #endif /* _ZEBRA_SOCKUNION_H */

+ 6 - 5
lib/str.h

@@ -1,12 +1,12 @@
 /*
- * $Id: str.h,v 1.2 2005/04/02 16:01:05 ajs Exp $
+ * $Id: str.h,v 1.3 2005/05/06 21:25:49 paul Exp $
  */
 
 #ifndef _ZEBRA_STR_H
 #define _ZEBRA_STR_H
 
 #ifndef HAVE_SNPRINTF
-int snprintf(char *, size_t, const char *, ...);
+extern int snprintf(char *, size_t, const char *, ...);
 #endif
 
 #ifndef HAVE_VSNPRINTF
@@ -14,15 +14,16 @@ int snprintf(char *, size_t, const char *, ...);
 #endif
 
 #ifndef HAVE_STRLCPY
-size_t strlcpy(char *, const char *, size_t);
+extern size_t strlcpy(char *, const char *, size_t);
 #endif
 
 #ifndef HAVE_STRLCAT
-size_t strlcat(char *, const char *, size_t);
+extern size_t strlcat(char *, const char *, size_t);
 #endif
 
 #ifndef HAVE_STRNLEN
 extern size_t strnlen(const char *s, size_t maxlen);
 #endif
 
-#endif
+#endif /* _ZEBRA_STR_H */
+

+ 52 - 49
lib/stream.h

@@ -128,50 +128,51 @@ struct stream_fifo
 #define STREAM_REMAIN(S) STREAM_WRITEABLE((S))
 
 /* Stream prototypes. */
-struct stream *stream_new (size_t);
-void stream_free (struct stream *);
-struct stream * stream_copy (struct stream *new, struct stream *src);
-struct stream *stream_dup (struct stream *);
-
-size_t stream_get_getp (struct stream *);
-size_t stream_get_endp (struct stream *);
-size_t stream_get_size (struct stream *);
-u_char *stream_get_data (struct stream *);
-
-void stream_set_getp (struct stream *, size_t);
-void stream_forward_getp (struct stream *, size_t);
-void stream_forward_endp (struct stream *, size_t);
-
-void stream_put (struct stream *, void *, size_t); /* NULL source zeroes */
-int stream_putc (struct stream *, u_char);
-int stream_putc_at (struct stream *, size_t, u_char);
-int stream_putw (struct stream *, u_int16_t);
-int stream_putw_at (struct stream *, size_t, u_int16_t);
-int stream_putl (struct stream *, u_int32_t);
-int stream_putl_at (struct stream *, size_t, u_int32_t);
-int stream_put_ipv4 (struct stream *, u_int32_t);
-int stream_put_in_addr (struct stream *, struct in_addr *);
-int stream_put_prefix (struct stream *, struct prefix *);
-
-void stream_get (void *, struct stream *, size_t);
-u_char stream_getc (struct stream *);
-u_char stream_getc_from (struct stream *, size_t);
-u_int16_t stream_getw (struct stream *);
-u_int16_t stream_getw_from (struct stream *, size_t);
-u_int32_t stream_getl (struct stream *);
-u_int32_t stream_getl_from (struct stream *, size_t);
-u_int32_t stream_get_ipv4 (struct stream *);
+extern struct stream *stream_new (size_t);
+extern void stream_free (struct stream *);
+extern struct stream * stream_copy (struct stream *new, struct stream *src);
+extern struct stream *stream_dup (struct stream *);
+
+extern size_t stream_get_getp (struct stream *);
+extern size_t stream_get_endp (struct stream *);
+extern size_t stream_get_size (struct stream *);
+extern u_char *stream_get_data (struct stream *);
+
+extern void stream_set_getp (struct stream *, size_t);
+extern void stream_forward_getp (struct stream *, size_t);
+extern void stream_forward_endp (struct stream *, size_t);
+
+/* steam_put: NULL source zeroes out size_t bytes of stream */
+extern void stream_put (struct stream *, void *, size_t);
+extern int stream_putc (struct stream *, u_char);
+extern int stream_putc_at (struct stream *, size_t, u_char);
+extern int stream_putw (struct stream *, u_int16_t);
+extern int stream_putw_at (struct stream *, size_t, u_int16_t);
+extern int stream_putl (struct stream *, u_int32_t);
+extern int stream_putl_at (struct stream *, size_t, u_int32_t);
+extern int stream_put_ipv4 (struct stream *, u_int32_t);
+extern int stream_put_in_addr (struct stream *, struct in_addr *);
+extern int stream_put_prefix (struct stream *, struct prefix *);
+
+extern void stream_get (void *, struct stream *, size_t);
+extern u_char stream_getc (struct stream *);
+extern u_char stream_getc_from (struct stream *, size_t);
+extern u_int16_t stream_getw (struct stream *);
+extern u_int16_t stream_getw_from (struct stream *, size_t);
+extern u_int32_t stream_getl (struct stream *);
+extern u_int32_t stream_getl_from (struct stream *, size_t);
+extern u_int32_t stream_get_ipv4 (struct stream *);
 
 #undef stream_read
 #undef stream_write
 
 /* Deprecated: assumes blocking I/O.  Will be removed. 
    Use stream_read_try instead.  */
-int stream_read (struct stream *, int, size_t);
+extern int stream_read (struct stream *, int, size_t);
 
 /* Deprecated: all file descriptors should already be non-blocking.
    Will be removed.  Use stream_read_try instead. */
-int stream_read_unblock (struct stream *, int, size_t);
+extern int stream_read_unblock (struct stream *, int, size_t);
 
 /* Read up to size bytes into the stream.
    Return code:
@@ -184,24 +185,26 @@ int stream_read_unblock (struct stream *, int, size_t);
 extern ssize_t stream_read_try(struct stream *s, int fd, size_t size);
 
 extern ssize_t stream_recvmsg (struct stream *s, int fd, struct msghdr *,
-                    int flags, size_t size);
-extern ssize_t stream_recvfrom (struct stream *s, int fd, size_t len, int flags,
-                     struct sockaddr *from, socklen_t *fromlen);
-size_t stream_write (struct stream *, u_char *, size_t);
+                               int flags, size_t size);
+extern ssize_t stream_recvfrom (struct stream *s, int fd, size_t len, 
+                                int flags, struct sockaddr *from, 
+                                socklen_t *fromlen);
+extern size_t stream_write (struct stream *, u_char *, size_t);
 
-void stream_reset (struct stream *); /* reset the stream. See Note above */
-int stream_flush (struct stream *, int);
-int stream_empty (struct stream *); /* is the stream empty? */
+/* reset the stream. See Note above */
+extern void stream_reset (struct stream *);
+extern int stream_flush (struct stream *, int);
+extern int stream_empty (struct stream *); /* is the stream empty? */
 
 /* deprecated */
-u_char *stream_pnt (struct stream *);
+extern u_char *stream_pnt (struct stream *);
 
 /* Stream fifo. */
-struct stream_fifo *stream_fifo_new (void);
-void stream_fifo_push (struct stream_fifo *fifo, struct stream *s);
-struct stream *stream_fifo_pop (struct stream_fifo *fifo);
-struct stream *stream_fifo_head (struct stream_fifo *fifo);
-void stream_fifo_clean (struct stream_fifo *fifo);
-void stream_fifo_free (struct stream_fifo *fifo);
+extern struct stream_fifo *stream_fifo_new (void);
+extern void stream_fifo_push (struct stream_fifo *fifo, struct stream *s);
+extern struct stream *stream_fifo_pop (struct stream_fifo *fifo);
+extern struct stream *stream_fifo_head (struct stream_fifo *fifo);
+extern void stream_fifo_clean (struct stream_fifo *fifo);
+extern void stream_fifo_free (struct stream_fifo *fifo);
 
 #endif /* _ZEBRA_STREAM_H */

+ 5 - 5
lib/table.c

@@ -46,8 +46,8 @@ route_table_finish (struct route_table *rt)
 }
 
 /* Allocate new route node. */
-struct route_node *
-route_node_new ()
+static struct route_node *
+route_node_new (void)
 {
   struct route_node *node;
   node = XCALLOC (MTYPE_ROUTE_NODE, sizeof (struct route_node));
@@ -55,7 +55,7 @@ route_node_new ()
 }
 
 /* Allocate new route node with prefix set. */
-struct route_node *
+static struct route_node *
 route_node_set (struct route_table *table, struct prefix *prefix)
 {
   struct route_node *node;
@@ -69,7 +69,7 @@ route_node_set (struct route_table *table, struct prefix *prefix)
 }
 
 /* Free route node. */
-void
+static void
 route_node_free (struct route_node *node)
 {
   XFREE (MTYPE_ROUTE_NODE, node);
@@ -220,7 +220,7 @@ route_unlock_node (struct route_node *node)
 }
 
 /* Dump routing table. */
-void
+static void __attribute__ ((unused))
 route_dump_node (struct route_table *t)
 {
   struct route_node *node;

+ 17 - 13
lib/table.h

@@ -53,21 +53,25 @@ struct route_node
 };
 
 /* Prototypes. */
-struct route_table *route_table_init (void);
-void route_table_finish (struct route_table *);
-void route_unlock_node (struct route_node *node);
-void route_node_delete (struct route_node *node);
-struct route_node *route_top (struct route_table *);
-struct route_node *route_next (struct route_node *);
-struct route_node *route_next_until (struct route_node *, struct route_node *);
-struct route_node *route_node_get (struct route_table *, struct prefix *);
-struct route_node *route_node_lookup (struct route_table *, struct prefix *);
-struct route_node *route_lock_node (struct route_node *node);
-struct route_node *route_node_match (struct route_table *, struct prefix *);
-struct route_node *route_node_match_ipv4 (struct route_table *,
+extern struct route_table *route_table_init (void);
+extern void route_table_finish (struct route_table *);
+extern void route_unlock_node (struct route_node *node);
+extern void route_node_delete (struct route_node *node);
+extern struct route_node *route_top (struct route_table *);
+extern struct route_node *route_next (struct route_node *);
+extern struct route_node *route_next_until (struct route_node *,
+                                            struct route_node *);
+extern struct route_node *route_node_get (struct route_table *,
+                                          struct prefix *);
+extern struct route_node *route_node_lookup (struct route_table *,
+                                             struct prefix *);
+extern struct route_node *route_lock_node (struct route_node *node);
+extern struct route_node *route_node_match (struct route_table *, 
+                                            struct prefix *);
+extern struct route_node *route_node_match_ipv4 (struct route_table *,
 					  struct in_addr *);
 #ifdef HAVE_IPV6
-struct route_node *route_node_match_ipv6 (struct route_table *,
+extern struct route_node *route_node_match_ipv6 (struct route_table *,
 					  struct in6_addr *);
 #endif /* HAVE_IPV6 */
 

+ 19 - 17
lib/thread.c

@@ -88,7 +88,7 @@ timeval_elapsed (struct timeval a, struct timeval b)
 static unsigned int
 cpu_record_hash_key (struct cpu_thread_history *a)
 {
-  return (unsigned int) a->func;
+  return (uintptr_t) a->func;
 }
 
 static int 
@@ -98,7 +98,7 @@ cpu_record_hash_cmp (struct cpu_thread_history *a,
   return a->func == b->func;
 }
 
-static void*  
+static void *
 cpu_record_hash_alloc (struct cpu_thread_history *a)
 {
   struct cpu_thread_history *new;
@@ -252,7 +252,7 @@ thread_list_debug (struct thread_list *list)
 }
 
 /* Debug print for thread_master. */
-void
+static void  __attribute__ ((unused))
 thread_master_debug (struct thread_master *m)
 {
   printf ("-----------\n");
@@ -277,8 +277,9 @@ struct thread_master *
 thread_master_create ()
 {
   if (cpu_record == NULL) 
-    cpu_record = hash_create_size (1011, cpu_record_hash_key, 
-                                   cpu_record_hash_cmp);
+    cpu_record 
+      = hash_create_size (1011, (unsigned int (*) (void *))cpu_record_hash_key, 
+                          (int (*) (void *, void *))cpu_record_hash_cmp);
     
   return (struct thread_master *) XCALLOC (MTYPE_THREAD_MASTER,
 					   sizeof (struct thread_master));
@@ -375,22 +376,22 @@ thread_master_free (struct thread_master *m)
   XFREE (MTYPE_THREAD_MASTER, m);
 }
 
+/* Thread list is empty or not.  */
+static inline int
+thread_empty (struct thread_list *list)
+{
+  return  list->head ? 0 : 1;
+}
+
 /* Delete top of the list and return it. */
 static struct thread *
 thread_trim_head (struct thread_list *list)
 {
-  if (list->head)
+  if (!thread_empty (list))
     return thread_list_delete (list, list->head);
   return NULL;
 }
 
-/* Thread list is empty or not.  */
-int
-thread_empty (struct thread_list *list)
-{
-  return  list->head ? 0 : 1;
-}
-
 /* Return remain time in second. */
 unsigned long
 thread_timer_remain_second (struct thread *thread)
@@ -437,7 +438,7 @@ thread_get (struct thread_master *m, u_char type,
 {
   struct thread *thread;
 
-  if (m->unuse.head)