diff options
author | paul <paul> | 2004-10-10 11:56:56 +0000 |
---|---|---|
committer | paul <paul> | 2004-10-10 11:56:56 +0000 |
commit | 9035efaa924c69f4f4fcb1049c7dc4f43b9da980 (patch) | |
tree | f81d25b0e069ad8fb5f2843172a4e60fa0d6cbdf /lib/smux.c | |
parent | ddd119fd3d94e95dd44aa9fb3bc3fca4f26078a0 (diff) |
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/smux.c')
-rw-r--r-- | lib/smux.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -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; |