summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhasso <hasso>2004-10-05 21:01:23 +0000
committerhasso <hasso>2004-10-05 21:01:23 +0000
commit8c328f1106cf0498333c2d8a96940e7b4581e316 (patch)
tree9bf24cca6a68a9dd5d4dda586484e497d0c19ca6
parent98c91ac6ac085713c00af00a6ac41779be6b50b3 (diff)
Number of warnings is down to 3 again in lib directory. A lot of const's
added to strings and a lot of int -> unsigned int changes.
-rw-r--r--lib/ChangeLog5
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/buffer.c2
-rw-r--r--lib/command.c131
-rw-r--r--lib/command.h16
-rw-r--r--lib/distribute.c7
-rw-r--r--lib/filter.c18
-rw-r--r--lib/filter.h2
-rw-r--r--lib/hash.c4
-rw-r--r--lib/if.c2
-rw-r--r--lib/if_rmap.c5
-rw-r--r--lib/keychain.c43
-rw-r--r--lib/keychain.h8
-rw-r--r--lib/log.c4
-rw-r--r--lib/log.h4
-rw-r--r--lib/plist.c4
-rw-r--r--lib/privs.h6
-rw-r--r--lib/routemap.c6
-rw-r--r--lib/sockunion.c2
-rw-r--r--lib/thread.c18
-rw-r--r--lib/thread.h14
-rw-r--r--lib/vty.c17
-rw-r--r--lib/zclient.c2
-rw-r--r--lib/zclient.h2
24 files changed, 163 insertions, 161 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 5aedc1e2..84cf7fc9 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-05 Hasso Tepper <hasso at quagga.net>
+
+ * *.[c|h]: Make many strings cons and a lot of int -> unsigned int
+ changes to fix warnings.
+
2004-10-05 Paul Jakma <paul@dishone.st>
* sockopt.{c,h}: add sockopt_iphdrincl_swab_{htosys,systoh},
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3b3d5464..9cb25f77 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -29,4 +29,4 @@ EXTRA_DIST = regex.c regex-gnu.h
version.c: Makefile
echo '' >version.c
- echo 'char *host_name = "$(host_alias)";' >>version.c
+ echo 'const char *host_name = "$(host_alias)";' >>version.c
diff --git a/lib/buffer.c b/lib/buffer.c
index 0fffdfd1..6fd9a2bb 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -382,7 +382,7 @@ buffer_flush_vty_all (struct buffer *b, int fd, int erase_flag,
/* Flush buffer to the file descriptor. Mainly used from vty
interface. */
int
-buffer_flush_vty (struct buffer *b, int fd, int size,
+buffer_flush_vty (struct buffer *b, int fd, unsigned int size,
int erase_flag, int no_more_flag)
{
int nbytes;
diff --git a/lib/command.c b/lib/command.c
index a4cf9ebf..c65e6fa8 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -37,7 +37,7 @@ vector cmdvec;
struct host host;
/* Default motd string. */
-char *default_motd =
+const char *default_motd =
"\r\n\
Hello, this is " QUAGGA_PROGNAME " (version " QUAGGA_VERSION ").\r\n\
Copyright 1996-2004 Kunihiro Ishiguro, et al.\r\n\
@@ -142,7 +142,7 @@ cmp_desc (const void *p, const void *q)
void
sort_node ()
{
- int i, j;
+ unsigned int i, j;
struct cmd_node *cnode;
vector descvec;
struct cmd_element *cmd_element;
@@ -218,7 +218,7 @@ cmd_make_strvec (char *string)
void
cmd_free_strvec (vector v)
{
- int i;
+ unsigned int i;
char *cp;
if (!v)
@@ -268,14 +268,14 @@ cmd_desc_str (char **string)
/* New string vector. */
vector
-cmd_make_descvec (char *string, char *descstr)
+cmd_make_descvec (const char *string, const char *descstr)
{
int multiple = 0;
- char *sp;
+ const char *sp;
char *token;
int len;
- char *cp;
- char *dp;
+ const char *cp;
+ const char *dp;
vector allvec;
vector strvec = NULL;
struct desc *desc;
@@ -363,8 +363,7 @@ cmd_make_descvec (char *string, char *descstr)
int
cmd_cmdsize (vector strvec)
{
- int i;
- char *str;
+ unsigned int i;
int size = 0;
vector descvec;
@@ -376,9 +375,7 @@ cmd_cmdsize (vector strvec)
{
struct desc *desc = vector_slot (descvec, 0);
- str = desc->cmd;
-
- if (str == NULL || CMD_OPTION (str))
+ if (desc->cmd == NULL || CMD_OPTION (desc->cmd))
return size;
else
size++;
@@ -390,7 +387,7 @@ cmd_cmdsize (vector strvec)
}
/* Return prompt character of specified node. */
-char *
+const char *
cmd_prompt (enum node_type node)
{
struct cmd_node *cnode;
@@ -448,7 +445,7 @@ char *zencrypt (char *passwd)
return crypt (passwd, salt);
}
-char *
+const char *
syslog_facility_print (int facility)
{
switch (facility)
@@ -639,9 +636,9 @@ enum match_type
};
enum match_type
-cmd_ipv4_match (char *str)
+cmd_ipv4_match (const char *str)
{
- char *sp;
+ const char *sp;
int dots = 0, nums = 0;
char buf[4];
@@ -696,9 +693,9 @@ cmd_ipv4_match (char *str)
}
enum match_type
-cmd_ipv4_prefix_match (char *str)
+cmd_ipv4_prefix_match (const char *str)
{
- char *sp;
+ const char *sp;
int dots = 0;
char buf[4];
@@ -787,11 +784,11 @@ cmd_ipv4_prefix_match (char *str)
#ifdef HAVE_IPV6
enum match_type
-cmd_ipv6_match (char *str)
+cmd_ipv6_match (const char *str)
{
int state = STATE_START;
int colons = 0, nums = 0, double_colon = 0;
- char *sp = NULL;
+ const char *sp = NULL;
struct sockaddr_in6 sin6_dummy;
int ret;
@@ -893,12 +890,12 @@ cmd_ipv6_match (char *str)
}
enum match_type
-cmd_ipv6_prefix_match (char *str)
+cmd_ipv6_prefix_match (const char *str)
{
int state = STATE_START;
int colons = 0, nums = 0, double_colon = 0;
int mask;
- char *sp = NULL;
+ const char *sp = NULL;
char *endptr = NULL;
if (str == NULL)
@@ -1028,7 +1025,7 @@ cmd_ipv6_prefix_match (char *str)
#define DECIMAL_STRLEN_MAX 10
int
-cmd_range_match (char *range, char *str)
+cmd_range_match (const char *range, const char *str)
{
char *p;
char buf[DECIMAL_STRLEN_MAX + 1];
@@ -1074,10 +1071,10 @@ cmd_range_match (char *range, char *str)
/* Make completion match and return match type flag. */
enum match_type
-cmd_filter_by_completion (char *command, vector v, int index)
+cmd_filter_by_completion (char *command, vector v, unsigned int index)
{
- int i;
- char *str;
+ unsigned int i;
+ const char *str;
struct cmd_element *cmd_element;
enum match_type match_type;
vector descvec;
@@ -1093,7 +1090,7 @@ cmd_filter_by_completion (char *command, vector v, int index)
vector_slot (v, i) = NULL;
else
{
- int j;
+ unsigned int j;
int matched = 0;
descvec = vector_slot (cmd_element->strvec, index);
@@ -1189,10 +1186,10 @@ cmd_filter_by_completion (char *command, vector v, int index)
/* Filter vector by command character with index. */
enum match_type
-cmd_filter_by_string (char *command, vector v, int index)
+cmd_filter_by_string (char *command, vector v, unsigned int index)
{
- int i;
- char *str;
+ unsigned int i;
+ const char *str;
struct cmd_element *cmd_element;
enum match_type match_type;
vector descvec;
@@ -1210,7 +1207,7 @@ cmd_filter_by_string (char *command, vector v, int index)
vector_slot (v, i) = NULL;
else
{
- int j;
+ unsigned int j;
int matched = 0;
descvec = vector_slot (cmd_element->strvec, index);
@@ -1299,11 +1296,11 @@ cmd_filter_by_string (char *command, vector v, int index)
int
is_cmd_ambiguous (char *command, vector v, int index, enum match_type type)
{
- int i;
- int j;
- char *str = NULL;
+ unsigned int i;
+ unsigned int j;
+ const char *str = NULL;
struct cmd_element *cmd_element;
- char *matched = NULL;
+ const char *matched = NULL;
vector descvec;
struct desc *desc;
@@ -1393,8 +1390,8 @@ is_cmd_ambiguous (char *command, vector v, int index, enum match_type type)
}
/* If src matches dst return dst string, otherwise return NULL */
-char *
-cmd_entry_function (char *src, char *dst)
+const char *
+cmd_entry_function (const char *src, const char *dst)
{
/* Skip variable arguments. */
if (CMD_OPTION (dst) || CMD_VARIABLE (dst) || CMD_VARARG (dst) ||
@@ -1415,8 +1412,8 @@ cmd_entry_function (char *src, char *dst)
/* If src matches dst return dst string, otherwise return NULL */
/* This version will return the dst string always if it is
CMD_VARIABLE for '?' key processing */
-char *
-cmd_entry_function_desc (char *src, char *dst)
+const char *
+cmd_entry_function_desc (const char *src, const char *dst)
{
if (CMD_VARARG (dst))
return dst;
@@ -1480,9 +1477,9 @@ cmd_entry_function_desc (char *src, char *dst)
/* Check same string element existence. If it isn't there return
1. */
int
-cmd_unique_string (vector v, char *str)
+cmd_unique_string (vector v, const char *str)
{
- int i;
+ unsigned int i;
char *match;
for (i = 0; i < vector_max (v); i++)
@@ -1495,9 +1492,9 @@ cmd_unique_string (vector v, char *str)
/* Compare string to description vector. If there is same string
return 1 else return 0. */
int
-desc_unique_string (vector v, char *str)
+desc_unique_string (vector v, const char *str)
{
- int i;
+ unsigned int i;
struct desc *desc;
for (i = 0; i < vector_max (v); i++)
@@ -1523,12 +1520,12 @@ cmd_try_do_shortcut (enum node_type node, char* first_word) {
vector
cmd_describe_command_real (vector vline, struct vty *vty, int *status)
{
- int i;
+ unsigned int i;
vector cmd_vector;
#define INIT_MATCHVEC_SIZE 10
vector matchvec;
struct cmd_element *cmd_element;
- int index;
+ unsigned int index;
int ret;
enum match_type match;
char *command;
@@ -1554,7 +1551,7 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status)
{
struct cmd_element *cmd_element;
vector descvec;
- int j, k;
+ unsigned int j, k;
for (j = 0; j < vector_max (cmd_vector); j++)
if ((cmd_element = vector_slot (cmd_vector, j)) != NULL)
@@ -1600,7 +1597,7 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status)
for (i = 0; i < vector_max (cmd_vector); i++)
if ((cmd_element = vector_slot (cmd_vector, i)) != NULL)
{
- char *string = NULL;
+ const char *string = NULL;
vector strvec = cmd_element->strvec;
/* if command is NULL, index may be equal to vector_max */
@@ -1617,7 +1614,7 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status)
}
else
{
- int j;
+ unsigned int j;
vector descvec = vector_slot (strvec, index);
struct desc *desc;
@@ -1657,7 +1654,7 @@ cmd_describe_command (vector vline, struct vty *vty, int *status)
{
enum node_type onode;
vector shifted_vline;
- int index;
+ unsigned int index;
onode = vty->node;
vty->node = ENABLE_NODE;
@@ -1719,12 +1716,12 @@ cmd_lcd (char **matched)
char **
cmd_complete_command_real (vector vline, struct vty *vty, int *status)
{
- int i;
+ unsigned int i;
vector cmd_vector = vector_copy (cmd_node_vector (cmdvec, vty->node));
#define INIT_MATCHVEC_SIZE 10
vector matchvec;
struct cmd_element *cmd_element;
- int index = vector_max (vline) - 1;
+ unsigned int index = vector_max (vline) - 1;
char **match_str;
struct desc *desc;
vector descvec;
@@ -1767,7 +1764,7 @@ cmd_complete_command_real (vector vline, struct vty *vty, int *status)
for (i = 0; i < vector_max (cmd_vector); i++)
if ((cmd_element = vector_slot (cmd_vector, i)) != NULL)
{
- char *string;
+ const char *string;
vector strvec = cmd_element->strvec;
/* Check field length */
@@ -1775,7 +1772,7 @@ cmd_complete_command_real (vector vline, struct vty *vty, int *status)
vector_slot (cmd_vector, i) = NULL;
else
{
- int j;
+ unsigned int j;
descvec = vector_slot (strvec, index);
for (j = 0; j < vector_max (descvec); j++)
@@ -1872,7 +1869,7 @@ cmd_complete_command (vector vline, struct vty *vty, int *status)
{
enum node_type onode;
vector shifted_vline;
- int index;
+ unsigned int index;
onode = vty->node;
vty->node = ENABLE_NODE;
@@ -1926,8 +1923,8 @@ enum node_type node_parent ( enum node_type node )
int
cmd_execute_command_real (vector vline, struct vty *vty, struct cmd_element **cmd)
{
- int i;
- int index;
+ unsigned int i;
+ unsigned int index;
vector cmd_vector;
struct cmd_element *cmd_element;
struct cmd_element *matched_element;
@@ -2020,12 +2017,11 @@ cmd_execute_command_real (vector vline, struct vty *vty, struct cmd_element **cm
if (vector_max (descvec) == 1)
{
struct desc *desc = vector_slot (descvec, 0);
- char *str = desc->cmd;
- if (CMD_VARARG (str))
+ if (CMD_VARARG (desc->cmd))
varflag = 1;
- if (varflag || CMD_VARIABLE (str) || CMD_OPTION (str))
+ if (varflag || CMD_VARIABLE (desc->cmd) || CMD_OPTION (desc->cmd))
argv[argc++] = vector_slot (vline, i);
}
else
@@ -2058,7 +2054,7 @@ cmd_execute_command (vector vline, struct vty *vty, struct cmd_element **cmd) {
if ( cmd_try_do_shortcut(vty->node, vector_slot(vline, 0) ) )
{
vector shifted_vline;
- int index;
+ unsigned int index;
vty->node = ENABLE_NODE;
/* We can try it on enable node, cos' the vty is authenticated */
@@ -2106,8 +2102,8 @@ int
cmd_execute_command_strict (vector vline, struct vty *vty,
struct cmd_element **cmd)
{
- int i;
- int index;
+ unsigned int i;
+ unsigned int index;
vector cmd_vector;
struct cmd_element *cmd_element;
struct cmd_element *matched_element;
@@ -2195,12 +2191,11 @@ cmd_execute_command_strict (vector vline, struct vty *vty,
if (vector_max (descvec) == 1)
{
struct desc *desc = vector_slot (descvec, 0);
- char *str = desc->cmd;
- if (CMD_VARARG (str))
+ if (CMD_VARARG (desc->cmd))
varflag = 1;
- if (varflag || CMD_VARIABLE (str) || CMD_OPTION (str))
+ if (varflag || CMD_VARIABLE (desc->cmd) || CMD_OPTION (desc->cmd))
argv[argc++] = vector_slot (vline, i);
}
else
@@ -2437,7 +2432,7 @@ DEFUN (config_list,
"list",
"Print command list\n")
{
- int i;
+ unsigned int i;
struct cmd_node *cnode = vector_slot (cmdvec, vty->node);
struct cmd_element *cmd;
@@ -2455,7 +2450,7 @@ DEFUN (config_write_file,
"Write running configuration to memory, network, or terminal\n"
"Write to configuration file\n")
{
- int i;
+ unsigned int i;
int fd;
struct cmd_node *node;
char *config_file;
@@ -2592,7 +2587,7 @@ DEFUN (config_write_terminal,
"Write running configuration to memory, network, or terminal\n"
"Write to terminal\n")
{
- int i;
+ unsigned int i;
struct cmd_node *node;
if (vty->type == VTY_SHELL_SERV)
diff --git a/lib/command.h b/lib/command.h
index d1648d68..66883fbb 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -60,7 +60,7 @@ struct host
int encrypt;
/* Banner configuration. */
- char *motd;
+ const char *motd;
};
/* There are some command levels which called from command node. */
@@ -113,7 +113,7 @@ struct cmd_node
enum node_type node;
/* Prompt character at vty interface. */
- char *prompt;
+ const char *prompt;
/* Is this node's configuration goes to vtysh ? */
int vtysh;
@@ -128,12 +128,12 @@ struct cmd_node
/* Structure of command element. */
struct cmd_element
{
- char *string; /* Command specification by string. */
+ const char *string; /* Command specification by string. */
int (*func) (struct cmd_element *, struct vty *, int, char **);
- char *doc; /* Documentation of this command. */
+ const char *doc; /* Documentation of this command. */
int daemon; /* Daemon to which this command belong. */
vector strvec; /* Pointing out each description vector. */
- int cmdsize; /* Command index count. */
+ unsigned int cmdsize; /* Command index count. */
char *config; /* Configuration string */
vector subconfig; /* Sub configuration string */
};
@@ -141,8 +141,8 @@ struct cmd_element
/* Command description structure. */
struct desc
{
- char *cmd; /* Command string. */
- char *str; /* Command's description. */
+ const char *cmd; /* Command string. */
+ const char *str; /* Command's description. */
};
/* Return value of the commands. */
@@ -291,7 +291,7 @@ vector cmd_make_strvec (char *);
void cmd_free_strvec (vector);
vector cmd_describe_command ();
char **cmd_complete_command ();
-char *cmd_prompt (enum node_type);
+const char *cmd_prompt (enum node_type);
int config_from_file (struct vty *, FILE *);
int cmd_execute_command (vector, struct vty *, struct cmd_element **);
int cmd_execute_command_strict (vector, struct vty *, struct cmd_element **);
diff --git a/lib/distribute.c b/lib/distribute.c
index 59dbc5a4..78de4bfb 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -119,8 +119,7 @@ distribute_get (char *ifname)
unsigned int
distribute_hash_make (struct distribute *dist)
{
- unsigned int key;
- int i;
+ unsigned int i, key;
key = 0;
if (dist->ifname)
@@ -625,7 +624,7 @@ ALIAS (no_districute_list_prefix, no_ipv6_distribute_list_prefix_cmd,
int
config_show_distribute (struct vty *vty)
{
- int i;
+ unsigned int i;
struct hash_backet *mp;
struct distribute *dist;
@@ -704,7 +703,7 @@ config_show_distribute (struct vty *vty)
int
config_write_distribute (struct vty *vty)
{
- int i;
+ unsigned int i;
struct hash_backet *mp;
int write = 0;
diff --git a/lib/filter.c b/lib/filter.c
index cd4bc0a5..ee3dbc06 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -137,7 +137,7 @@ filter_free (struct filter *filter)
}
/* Return string of filter_type. */
-static char *
+const static char *
filter_type_str (struct filter *filter)
{
switch (filter->type)
@@ -267,9 +267,9 @@ 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 *
-access_list_insert (afi_t afi, char *name)
+access_list_insert (afi_t afi, const char *name)
{
- int i;
+ unsigned int i;
long number;
struct access_list *access;
struct access_list *point;
@@ -358,7 +358,7 @@ access_list_insert (afi_t afi, char *name)
/* Lookup access_list from list of access_list by name. */
struct access_list *
-access_list_lookup (afi_t afi, char *name)
+access_list_lookup (afi_t afi, const char *name)
{
struct access_list *access;
struct access_master *master;
@@ -384,7 +384,7 @@ access_list_lookup (afi_t afi, 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 *
-access_list_get (afi_t afi, char *name)
+access_list_get (afi_t afi, const char *name)
{
struct access_list *access;
@@ -595,8 +595,8 @@ vty_access_list_remark_unset (struct vty *vty, afi_t afi, char *name)
int
filter_set_cisco (struct vty *vty, char *name_str, char *type_str,
- char *addr_str, char *addr_mask_str,
- char *mask_str, char *mask_mask_str,
+ const char *addr_str, const char *addr_mask_str,
+ const char *mask_str, const char *mask_mask_str,
int extended, int set)
{
int ret;
@@ -1153,8 +1153,8 @@ DEFUN (no_access_list_extended_host_any,
}
int
-filter_set_zebra (struct vty *vty, char *name_str, char *type_str,
- afi_t afi, char *prefix_str, int exact, int set)
+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)
{
int ret;
enum filter_type type;
diff --git a/lib/filter.h b/lib/filter.h
index 077ac2fb..a33e7bfe 100644
--- a/lib/filter.h
+++ b/lib/filter.h
@@ -61,7 +61,7 @@ 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, char *);
+struct access_list *access_list_lookup (afi_t, const char *);
enum filter_type access_list_apply (struct access_list *, void *);
#endif /* _ZEBRA_FILTER_H */
diff --git a/lib/hash.c b/lib/hash.c
index e89171b8..04549ada 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -140,7 +140,7 @@ void
hash_iterate (struct hash *hash,
void (*func) (struct hash_backet *, void *), void *arg)
{
- int i;
+ unsigned int i;
struct hash_backet *hb;
struct hash_backet *hbnext;
@@ -159,7 +159,7 @@ hash_iterate (struct hash *hash,
void
hash_clean (struct hash *hash, void (*free_func) (void *))
{
- int i;
+ unsigned int i;
struct hash_backet *hb;
struct hash_backet *next;
diff --git a/lib/if.c b/lib/if.c
index 43e84a43..8fbaa76a 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -203,7 +203,7 @@ ifindex2ifname (unsigned int index)
if (ifp->ifindex == index)
return ifp->name;
}
- return "unknown";
+ return (char *) "unknown";
}
/* Interface existance check by interface name. */
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 4cf8ad9a..0f3fa9c7 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -106,8 +106,7 @@ if_rmap_get (char *ifname)
unsigned int
if_rmap_hash_make (struct if_rmap *if_rmap)
{
- unsigned int key;
- int i;
+ unsigned int i, key;
key = 0;
for (i = 0; i < strlen (if_rmap->ifname); i++)
@@ -276,7 +275,7 @@ ALIAS (no_if_rmap,
int
config_write_if_rmap (struct vty *vty)
{
- int i;
+ unsigned int i;
struct hash_backet *mp;
int write = 0;
diff --git a/lib/keychain.c b/lib/keychain.c
index 527da053..1d381677 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -59,7 +59,7 @@ key_free (struct key *key)
}
struct keychain *
-keychain_lookup (char *name)
+keychain_lookup (const char *name)
{
struct listnode *nn;
struct keychain *keychain;
@@ -76,7 +76,7 @@ keychain_lookup (char *name)
}
int
-key_cmp_func (struct key *k1, struct key *k2)
+key_cmp_func (const struct key *k1, const struct key *k2)
{
if (k1->index > k2->index)
return 1;
@@ -94,7 +94,7 @@ key_delete_func (struct key *key)
}
struct keychain *
-keychain_get (char *name)
+keychain_get (const char *name)
{
struct keychain *keychain;
@@ -125,7 +125,7 @@ keychain_delete (struct keychain *keychain)
}
struct key *
-key_lookup (struct keychain *keychain, u_int32_t index)
+key_lookup (const struct keychain *keychain, u_int32_t index)
{
struct listnode *nn;
struct key *key;
@@ -139,7 +139,7 @@ key_lookup (struct keychain *keychain, u_int32_t index)
}
struct key *
-key_lookup_for_accept (struct keychain *keychain, u_int32_t index)
+key_lookup_for_accept (const struct keychain *keychain, u_int32_t index)
{
struct listnode *nn;
struct key *key;
@@ -163,7 +163,7 @@ key_lookup_for_accept (struct keychain *keychain, u_int32_t index)
}
struct key *
-key_match_for_accept (struct keychain *keychain, char *auth_str)
+key_match_for_accept (const struct keychain *keychain, const char *auth_str)
{
struct listnode *nn;
struct key *key;
@@ -183,7 +183,7 @@ key_match_for_accept (struct keychain *keychain, char *auth_str)
}
struct key *
-key_lookup_for_send (struct keychain *keychain)
+key_lookup_for_send (const struct keychain *keychain)
{
struct listnode *nn;
struct key *key;
@@ -204,7 +204,7 @@ key_lookup_for_send (struct keychain *keychain)
}
struct key *
-key_get (struct keychain *keychain, u_int32_t index)
+key_get (const struct keychain *keychain, u_int32_t index)
{
struct key *key;
@@ -370,17 +370,18 @@ 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
-key_str2time(char *time_str, char *day_str, char *month_str, char *year_str)
+key_str2time (const char *time_str, const char *day_str, const char *month_str,
+ const char *year_str)
{
int i = 0;
char *colon;
struct tm tm;
time_t time;
- int sec, min, hour;
- int day, month, year;
+ unsigned int sec, min, hour;
+ unsigned int day, month, year;
char *endptr = NULL;
- char *month_name[] =
+ const char *month_name[] =
{
"January",
"February",
@@ -466,10 +467,11 @@ key_str2time(char *time_str, char *day_str, char *month_str, char *year_str)
}
int
-key_lifetime_set (struct vty *vty, struct key_range *krange, char *stime_str,
- char *sday_str, char *smonth_str, char *syear_str,
- char *etime_str, char *eday_str, char *emonth_str,
- char *eyear_str)
+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,
+ const char *etime_str, const char *eday_str,
+ const char *emonth_str, const char *eyear_str)
{
time_t time_start;
time_t time_end;
@@ -502,8 +504,9 @@ key_lifetime_set (struct vty *vty, struct key_range *krange, char *stime_str,
int
key_lifetime_duration_set (struct vty *vty, struct key_range *krange,
- char *stime_str, char *sday_str, char *smonth_str,
- char *syear_str, char *duration_str)
+ const char *stime_str, const char *sday_str,
+ const char *smonth_str, const char *syear_str,
+ const char *duration_str)
{
time_t time_start;
u_int32_t duration;
@@ -531,8 +534,8 @@ key_lifetime_duration_set (struct vty *vty, struct key_range *krange,
int
key_lifetime_infinite_set (struct vty *vty, struct key_range *krange,
- char *stime_str, char *sday_str, char *smonth_str,
- char *syear_str)
+ const char *stime_str, const char *sday_str,
+ const char *smonth_str, const char *syear_str)
{
time_t time_start;
diff --git a/lib/keychain.h b/lib/keychain.h
index 0cfa3d52..e98c403f 100644
--- a/lib/keychain.h
+++ b/lib/keychain.h
@@ -48,9 +48,9 @@ struct key
};
void keychain_init ();
-struct keychain *keychain_lookup (char *);
-struct key *key_lookup_for_accept (struct keychain *, u_int32_t);
-struct key *key_match_for_accept (struct keychain *, char *);
-struct key *key_lookup_for_send (struct keychain *);
+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 *);
#endif /* _ZEBRA_KEYCHAIN_H */
diff --git a/lib/log.c b/lib/log.c
index 2090b91e..bbe6e996 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -474,7 +474,7 @@ zlog_free_cwd ()
}
/* Message lookup function. */
-char *
+const char *
lookup (struct message *mes, int key)
{
struct message *pnt;
@@ -488,7 +488,7 @@ lookup (struct message *mes, int key)
/* Very old hacky version of message lookup function. Still partly
used in bgpd and ospfd. FIXME Seems that it's not used any more. */
-char *
+const char *
mes_lookup (struct message *meslist, int max, int index)
{
if (index < 0 || index >= max)
diff --git a/lib/log.h b/lib/log.h
index defe0641..e2eeb826 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -121,8 +121,8 @@ int zlog_rotate ();
/* For hackey massage lookup and check */
#define LOOKUP(x, y) mes_lookup(x, x ## _max, y)
-char *lookup (struct message *, int);
-char *mes_lookup (struct message *meslist, int max, int index);
+const char *lookup (struct message *, int);
+const char *mes_lookup (struct message *meslist, int max, int index);
extern const char *zlog_priority[];
diff --git a/lib/plist.c b/lib/plist.c
index 4069f861..ef2fffc2 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -184,7 +184,7 @@ prefix_list_entry_free (struct prefix_list_entry *pentry)
static struct prefix_list *
prefix_list_insert (afi_t afi, char *name)
{
- int i;
+ unsigned int i;
long number;
struct prefix_list *plist;
struct prefix_list *point;
@@ -517,7 +517,7 @@ prefix_list_entry_add (struct prefix_list *plist,
}
/* Return string of prefix_list_type. */
-static char *
+const static char *
prefix_list_type_str (struct prefix_list_entry *pentry)
{
switch (pentry->type)
diff --git a/lib/privs.h b/lib/privs.h
index 65c9f358..76e8af23 100644
--- a/lib/privs.h
+++ b/lib/privs.h
@@ -61,9 +61,9 @@ struct zebra_privs_t
zebra_capabilities_t *caps_i; /* caps to allow inheritance of */
int cap_num_p; /* number of caps in arrays */
int cap_num_i;
- char *user; /* user and group to run as */
- char *group;
- char *vty_group; /* group to chown vty socket to */
+ const char *user; /* user and group to run as */
+ const char *group;
+ const char *vty_group; /* group to chown vty socket to */
/* methods */
int
(*change) (zebra_privs_ops_t); /* change privileges, 0 on success */
diff --git a/lib/routemap.c b/lib/routemap.c
index 9d6bbcfd..67bbc034 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -171,7 +171,7 @@ route_map_get (char *name)
}
/* Return route map's type string. */
-static char *
+const static char *
route_map_type_str (enum route_map_type type)
{
switch (type)
@@ -426,7 +426,7 @@ route_map_install_set (struct route_map_rule_cmd *cmd)
struct route_map_rule_cmd *
route_map_lookup_match (char *name)
{
- int i;
+ unsigned int i;
struct route_map_rule_cmd *rule;
for (i = 0; i < vector_max (route_match_vec); i++)
@@ -440,7 +440,7 @@ route_map_lookup_match (char *name)
struct route_map_rule_cmd *
route_map_lookup_set (char *name)
{
- int i;
+ unsigned int i;
struct route_map_rule_cmd *rule;
for (i = 0; i < vector_max (route_set_vec); i++)
diff --git a/lib/sockunion.c b/lib/sockunion.c
index 039da1a9..587b324a 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -704,7 +704,7 @@ sockunion_print (union sockunion *su)
int
in6addr_cmp (struct in6_addr *addr1, struct in6_addr *addr2)
{
- int i;
+ unsigned int i;
u_char *p1, *p2;
p1 = (u_char *)addr1;
diff --git a/lib/thread.c b/lib/thread.c
index 474571e6..2847b8bf 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -382,7 +382,7 @@ thread_timer_remain_second (struct thread *thread)
/* Trim blankspace and "()"s */
static char *
-strip_funcname (char *funcname)
+strip_funcname (const char *funcname)
{
char buff[100];
char tmp, *ret, *e, *b = buff;
@@ -410,7 +410,7 @@ strip_funcname (char *funcname)
/* Get new thread. */
static struct thread *
thread_get (struct thread_master *m, u_char type,
- int (*func) (struct thread *), void *arg, char* funcname)
+ int (*func) (struct thread *), void *arg, const char* funcname)
{
struct thread *thread;
@@ -439,7 +439,7 @@ thread_get (struct thread_master *m, u_char type,
/* Add new read thread. */
struct thread *
funcname_thread_add_read (struct thread_master *m,
- int (*func) (struct thread *), void *arg, int fd, char* funcname)
+ int (*func) (struct thread *), void *arg, int fd, const char* funcname)
{
struct thread *thread;
@@ -462,7 +462,7 @@ funcname_thread_add_read (struct thread_master *m,
/* Add new write thread. */
struct thread *
funcname_thread_add_write (struct thread_master *m,
- int (*func) (struct thread *), void *arg, int fd, char* funcname)
+ int (*func) (struct thread *), void *arg, int fd, const char* funcname)
{
struct thread *thread;
@@ -487,7 +487,7 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
int (*func) (struct thread *),
void *arg,
struct timeval *time_relative,
- char* funcname)
+ const char* funcname)
{
struct thread *thread;
struct timeval timer_now;
@@ -528,7 +528,7 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
struct thread *
funcname_thread_add_timer (struct thread_master *m,
int (*func) (struct thread *),
- void *arg, long timer, char* funcname)
+ void *arg, long timer, const char* funcname)
{
struct timeval trel;
@@ -544,7 +544,7 @@ funcname_thread_add_timer (struct thread_master *m,
struct thread *
funcname_thread_add_timer_msec (struct thread_master *m,
int (*func) (struct thread *),
- void *arg, long timer, char* funcname)
+ void *arg, long timer, const char* funcname)
{
struct timeval trel;
@@ -561,7 +561,7 @@ funcname_thread_add_timer_msec (struct thread_master *m,
/* Add simple event thread. */
struct thread *
funcname_thread_add_event (struct thread_master *m,
- int (*func) (struct thread *), void *arg, int val, char* funcname)
+ int (*func) (struct thread *), void *arg, int val, const char* funcname)
{
struct thread *thread;
@@ -888,7 +888,7 @@ funcname_thread_execute (struct thread_master *m,
int (*func)(struct thread *),
void *arg,
int val,
- char* funcname)
+ const char* funcname)
{
struct thread dummy;
diff --git a/lib/thread.h b/lib/thread.h
index 9a8c2bef..716a6a6c 100644
--- a/lib/thread.h
+++ b/lib/thread.h
@@ -74,7 +74,7 @@ struct thread
struct cpu_thread_history {
int (*func)(struct thread *);
- char *funcname;
+ const char *funcname;
unsigned int total_calls;
unsigned long total, max;
unsigned char types;
@@ -138,21 +138,21 @@ struct cpu_thread_history {
/* Prototypes. */
struct thread_master *thread_master_create ();
struct thread *funcname_thread_add_read (struct thread_master *,
- int (*)(struct thread *), void *, int, char*);
+ int (*)(struct thread *), void *, int, const char*);
struct thread *funcname_thread_add_write (struct thread_master *,
- int (*)(struct thread *), void *, int, char*);
+ int (*)(struct thread *), void *, int, const char*);
struct thread *funcname_thread_add_timer (struct thread_master *,
- int (*)(struct thread *), void *, long, char*);
+ int (*)(struct thread *), void *, long, const char*);
struct thread *funcname_thread_add_timer_msec (struct thread_master *,
- int (*)(struct thread *), void *, long, char*);
+ int (*)(struct thread *), void *, long, const char*);
struct thread *funcname_thread_add_event (struct thread_master *,
- int (*)(struct thread *), void *, int, char*);
+ int (*)(struct thread *), void *, int, const char*);
void thread_cancel (struct thread *);
void thread_cancel_event (struct thread_master *, void *);
struct thread *thread_fetch (struct thread_master *, struct thread *);
struct thread *funcname_thread_execute (struct thread_master *,
- int (*)(struct thread *), void *, int, char *);
+ int (*)(struct thread *), void *, int, const char *);
void thread_call (struct thread *);
unsigned long thread_timer_remain_second (struct thread *);
diff --git a/lib/vty.c b/lib/vty.c
index 3e799b88..c10c984b 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -848,9 +848,10 @@ vty_complete_command (struct vty *vty)
void
vty_describe_fold (struct vty *vty, int cmd_width,
- int desc_width, struct desc *desc)
+ unsigned int desc_width, struct desc *desc)
{
- char *buf, *cmd, *p;
+ char *buf;
+ const char *cmd, *p;
int pos;
cmd = desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd;
@@ -891,7 +892,7 @@ vty_describe_command (struct vty *vty)
int ret;
vector vline;
vector describe;
- int i, width, desc_width;
+ unsigned int i, width, desc_width;
struct desc *desc, *desc_cr = NULL;
vline = cmd_make_strvec (vty->buf);
@@ -934,7 +935,7 @@ vty_describe_command (struct vty *vty)
for (i = 0; i < vector_max (describe); i++)
if ((desc = vector_slot (describe, i)) != NULL)
{
- int len;
+ unsigned int len;
if (desc->cmd[0] == '\0')
continue;
@@ -2308,7 +2309,7 @@ vty_read_config (char *config_file,
void
vty_log (const char *proto_str, const char *format, va_list va)
{
- int i;
+ unsigned int i;
struct vty *vty;
for (i = 0; i < vector_max (vtyvec); i++)
@@ -2397,7 +2398,7 @@ DEFUN (config_who,
"who",
"Display who is on vty\n")
{
- int i;
+ unsigned int i;
struct vty *v;
for (i = 0; i < vector_max (vtyvec); i++)
@@ -2677,7 +2678,7 @@ struct cmd_node vty_node =
void
vty_reset ()
{
- int i;
+ unsigned int i;
struct vty *vty;
struct thread *vty_serv_thread;
@@ -2717,7 +2718,7 @@ vty_reset ()
void
vty_finish ()
{
- int i;
+ unsigned int i;
struct vty *vty;
struct thread *vty_serv_thread;
diff --git a/lib/zclient.c b/lib/zclient.c
index 5df420f2..98829f61 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -167,7 +167,7 @@ zclient_socket ()
#include <sys/un.h>
int
-zclient_socket_un (char *path)
+zclient_socket_un (const char *path)
{
int ret;
int sock, len;
diff --git a/lib/zclient.h b/lib/zclient.h
index 03a6e0a7..d18cf628 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -109,7 +109,7 @@ int zclient_start (struct zclient *);
void zclient_stop (struct zclient *);
void zclient_reset (struct zclient *);
int zclient_socket ();
-int zclient_socket_un (char *);
+int zclient_socket_un (const char *);
void zclient_redistribute (int, struct zclient *, int);
void zclient_redistribute_default (int, struct zclient *);