summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpaul <paul>2004-10-10 13:56:56 +0200
committerpaul <paul>2004-10-10 13:56:56 +0200
commit9035efaa924c69f4f4fcb1049c7dc4f43b9da980 (patch)
treef81d25b0e069ad8fb5f2843172a4e60fa0d6cbdf /lib
parent2004-10-10 Paul Jakma <paul@dishone.st> (diff)
downloadfrr-9035efaa924c69f4f4fcb1049c7dc4f43b9da980.tar.xz
frr-9035efaa924c69f4f4fcb1049c7dc4f43b9da980.zip
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier. * command.h: Change DEFUN func to take const char *[] rather than char **, to begin process of fixing compile warnings in lib/. Nearly all other changes in this commit follow from this change. * buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take const void * and cast an automatic const char *p to it. (buffer_putstr) add const * command.c: (zencrypt) const qualifier (cmd_execute_command_real) ditto (cmd_execute_command_strict) ditto (config_log_file) ditto. Fix leak of getcwd() returned string. * memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname. * distribute.{c,h}: Update with const qualifier. (distribute_free) use MTYPE_DISTRIBUTE_IFNAME (distribute_lookup) Cast to char *, note that it's ok. (distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME. (distribute_get) Cast to char *, note that it's ok. * filter.c: Update with const qualifier. * if.{c,h}: ditto. * if_rmap.{c,h}: ditto. (if_rmap_lookup) Cast to char *, note that it's ok. (if_rmap_get) ditto. * log.{c,h}: Update with const qualifier. * plist.{c,h}: ditto. * routemap.{c,h}: ditto. * smux.{c,h}: ditto. Fix some signed/unsigned comparisons. * sockopt.c: (getsockopt_cmsg_data) add return for error case. * vty.c: Update with const qualifier.
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog32
-rw-r--r--lib/buffer.c6
-rw-r--r--lib/buffer.h4
-rw-r--r--lib/command.c36
-rw-r--r--lib/command.h16
-rw-r--r--lib/distribute.c31
-rw-r--r--lib/distribute.h2
-rw-r--r--lib/filter.c6
-rw-r--r--lib/if.c6
-rw-r--r--lib/if.h6
-rw-r--r--lib/if_rmap.c16
-rw-r--r--lib/if_rmap.h2
-rw-r--r--lib/log.c2
-rw-r--r--lib/log.h2
-rw-r--r--lib/memory.c2
-rw-r--r--lib/memory.h2
-rw-r--r--lib/plist.c33
-rw-r--r--lib/plist.h2
-rw-r--r--lib/routemap.c22
-rw-r--r--lib/routemap.h8
-rw-r--r--lib/smux.c23
-rw-r--r--lib/sockopt.c2
-rw-r--r--lib/vty.c2
23 files changed, 163 insertions, 100 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 05317db5a..dc8fae8a9 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,7 +1,35 @@
-2004-10-05 Paul Jakma <paul@dishone.st>
+2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
-
+ * command.h: Change DEFUN func to take const char *[] rather
+ than char **, to begin process of fixing compile warnings in lib/.
+ Nearly all other changes in this commit follow from this change.
+ * buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
+ const void * and cast an automatic const char *p to it.
+ (buffer_putstr) add const
+ * command.c: (zencrypt) const qualifier
+ (cmd_execute_command_real) ditto
+ (cmd_execute_command_strict) ditto
+ (config_log_file) ditto.
+ Fix leak of getcwd() returned string.
+ * memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
+ * distribute.{c,h}: Update with const qualifier.
+ (distribute_free) use MTYPE_DISTRIBUTE_IFNAME
+ (distribute_lookup) Cast to char *, note that it's ok.
+ (distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
+ (distribute_get) Cast to char *, note that it's ok.
+ * filter.c: Update with const qualifier.
+ * if.{c,h}: ditto.
+ * if_rmap.{c,h}: ditto.
+ (if_rmap_lookup) Cast to char *, note that it's ok.
+ (if_rmap_get) ditto.
+ * log.{c,h}: Update with const qualifier.
+ * plist.{c,h}: ditto.
+ * routemap.{c,h}: ditto.
+ * smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
+ * sockopt.c: (getsockopt_cmsg_data) add return for error case.
+ * vty.c: Update with const qualifier.
+
2004-10-08 Hasso Tepper <hasso at quagga.net>
* routemap.c, routemap.h: Make some string arguments const.
diff --git a/lib/buffer.c b/lib/buffer.c
index 6fd9a2bb0..904b4aa9b 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -149,10 +149,10 @@ buffer_add (struct buffer *b)
/* Write data to buffer. */
int
-buffer_write (struct buffer *b, void *ptr, size_t size)
+buffer_write (struct buffer *b, const void *p, size_t size)
{
struct buffer_data *data;
-
+ const char *ptr = p;
data = b->tail;
b->length += size;
@@ -205,7 +205,7 @@ buffer_putw (struct buffer *b, u_short c)
/* Put string to the buffer. */
int
-buffer_putstr (struct buffer *b, char *c)
+buffer_putstr (struct buffer *b, const char *c)
{
size_t size;
diff --git a/lib/buffer.h b/lib/buffer.h
index eaf4b88df..9d453b1d0 100644
--- a/lib/buffer.h
+++ b/lib/buffer.h
@@ -63,11 +63,11 @@ struct buffer_data
/* Buffer prototypes. */
struct buffer *buffer_new (size_t);
-int buffer_write (struct buffer *, void *, size_t);
+int buffer_write (struct buffer *, const void *, size_t);
void buffer_free (struct buffer *);
char *buffer_getstr (struct buffer *);
int buffer_putc (struct buffer *, u_char);
-int buffer_putstr (struct buffer *, char *);
+int buffer_putstr (struct buffer *, const char *);
void buffer_reset (struct buffer *);
int buffer_flush_all (struct buffer *, int);
int buffer_flush_vty_all (struct buffer *, int, int, int);
diff --git a/lib/command.c b/lib/command.c
index 2766a3577..168fe563f 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -432,7 +432,7 @@ to64(char *s, long v, int n)
}
}
-char *zencrypt (char *passwd)
+char *zencrypt (const char *passwd)
{
char salt[6];
struct timeval tv;
@@ -1932,7 +1932,7 @@ cmd_execute_command_real (vector vline, struct vty *vty, struct cmd_element **cm
struct cmd_element *matched_element;
unsigned int matched_count, incomplete_count;
int argc;
- char *argv[CMD_ARGC_MAX];
+ const char *argv[CMD_ARGC_MAX];
enum match_type match = 0;
int varflag;
char *command;
@@ -2111,7 +2111,7 @@ cmd_execute_command_strict (vector vline, struct vty *vty,
struct cmd_element *matched_element;
unsigned int matched_count, incomplete_count;
int argc;
- char *argv[CMD_ARGC_MAX];
+ const char *argv[CMD_ARGC_MAX];
int varflag;
enum match_type match = 0;
char *command;
@@ -2983,22 +2983,38 @@ DEFUN (config_log_file,
"Logging filename\n")
{
int ret;
- char *cwd;
- char *fullpath;
-
+ char *p = NULL;
+ const char *fullpath;
+
/* Path detection. */
if (! IS_DIRECTORY_SEP (*argv[0]))
{
- cwd = getcwd (NULL, MAXPATHLEN);
- fullpath = XMALLOC (MTYPE_TMP,
- strlen (cwd) + strlen (argv[0]) + 2);
- sprintf (fullpath, "%s/%s", cwd, argv[0]);
+ char cwd[MAXPATHLEN+1];
+ cwd[MAXPATHLEN] = '\0';
+
+ if (getcwd (cwd, MAXPATHLEN) == NULL)
+ {
+ zlog_err ("config_log_file: Unable to alloc mem!");
+ return CMD_WARNING;
+ }
+
+ if ( (p = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (argv[0]) + 2))
+ == NULL)
+ {
+ zlog_err ("config_log_file: Unable to alloc mem!");
+ return CMD_WARNING;
+ }
+ sprintf (p, "%s/%s", cwd, argv[0]);
+ fullpath = p;
}
else
fullpath = argv[0];
ret = zlog_set_file (NULL, ZLOG_FILE, fullpath);
+ if (p)
+ XFREE (MTYPE_TMP, p);
+
if (!ret)
{
vty_out (vty, "can't open logfile %s\n", argv[0]);
diff --git a/lib/command.h b/lib/command.h
index 9e727cfb9..0f806c872 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -129,7 +129,7 @@ struct cmd_node
struct cmd_element
{
const char *string; /* Command specification by string. */
- int (*func) (struct cmd_element *, struct vty *, int, char **);
+ int (*func) (struct cmd_element *, struct vty *, int, const char *[]);
const char *doc; /* Documentation of this command. */
int daemon; /* Daemon to which this command belong. */
vector strvec; /* Pointing out each description vector. */
@@ -166,15 +166,15 @@ struct desc
/* DEFUN for vty command interafce. Little bit hacky ;-). */
#define DEFUN(funcname, cmdname, cmdstr, helpstr) \
- int funcname (struct cmd_element *, struct vty *, int, char **); \
+ int funcname (struct cmd_element *, struct vty *, int, const char *[]); \
struct cmd_element cmdname = \
{ \
- cmdstr, \
- funcname, \
- helpstr \
+ .string = cmdstr, \
+ .func = funcname, \
+ .doc = helpstr \
}; \
int funcname \
- (struct cmd_element *self, struct vty *vty, int argc, char **argv)
+ (struct cmd_element *self, struct vty *vty, int argc, const char *argv[])
/* DEFUN_NOSH for commands that vtysh should ignore */
#define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \
@@ -304,8 +304,8 @@ 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;
-int config_exit (struct cmd_element *, struct vty *, int, char **);
-int config_help (struct cmd_element *, struct vty *, int, char **);
+int config_exit (struct cmd_element *, struct vty *, int, const char *[]);
+int config_help (struct cmd_element *, struct vty *, int, const char *[]);
char *host_config_file ();
void host_config_set (char *);
diff --git a/lib/distribute.c b/lib/distribute.c
index 78de4bfbc..48eb0403f 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -51,7 +51,7 @@ void
distribute_free (struct distribute *dist)
{
if (dist->ifname)
- free (dist->ifname);
+ XFREE (MTYPE_DISTRIBUTE_IFNAME, dist->ifname);
if (dist->list[DISTRIBUTE_IN])
free (dist->list[DISTRIBUTE_IN]);
@@ -68,12 +68,13 @@ distribute_free (struct distribute *dist)
/* Lookup interface's distribute list. */
struct distribute *
-distribute_lookup (char *ifname)
+distribute_lookup (const char *ifname)
{
struct distribute key;
struct distribute *dist;
- key.ifname = ifname;
+ /* temporary reference */
+ key.ifname = (char *)ifname;
dist = hash_lookup (disthash, &key);
@@ -99,7 +100,7 @@ distribute_hash_alloc (struct distribute *arg)
dist = distribute_new ();
if (arg->ifname)
- dist->ifname = strdup (arg->ifname);
+ dist->ifname = XSTRDUP (MTYPE_DISTRIBUTE_IFNAME, arg->ifname);
else
dist->ifname = NULL;
return dist;
@@ -107,12 +108,13 @@ distribute_hash_alloc (struct distribute *arg)
/* Make new distribute list and push into hash. */
struct distribute *
-distribute_get (char *ifname)
+distribute_get (const char *ifname)
{
struct distribute key;
- key.ifname = ifname;
-
+ /* temporary reference */
+ key.ifname = (char *)ifname;
+
return hash_get (disthash, &key, distribute_hash_alloc);
}
@@ -144,7 +146,8 @@ distribute_cmp (struct distribute *dist1, struct distribute *dist2)
/* Set access-list name to the distribute list. */
struct distribute *
-distribute_list_set (char *ifname, enum distribute_type type, char *alist_name)
+distribute_list_set (const char *ifname, enum distribute_type type,
+ const char *alist_name)
{
struct distribute *dist;
@@ -172,8 +175,8 @@ distribute_list_set (char *ifname, enum distribute_type type, char *alist_name)
/* Unset distribute-list. If matched distribute-list exist then
return 1. */
int
-distribute_list_unset (char *ifname, enum distribute_type type,
- char *alist_name)
+distribute_list_unset (const char *ifname, enum distribute_type type,
+ const char *alist_name)
{
struct distribute *dist;
@@ -221,8 +224,8 @@ distribute_list_unset (char *ifname, enum distribute_type type,
/* Set access-list name to the distribute list. */
struct distribute *
-distribute_list_prefix_set (char *ifname, enum distribute_type type,
- char *plist_name)
+distribute_list_prefix_set (const char *ifname, enum distribute_type type,
+ const char *plist_name)
{
struct distribute *dist;
@@ -250,8 +253,8 @@ distribute_list_prefix_set (char *ifname, enum distribute_type type,
/* Unset distribute-list. If matched distribute-list exist then
return 1. */
int
-distribute_list_prefix_unset (char *ifname, enum distribute_type type,
- char *plist_name)
+distribute_list_prefix_unset (const char *ifname, enum distribute_type type,
+ const char *plist_name)
{
struct distribute *dist;
diff --git a/lib/distribute.h b/lib/distribute.h
index 330126b95..77bb87585 100644
--- a/lib/distribute.h
+++ b/lib/distribute.h
@@ -47,7 +47,7 @@ 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 (char *);
+struct distribute *distribute_lookup (const char *);
int config_write_distribute (struct vty *);
int config_show_distribute (struct vty *);
diff --git a/lib/filter.c b/lib/filter.c
index ee3dbc06f..9817c07de 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -569,7 +569,7 @@ filter_lookup_zebra (struct access_list *access, struct filter *mnew)
}
int
-vty_access_list_remark_unset (struct vty *vty, afi_t afi, char *name)
+vty_access_list_remark_unset (struct vty *vty, afi_t afi, const char *name)
{
struct access_list *access;
@@ -594,7 +594,7 @@ 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,
+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,
int extended, int set)
@@ -1596,7 +1596,7 @@ void config_write_access_cisco (struct vty *, struct filter *);
/* show access-list command. */
int
-filter_show (struct vty *vty, char *name, afi_t afi)
+filter_show (struct vty *vty, const char *name, afi_t afi)
{
struct access_list *access;
struct access_master *master;
diff --git a/lib/if.c b/lib/if.c
index 8fbaa76ac..259b84231 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -123,7 +123,7 @@ if_new ()
}
struct interface *
-if_create (char *name, int namelen)
+if_create (const char *name, int namelen)
{
struct interface *ifp;
@@ -208,7 +208,7 @@ ifindex2ifname (unsigned int index)
/* Interface existance check by interface name. */
struct interface *
-if_lookup_by_name (char *name)
+if_lookup_by_name (const char *name)
{
struct listnode *node;
struct interface *ifp;
@@ -320,7 +320,7 @@ if_lookup_address (struct in_addr src)
/* Get interface by name if given name interface doesn't exist create
one. */
struct interface *
-if_get_by_name (char *name)
+if_get_by_name (const char *name)
{
struct interface *ifp;
diff --git a/lib/if.h b/lib/if.h
index 47e992c36..0f088a975 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -183,12 +183,12 @@ struct connected
/* Prototypes. */
int if_cmp_func (struct interface *, struct interface *);
struct interface *if_new (void);
-struct interface *if_create (char *name, int namelen);
+struct interface *if_create (const char *name, int namelen);
struct interface *if_lookup_by_index (unsigned int);
-struct interface *if_lookup_by_name (char *);
+struct interface *if_lookup_by_name (const char *);
struct interface *if_lookup_exact_address (struct in_addr);
struct interface *if_lookup_address (struct in_addr);
-struct interface *if_get_by_name (char *);
+struct interface *if_get_by_name (const char *);
void if_delete (struct interface *);
int if_is_up (struct interface *);
int if_is_running (struct interface *);
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 0f3fa9c70..3f95af39c 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -58,12 +58,13 @@ if_rmap_free (struct if_rmap *if_rmap)
}
struct if_rmap *
-if_rmap_lookup (char *ifname)
+if_rmap_lookup (const char *ifname)
{
struct if_rmap key;
struct if_rmap *if_rmap;
- key.ifname = ifname;
+ /* temporary copy */
+ key.ifname = (char *)ifname;
if_rmap = hash_lookup (ifrmaphash, &key);
@@ -94,11 +95,12 @@ if_rmap_hash_alloc (struct if_rmap *arg)
}
struct if_rmap *
-if_rmap_get (char *ifname)
+if_rmap_get (const char *ifname)
{
struct if_rmap key;
- key.ifname = ifname;
+ /* temporary copy */
+ key.ifname = (char *)ifname;
return (struct if_rmap *) hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
}
@@ -124,7 +126,8 @@ if_rmap_hash_cmp (struct if_rmap *if_rmap1, struct if_rmap *if_rmap2)
}
struct if_rmap *
-if_rmap_set (char *ifname, enum if_rmap_type type, char *routemap_name)
+if_rmap_set (const char *ifname, enum if_rmap_type type,
+ const char *routemap_name)
{
struct if_rmap *if_rmap;
@@ -150,7 +153,8 @@ if_rmap_set (char *ifname, enum if_rmap_type type, char *routemap_name)
}
int
-if_rmap_unset (char *ifname, enum if_rmap_type type, char *routemap_name)
+if_rmap_unset (const char *ifname, enum if_rmap_type type,
+ const char *routemap_name)
{
struct if_rmap *if_rmap;
diff --git a/lib/if_rmap.h b/lib/if_rmap.h
index a9355ab99..540d68fc2 100644
--- a/lib/if_rmap.h
+++ b/lib/if_rmap.h
@@ -41,7 +41,7 @@ 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 (char *);
+struct if_rmap *if_rmap_lookup (const char *);
int config_write_if_rmap (struct vty *);
#endif /* _ZEBRA_IF_RMAP_H */
diff --git a/lib/log.c b/lib/log.c
index bbe6e9967..375730f22 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -366,7 +366,7 @@ zlog_reset_flag (struct zlog *zl, int flags)
}
int
-zlog_set_file (struct zlog *zl, int flags, char *filename)
+zlog_set_file (struct zlog *zl, int flags, const char *filename)
{
FILE *fp;
mode_t oldumask;
diff --git a/lib/log.h b/lib/log.h
index e2eeb826f..9f6ec3bec 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -112,7 +112,7 @@ void zlog_set_flag (struct zlog *zl, int flags);
void zlog_reset_flag (struct zlog *zl, int flags);
/* Set zlog filename. */
-int zlog_set_file (struct zlog *zl, int flags, char *filename);
+int zlog_set_file (struct zlog *zl, int flags, const char *filename);
int zlog_reset_file (struct zlog *zl);
/* Rotate log. */
diff --git a/lib/memory.c b/lib/memory.c
index 8b311aeac..bef0997f7 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -239,6 +239,8 @@ struct memory_list memory_list_lib[] =
{ MTYPE_ROUTE_TABLE, "Route table " },
{ MTYPE_ROUTE_NODE, "Route node " },
{ MTYPE_RIB, "RIB " },
+ { MTYPE_DISTRIBUTE, "Distribute list " },
+ { MTYPE_DISTRIBUTE_IFNAME, "Dist-list ifname" },
{ MTYPE_NEXTHOP, "Nexthop " },
{ MTYPE_LINK_LIST, "Link List " },
{ MTYPE_LINK_NODE, "Link Node " },
diff --git a/lib/memory.h b/lib/memory.h
index c2d595a47..2f403a145 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -75,7 +75,9 @@ enum
MTYPE_ROUTE_MAP_COMPILED,
MTYPE_RIB,
+
MTYPE_DISTRIBUTE,
+ MTYPE_DISTRIBUTE_IFNAME,
MTYPE_ZLOG,
MTYPE_ZCLIENT,
MTYPE_NEXTHOP,
diff --git a/lib/plist.c b/lib/plist.c
index ef2fffc29..3520f82f0 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -126,7 +126,7 @@ prefix_master_get (afi_t afi)
/* Lookup prefix_list from list of prefix_list by name. */
struct prefix_list *
-prefix_list_lookup (afi_t afi, char *name)
+prefix_list_lookup (afi_t afi, const char *name)
{
struct prefix_list *plist;
struct prefix_master *master;
@@ -182,7 +182,7 @@ prefix_list_entry_free (struct prefix_list_entry *pentry)
/* Insert new prefix list to list of prefix_list. Each prefix_list
is sorted by the name. */
static struct prefix_list *
-prefix_list_insert (afi_t afi, char *name)
+prefix_list_insert (afi_t afi, const char *name)
{
unsigned int i;
long number;
@@ -272,7 +272,7 @@ prefix_list_insert (afi_t afi, char *name)
}
static struct prefix_list *
-prefix_list_get (afi_t afi, char *name)
+prefix_list_get (afi_t afi, const char *name)
{
struct prefix_list *plist;
@@ -647,7 +647,7 @@ prefix_entry_dup_check (struct prefix_list *plist,
}
static int
-vty_invalid_prefix_range (struct vty *vty, char *prefix)
+vty_invalid_prefix_range (struct vty *vty, const char *prefix)
{
vty_out (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s",
prefix, VTY_NEWLINE);
@@ -655,9 +655,9 @@ vty_invalid_prefix_range (struct vty *vty, char *prefix)
}
static int
-vty_prefix_list_install (struct vty *vty, afi_t afi,
- char *name, char *seq, char *typestr,
- char *prefix, char *ge, char *le)
+vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
+ const char *seq, const char *typestr,
+ const char *prefix, const char *ge, const char *le)
{
int ret;
enum prefix_list_type type;
@@ -774,9 +774,9 @@ vty_prefix_list_install (struct vty *vty, afi_t afi,
}
static int
-vty_prefix_list_uninstall (struct vty *vty, afi_t afi,
- char *name, char *seq, char *typestr,
- char *prefix, char *ge, char *le)
+vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
+ const char *seq, const char *typestr,
+ const char *prefix, const char *ge, const char *le)
{
int ret;
enum prefix_list_type type;
@@ -878,7 +878,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi,
}
static int
-vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, char *name)
+vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, const char *name)
{
struct prefix_list *plist;
@@ -982,8 +982,8 @@ vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist,
}
static int
-vty_show_prefix_list (struct vty *vty, afi_t afi, char *name,
- char *seq, enum display_type dtype)
+vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name,
+ const char *seq, enum display_type dtype)
{
struct prefix_list *plist;
struct prefix_master *master;
@@ -1026,8 +1026,8 @@ vty_show_prefix_list (struct vty *vty, afi_t afi, char *name,
}
static int
-vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, char *name,
- char *prefix, enum display_type type)
+vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name,
+ const char *prefix, enum display_type type)
{
struct prefix_list *plist;
struct prefix_list_entry *pentry;
@@ -1098,7 +1098,8 @@ vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, char *name,
}
static int
-vty_clear_prefix_list (struct vty *vty, afi_t afi, char *name, char *prefix)
+vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name,
+ const char *prefix)
{
struct prefix_master *master;
struct prefix_list *plist;
diff --git a/lib/plist.h b/lib/plist.h
index 9a9eb7101..01ac9874d 100644
--- a/lib/plist.h
+++ b/lib/plist.h
@@ -67,7 +67,7 @@ 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 *));
-struct prefix_list *prefix_list_lookup (afi_t, char *);
+struct prefix_list *prefix_list_lookup (afi_t, const char *);
enum prefix_list_type prefix_list_apply (struct prefix_list *, void *);
struct stream *
diff --git a/lib/routemap.c b/lib/routemap.c
index 748aa2cf8..cd231be7d 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -57,9 +57,9 @@ struct route_map_list
struct route_map *head;
struct route_map *tail;
- void (*add_hook) (char *);
- void (*delete_hook) (char *);
- void (*event_hook) (route_map_event_t, char *);
+ void (*add_hook) (const char *);
+ void (*delete_hook) (const char *);
+ void (*event_hook) (route_map_event_t, const char *);
};
/* Master list of route map. */
@@ -75,7 +75,7 @@ route_map_index_delete (struct route_map_index *, int);
/* New route map allocation. Please note route map's name must be
specified. */
static struct route_map *
-route_map_new (char *name)
+route_map_new (const char *name)
{
struct route_map *new;
@@ -86,7 +86,7 @@ route_map_new (char *name)
/* Add new name to route_map. */
static struct route_map *
-route_map_add (char *name)
+route_map_add (const char *name)
{
struct route_map *map;
struct route_map_list *list;
@@ -147,7 +147,7 @@ route_map_delete (struct route_map *map)
/* Lookup route map by route map name string. */
struct route_map *
-route_map_lookup_by_name (char *name)
+route_map_lookup_by_name (const char *name)
{
struct route_map *map;
@@ -160,7 +160,7 @@ route_map_lookup_by_name (char *name)
/* Lookup route map. If there isn't route map create one and return
it. */
struct route_map *
-route_map_get (char *name)
+route_map_get (const char *name)
{
struct route_map *map;
@@ -241,7 +241,7 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
}
int
-vty_show_route_map (struct vty *vty, char *name)
+vty_show_route_map (struct vty *vty, const char *name)
{
struct route_map *map;
@@ -852,19 +852,19 @@ route_map_apply (struct route_map *map, struct prefix *prefix,
}
void
-route_map_add_hook (void (*func) (char *))
+route_map_add_hook (void (*func) (const char *))
{
route_map_master.add_hook = func;
}
void
-route_map_delete_hook (void (*func) (char *))
+route_map_delete_hook (void (*func) (const char *))
{
route_map_master.delete_hook = func;
}
void
-route_map_event_hook (void (*func) (route_map_event_t, char *))
+route_map_event_hook (void (*func) (route_map_event_t, const char *))
{
route_map_master.event_hook = func;
}
diff --git a/lib/routemap.h b/lib/routemap.h
index a6f3c5db4..73874d6b7 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -185,16 +185,16 @@ route_map_install_set (struct route_map_rule_cmd *cmd);
/* Lookup route map by name. */
struct route_map *
-route_map_lookup_by_name (char *name);
+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) (char *));
-void route_map_delete_hook (void (*func) (char *));
-void route_map_event_hook (void (*func) (route_map_event_t, char *));
+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 *));
#endif /* _ZEBRA_ROUTEMAP_H */
diff --git a/lib/smux.c b/lib/smux.c
index 7e0a2ecf6..5831b818a 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -61,7 +61,7 @@ size_t smux_default_oid_len;
/* SMUX password. */
char *smux_passwd;
-char *smux_default_passwd = "";
+const char *smux_default_passwd = "";
/* SMUX read threads. */
struct thread *smux_read_thread;
@@ -160,9 +160,9 @@ oid_compare_part (oid *o1, int o1_len, oid *o2, int o2_len)
}
void
-smux_oid_dump (char *prefix, oid *oid, size_t oid_len)
+smux_oid_dump (const char *prefix, oid *oid, size_t oid_len)
{
- int i;
+ unsigned int i;
int first = 1;
char buf[MAX_OID_LEN * 3];
@@ -1004,7 +1004,7 @@ smux_trap (oid *name, size_t namelen,
struct trap_object *trapobj, size_t trapobjlen,
unsigned int tick, u_char sptrap)
{
- int i;
+ unsigned int i;
u_char buf[BUFSIZ];
u_char *ptr;
int len, length;
@@ -1249,7 +1249,7 @@ smux_event (enum smux_event event, int sock)
}
int
-smux_str2oid (char *str, oid *oid, size_t *oid_len)
+smux_str2oid (const char *str, oid *oid, size_t *oid_len)
{
int len;
int val;
@@ -1303,7 +1303,7 @@ smux_oid_dup (oid *objid, size_t objid_len)
}
int
-smux_peer_oid (struct vty *vty, char *oid_str, char *passwd_str)
+smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
{
int ret;
oid oid[MAX_OID_LEN];
@@ -1319,6 +1319,7 @@ smux_peer_oid (struct vty *vty, char *oid_str, char *passwd_str)
if (smux_oid && smux_oid != smux_default_oid)
free (smux_oid);
+ /* careful, smux_passwd might point to string constant */
if (smux_passwd && smux_passwd != smux_default_passwd)
{
free (smux_passwd);
@@ -1369,10 +1370,12 @@ smux_peer_default ()
smux_oid = smux_default_oid;
smux_oid_len = smux_default_oid_len;
}
+
+ /* careful, smux_passwd might be pointing at string constant */
if (smux_passwd != smux_default_passwd)
{
free (smux_passwd);
- smux_passwd = smux_default_passwd;
+ smux_passwd = (char *)smux_default_passwd;
}
return CMD_SUCCESS;
}
@@ -1425,7 +1428,7 @@ int
config_write_smux (struct vty *vty)
{
int first = 1;
- int i;
+ unsigned int i;
if (smux_oid != smux_default_oid || smux_passwd != smux_default_passwd)
{
@@ -1482,7 +1485,9 @@ smux_init (struct thread_master *tm, oid defoid[], size_t defoid_len)
smux_oid = smux_default_oid;
smux_oid_len = smux_default_oid_len;
- smux_passwd = smux_default_passwd;
+
+ /* be careful with smux_passwd, points to string constant by default */
+ smux_passwd = (char *)smux_default_passwd;
/* copy callers thread master */
master = tm;
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 5936d6610..c448d3085 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -46,6 +46,8 @@ getsockopt_cmsg_data (struct msghdr *msgh, int level, int type)
cmsg = CMSG_NXTHDR(msgh, cmsg))
if (cmsg->cmsg_level == level && cmsg->cmsg_type)
return (ptr = CMSG_DATA(cmsg));
+
+ return NULL;
}
#ifdef HAVE_IPV6
diff --git a/lib/vty.c b/lib/vty.c
index 42b7e9251..d21f38c93 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2422,7 +2422,7 @@ DEFUN (line_vty,
/* Set time out value. */
int
-exec_timeout (struct vty *vty, char *min_str, char *sec_str)
+exec_timeout (struct vty *vty, const char *min_str, const char *sec_str)
{
unsigned long timeout = 0;