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.
diff --git a/lib/smux.c b/lib/smux.c
index 7e0a2ec..5831b81 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -61,7 +61,7 @@
 
 /* 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 @@
 }
 
 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 @@
 	   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 @@
 }
 
 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 @@
 }
 
 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 @@
   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_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 @@
 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_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;