]> git.puffer.fish Git - matthieu/frr.git/commitdiff
2004-10-10 Paul Jakma <paul@dishone.st>
authorpaul <paul>
Sun, 10 Oct 2004 11:56:56 +0000 (11:56 +0000)
committerpaul <paul>
Sun, 10 Oct 2004 11:56:56 +0000 (11:56 +0000)
* 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.

23 files changed:
lib/ChangeLog
lib/buffer.c
lib/buffer.h
lib/command.c
lib/command.h
lib/distribute.c
lib/distribute.h
lib/filter.c
lib/if.c
lib/if.h
lib/if_rmap.c
lib/if_rmap.h
lib/log.c
lib/log.h
lib/memory.c
lib/memory.h
lib/plist.c
lib/plist.h
lib/routemap.c
lib/routemap.h
lib/smux.c
lib/sockopt.c
lib/vty.c

index 05317db5adc639a1e2d5aeea3e63663dc236bba5..dc8fae8a9ae994415e116b4140506432249ce746 100644 (file)
@@ -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.
index 6fd9a2bb03f6807c244d6f4f0a12e375e860a8ac..904b4aa9b9a4cc85d83b17b997957200f56a81cb 100644 (file)
@@ -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;
 
index eaf4b88df6ca248abcdbf56ff9f81fd40c74e749..9d453b1d069e00d980e9901be05879c453ec92ca 100644 (file)
@@ -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);
index 2766a35774256241392e9386cbc99a3a9e556ce2..168fe563f0071de02e87f79952d968ca05f11697 100644 (file)
@@ -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]);
index 9e727cfb9f170a789b60c314d02d0bda0f67d209..0f806c872209efb5d23587e3f49e47c7eb20c62c 100644 (file)
@@ -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 *);
 
index 78de4bfbc8526b3f17460c76ffbacf0738034acb..48eb0403fb4ada5b080230c0a7327c9690213c61 100644 (file)
@@ -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)
 \f
 /* 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;
 
index 330126b957ab71dac4b81dc45a9e8f3604050d5a..77bb875852ecb8f0934f553e4c0f44299e6bc822 100644 (file)
@@ -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 *);
 
index ee3dbc06f776a5dc458b1a35d8f57d151deaa8bb..9817c07dec38e00d596721ad0d6aa11715e2d3e2 100644 (file)
@@ -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;
index 8fbaa76ac32ade479eb22319ce1650bc5ee2811f..259b84231ca4c01ed6d6dd51843afa40e1810db5 100644 (file)
--- 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;
 
index 47e992c36391964596175d8aeba7e4d0e2e5a79a..0f088a975dc3693d400043b25d8293294820ebe4 100644 (file)
--- 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 *);
index 0f3fa9c703d45aa4adc72118a09a460cfef5fb26..3f95af39c219511eaccb9b4e360666eee9ec0ef6 100644 (file)
@@ -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)
 }
 \f
 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;
 
index a9355ab99a3fba160070cfe0301a49aa291c826b..540d68fc216592bb5c986e98ea86ab14110edd1a 100644 (file)
@@ -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 */
index bbe6e99671055676f4102c79bf84690a5c47f0cf..375730f2263730cf135c22934089a3bf287c1b6e 100644 (file)
--- 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;
index e2eeb826f5a0d84935e5d72c42473c6a8424af98..9f6ec3bec4d18a47d45ccdb5fc413feef1f18ec1 100644 (file)
--- 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. */
index 8b311aeacd8fab736db14d9778c961c771d608e9..bef0997f79fbfaffe5fee56a411cd91f3d5f252e 100644 (file)
@@ -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       " },
index c2d595a47967f267b1894f9ea63df56fd8ea2523..2f403a145f3af53b9c1c0972e3d63704be794451 100644 (file)
@@ -75,7 +75,9 @@ enum
   MTYPE_ROUTE_MAP_COMPILED,
 
   MTYPE_RIB,
+  
   MTYPE_DISTRIBUTE,
+  MTYPE_DISTRIBUTE_IFNAME,
   MTYPE_ZLOG,
   MTYPE_ZCLIENT,
   MTYPE_NEXTHOP,
index ef2fffc29d0a170c5f7c836d569acfbf6c4dfc79..3520f82f0f106656c91a061b1a02c4f4fb475add 100644 (file)
@@ -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;
index 9a9eb710174612c2ec7c49d42446ee6cfd478ab8..01ac9874d583397eb60e7326146811ff2246d336 100644 (file)
@@ -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 *
index 748aa2cf8ab8cd6b8620c94570332857e7f8f481..cd231be7d13e7cbda3afcce78ab97cdc5a9f1216 100644 (file)
@@ -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;
 }
index a6f3c5db41744509d1392083294043c2be7b5ca6..73874d6b7c566b291482a8c9ccb70dd418259aaa 100644 (file)
@@ -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 */
index 7e0a2ecf650b21ad6720469dd4752697886503a4..5831b818af03aa86bc21e719e645e5f361ec7dce 100644 (file)
@@ -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)
 }
 \f
 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)
 }
 \f
 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;
index 5936d6610ea5bddacea02ce3d21a7b8c7c66df76..c448d308543c819b835ce5a2f34932047ae4ca81 100644 (file)
@@ -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
index 42b7e92511ca9ab555aae6099d385154b00fa512..d21f38c93e75dd0288cd57f3eea12372c8376bea 100644 (file)
--- 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;