The branch, master has been updated via 38492b1 Fixup build without --with-aio. via 9efea96 More const compiler warning fixes. via 4f41be3 Fix many const compiler warnings. via 10a628b Don't reuse a non-const pointer when manipulating const. from 1c407da s3: Fix a typo
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 38492b16fee29f31b324ec459069470e977a2359 Author: Jeremy Allison <j...@samba.org> Date: Thu May 5 11:38:06 2011 -0700 Fixup build without --with-aio. Autobuild-User: Jeremy Allison <j...@samba.org> Autobuild-Date: Thu May 5 21:38:23 CEST 2011 on sn-devel-104 commit 9efea96d16a9f9526669e7d9288902a15d0ee549 Author: Jeremy Allison <j...@samba.org> Date: Thu May 5 11:29:01 2011 -0700 More const compiler warning fixes. commit 4f41be356a4e6b311d30de3b2e36e4c33aa72ca3 Author: Jeremy Allison <j...@samba.org> Date: Thu May 5 10:41:59 2011 -0700 Fix many const compiler warnings. commit 10a628b6e181af07f0c43db36ba017411b4eaaaa Author: Jeremy Allison <j...@samba.org> Date: Thu May 5 10:41:40 2011 -0700 Don't reuse a non-const pointer when manipulating const. ----------------------------------------------------------------------- Summary of changes: lib/util/charset/util_str.c | 2 +- lib/util/charset/util_unistr_w.c | 6 ++-- source3/include/proto.h | 2 +- source3/include/smb.h | 2 +- source3/include/smb_macros.h | 1 + source3/lib/tldap.c | 10 ++++---- source3/lib/util.c | 4 +- source3/lib/util_sid.c | 2 +- source3/lib/winbind_util.c | 2 +- source3/librpc/crypto/gse.c | 44 +++++++++++++++++---------------- source3/libsmb/libsmb_context.c | 6 ++-- source3/libsmb/libsmb_file.c | 2 +- source3/nmbd/nmbd_elections.c | 2 +- source3/nmbd/nmbd_incomingdgrams.c | 20 +++++++------- source3/nmbd/nmbd_packets.c | 10 ++++---- source3/nmbd/nmbd_processlogon.c | 2 +- source3/nmbd/nmbd_proto.h | 22 ++++++++-------- source3/registry/reg_util_internal.c | 7 ++--- source3/rpc_client/cli_pipe.c | 2 +- source3/smbd/aio.c | 6 ++-- source3/smbd/blocking.c | 4 +- source3/smbd/filename.c | 2 +- source3/smbd/ipc.c | 2 +- source3/smbd/nttrans.c | 4 +- source3/smbd/perfcount.c | 2 +- source3/smbd/pipes.c | 4 +- source3/smbd/process.c | 32 ++++++++++++------------ source3/smbd/proto.h | 2 +- source3/smbd/reply.c | 14 +++++----- source3/smbd/seal.c | 2 +- source3/smbd/trans2.c | 6 ++-- source3/smbd/vfs.c | 2 +- source4/libcli/raw/smb.h | 2 +- 33 files changed, 117 insertions(+), 115 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c index 4f4ca93..e76c1db 100644 --- a/lib/util/charset/util_str.c +++ b/lib/util/charset/util_str.c @@ -550,7 +550,7 @@ char *strstr_m(const char *src, const char *findstr) DEBUG(0,("strstr_m: dest malloc fail\n")); return NULL; } - retp = (char *)(s+strlen(s2)); + retp = discard_const_p(char, (s+strlen(s2))); TALLOC_FREE(src_w); TALLOC_FREE(find_w); TALLOC_FREE(s2); diff --git a/lib/util/charset/util_unistr_w.c b/lib/util/charset/util_unistr_w.c index 22f22ab..5b61d52 100644 --- a/lib/util/charset/util_unistr_w.c +++ b/lib/util/charset/util_unistr_w.c @@ -72,12 +72,12 @@ smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c) smb_ucs2_t cp; while (*(COPY_UCS2_CHAR(&cp,s))) { if (c == cp) { - return (smb_ucs2_t *)s; + return discard_const_p(smb_ucs2_t, s); } s++; } if (c == cp) { - return (smb_ucs2_t *)s; + return discard_const_p(smb_ucs2_t, s); } return NULL; @@ -104,7 +104,7 @@ smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c) p += (len - 1); do { if (c == *(COPY_UCS2_CHAR(&cp,p))) { - return (smb_ucs2_t *)p; + return discard_const_p(smb_ucs2_t, p); } } while (p-- != s); return NULL; diff --git a/source3/include/proto.h b/source3/include/proto.h index 2dd30d9..2305a7a 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -615,7 +615,7 @@ bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf, bool socket_exist(const char *fname); uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf); SMB_OFF_T get_file_size(char *file_name); -void show_msg(char *buf); +void show_msg(const char *buf); void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num); void smb_setlen(char *buf,int len); int set_message_bcc(char *buf,int num_bytes); diff --git a/source3/include/smb.h b/source3/include/smb.h index 57de387..28bc49f 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1205,7 +1205,7 @@ struct bitmap { /* where to find the base of the SMB packet proper */ -#define smb_base(buf) (((char *)(buf))+4) +#define smb_base(buf) (((const char *)(buf))+4) /* we don't allow server strings to be longer than 48 characters as otherwise NT will not honour the announce packets */ diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 79aa4c5..f7cfaaf 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -123,6 +123,7 @@ /* Extra macros added by Ying Chen at IBM - speed increase by inlining. */ #define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2) +#define smb_buf_const(buf) (((const char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2) #define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2)) /* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */ diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c index ba27028..3afdaea 100644 --- a/source3/lib/tldap.c +++ b/source3/lib/tldap.c @@ -189,7 +189,7 @@ bool tldap_context_setattr(struct tldap_context *ld, struct tldap_ctx_attribute *tmp, *attr; char *tmpname; int num_attrs; - void **pptr = (void **)_pptr; + void **pptr = (void **)discard_const_p(void,_pptr); attr = tldap_context_findattr(ld, name); if (attr != NULL) { @@ -935,10 +935,10 @@ struct tevent_req *tldap_simple_bind_send(TALLOC_CTX *mem_ctx, DATA_BLOB cred; if (passwd != NULL) { - cred.data = (uint8_t *)passwd; + cred.data = discard_const_p(uint8_t, passwd); cred.length = strlen(passwd); } else { - cred.data = (uint8_t *)""; + cred.data = discard_const_p(uint8_t, ""); cred.length = 0; } return tldap_sasl_bind_send(mem_ctx, ev, ld, dn, NULL, &cred, NULL, 0, @@ -956,10 +956,10 @@ int tldap_simple_bind(struct tldap_context *ld, const char *dn, DATA_BLOB cred; if (passwd != NULL) { - cred.data = (uint8_t *)passwd; + cred.data = discard_const_p(uint8_t, passwd); cred.length = strlen(passwd); } else { - cred.data = (uint8_t *)""; + cred.data = discard_const_p(uint8_t, ""); cred.length = 0; } return tldap_sasl_bind(ld, dn, NULL, &cred, NULL, 0, NULL, 0); diff --git a/source3/lib/util.c b/source3/lib/util.c index 718500a..cd856ee 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -298,7 +298,7 @@ SMB_OFF_T get_file_size(char *file_name) Show a smb message structure. ********************************************************************/ -void show_msg(char *buf) +void show_msg(const char *buf) { int i; int bcc=0; @@ -335,7 +335,7 @@ void show_msg(char *buf) if (DEBUGLEVEL < 50) bcc = MIN(bcc, 512); - dump_data(10, (uint8 *)smb_buf(buf), bcc); + dump_data(10, (const uint8 *)smb_buf(buf), bcc); } /******************************************************************* diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index ef46a38..f080d3d 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -121,7 +121,7 @@ char *sid_binstring_hex(const struct dom_sid *sid) if (!buf) return NULL; sid_linearize(buf, len, sid); - hex_encode(buf, len, &s); + hex_encode((const unsigned char *)buf, len, &s); free(buf); return s; } diff --git a/source3/lib/winbind_util.c b/source3/lib/winbind_util.c index f30bcfc..3fa1485 100644 --- a/source3/lib/winbind_util.c +++ b/source3/lib/winbind_util.c @@ -245,7 +245,7 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx, (*types)[i] = (enum lsa_SidType)name_types[i]; } - wbcFreeMemory(CONST_DISCARD(char*, dom_name)); + wbcFreeMemory(discard_const_p(char, dom_name)); wbcFreeMemory(namelist); wbcFreeMemory(name_types); diff --git a/source3/librpc/crypto/gse.c b/source3/librpc/crypto/gse.c index ca99f9b..34742bc 100644 --- a/source3/librpc/crypto/gse.c +++ b/source3/librpc/crypto/gse.c @@ -365,8 +365,6 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx, OM_uint32 gss_maj, gss_min; krb5_error_code ret; NTSTATUS status; - const char *ktname; - gss_OID_set_desc mech_set; status = gse_context_init(mem_ctx, do_sign, do_seal, NULL, add_gss_c_flags, &gse_ctx); @@ -396,24 +394,27 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx, * This call sets the default keytab for the whole server, not * just for this context. Need to find a way that does not alter * the state of the whole server ... */ + { + const char *ktname; + gss_OID_set_desc mech_set; - ret = smb_krb5_keytab_name(gse_ctx, gse_ctx->k5ctx, + ret = smb_krb5_keytab_name(gse_ctx, gse_ctx->k5ctx, gse_ctx->keytab, &ktname); - if (ret) { - status = NT_STATUS_INTERNAL_ERROR; - goto done; - } + if (ret) { + status = NT_STATUS_INTERNAL_ERROR; + goto done; + } - ret = gsskrb5_register_acceptor_identity(ktname); - if (ret) { - status = NT_STATUS_INTERNAL_ERROR; - goto done; - } + ret = gsskrb5_register_acceptor_identity(ktname); + if (ret) { + status = NT_STATUS_INTERNAL_ERROR; + goto done; + } - mech_set.count = 1; - mech_set.elements = &gse_ctx->gss_mech; - - gss_maj = gss_acquire_cred(&gss_min, + mech_set.count = 1; + mech_set.elements = &gse_ctx->gss_mech; + + gss_maj = gss_acquire_cred(&gss_min, GSS_C_NO_NAME, GSS_C_INDEFINITE, &mech_set, @@ -421,11 +422,12 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx, &gse_ctx->creds, NULL, NULL); - if (gss_maj) { - DEBUG(0, ("gss_acquire_creds failed with [%s]\n", - gse_errstr(gse_ctx, gss_maj, gss_min))); - status = NT_STATUS_INTERNAL_ERROR; - goto done; + if (gss_maj) { + DEBUG(0, ("gss_acquire_creds failed with [%s]\n", + gse_errstr(gse_ctx, gss_maj, gss_min))); + status = NT_STATUS_INTERNAL_ERROR; + goto done; + } } #endif status = NT_STATUS_OK; diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index 9c8429a..f81631e 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -456,11 +456,11 @@ smbc_option_get(SMBCCTX *context, switch(smbc_getOptionSmbEncryptionLevel(context)) { case 0: - return (void *) "none"; + return discard_const_p(void, "none"); case 1: - return (void *) "request"; + return discard_const_p(void, "request"); case 2: - return (void *) "require"; + return discard_const_p(void, "require"); } } else if (strcmp(option_name, "smb_encrypt_on") == 0) { diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 4ab6cd2..e21eff3 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -378,7 +378,7 @@ SMBC_write_ctx(SMBCCTX *context, /*d_printf(">>>write: resolved path as %s\n", targetpath);*/ status = cli_writeall(targetcli, file->cli_fd, - 0, (uint8_t *)buf, offset, count, NULL); + 0, (const uint8_t *)buf, offset, count, NULL); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); TALLOC_FREE(frame); diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c index 899c273..a7b240f 100644 --- a/source3/nmbd/nmbd_elections.c +++ b/source3/nmbd/nmbd_elections.c @@ -258,7 +258,7 @@ static bool win_election(struct work_record *work, int version, Process an incoming election datagram packet. ******************************************************************/ -void process_election(struct subnet_record *subrec, struct packet_struct *p, char *buf) +void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf) { struct dgram_packet *dgram = &p->packet.dgram; int version = CVAL(buf,0); diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c index d3b9d3d..11f3d43 100644 --- a/source3/nmbd/nmbd_incomingdgrams.c +++ b/source3/nmbd/nmbd_incomingdgrams.c @@ -95,7 +95,7 @@ void tell_become_backup(void) Process an incoming host announcement packet. *******************************************************************/ -void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf) +void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf) { struct dgram_packet *dgram = &p->packet.dgram; int ttl = IVAL(buf,1)/1000; @@ -195,7 +195,7 @@ done: Process an incoming WORKGROUP announcement packet. *******************************************************************/ -void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf) +void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf) { struct dgram_packet *dgram = &p->packet.dgram; int ttl = IVAL(buf,1)/1000; @@ -252,7 +252,7 @@ done: Process an incoming local master browser announcement packet. *******************************************************************/ -void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf) +void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf) { struct dgram_packet *dgram = &p->packet.dgram; int ttl = IVAL(buf,1)/1000; @@ -367,7 +367,7 @@ done: ******************************************************************/ void process_master_browser_announce(struct subnet_record *subrec, - struct packet_struct *p,char *buf) + struct packet_struct *p,const char *buf) { unstring local_master_name; struct work_record *work; @@ -418,7 +418,7 @@ done: Process an incoming LanMan host announcement packet. *******************************************************************/ -void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len) +void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len) { struct dgram_packet *dgram = &p->packet.dgram; uint32 servertype = IVAL(buf,1); @@ -431,7 +431,7 @@ void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct unstring work_name; unstring source_name; fstring comment; - char *s = get_safe_str_ptr(buf,len,buf,9); + char *s = get_safe_str_ptr(buf,len,discard_const_p(char, buf),9); START_PROFILE(lm_host_announce); if (!s) { @@ -641,7 +641,7 @@ static void send_backup_list_response(struct subnet_record *subrec, ********************************************************************/ void process_get_backup_list_request(struct subnet_record *subrec, - struct packet_struct *p,char *buf) + struct packet_struct *p,const char *buf) { struct dgram_packet *dgram = &p->packet.dgram; struct work_record *work; @@ -724,7 +724,7 @@ done: ******************************************************************/ void process_reset_browser(struct subnet_record *subrec, - struct packet_struct *p,char *buf) + struct packet_struct *p,const char *buf) { struct dgram_packet *dgram = &p->packet.dgram; int state = CVAL(buf,0); @@ -776,7 +776,7 @@ request from %s IP %s state=0x%X\n", announcement is needed soon. ******************************************************************/ -void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf) +void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf) { struct dgram_packet *dgram = &p->packet.dgram; struct work_record *work; @@ -817,7 +817,7 @@ done: through the "lm announce" parameter in smb.conf) ******************************************************************/ -void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len) +void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len) { struct dgram_packet *dgram = &p->packet.dgram; unstring workgroup_name; diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c index 2817ea8..36ec13f 100644 --- a/source3/nmbd/nmbd_packets.c +++ b/source3/nmbd/nmbd_packets.c @@ -108,7 +108,7 @@ void set_nb_flags(char *buf, uint16 nb_flags) Dumps out the browse packet data. **************************************************************************/ -static void debug_browse_data(char *outbuf, int len) +static void debug_browse_data(const char *outbuf, int len) { int i,j; @@ -1062,7 +1062,7 @@ static struct subnet_record *find_subnet_for_dgram_browse_packet(struct packet_s Dispatch a browse frame from port 138 to the correct processing function. ****************************************************************************/ -static void process_browse_packet(struct packet_struct *p, char *buf,int len) +static void process_browse_packet(struct packet_struct *p, const char *buf,int len) { struct dgram_packet *dgram = &p->packet.dgram; int command = CVAL(buf,0); @@ -1149,7 +1149,7 @@ command code %d from %s IP %s to %s\n", subrec->subnet_name, command, nmb_namest Dispatch a LanMan browse frame from port 138 to the correct processing function. ****************************************************************************/ -static void process_lanman_packet(struct packet_struct *p, char *buf,int len) +static void process_lanman_packet(struct packet_struct *p, const char *buf,int len) { struct dgram_packet *dgram = &p->packet.dgram; int command = SVAL(buf,0); @@ -1216,8 +1216,8 @@ static bool listening(struct packet_struct *p,struct nmb_name *nbname) static void process_dgram(struct packet_struct *p) { - char *buf; - char *buf2; + const char *buf; + const char *buf2; int len; struct dgram_packet *dgram = &p->packet.dgram; diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c index 7976817..9bb1252 100644 --- a/source3/nmbd/nmbd_processlogon.c +++ b/source3/nmbd/nmbd_processlogon.c @@ -304,7 +304,7 @@ static void nmbd_proxy_logon_done(struct tevent_req *subreq) Process a domain logon packet **************************************************************************/ -void process_logon_packet(struct packet_struct *p, char *buf,int len, +void process_logon_packet(struct packet_struct *p, const char *buf,int len, const char *mailslot) { fstring source_name; diff --git a/source3/nmbd/nmbd_proto.h b/source3/nmbd/nmbd_proto.h index b58ca41..1c6ec0c 100644 --- a/source3/nmbd/nmbd_proto.h +++ b/source3/nmbd/nmbd_proto.h @@ -48,7 +48,7 @@ void sync_all_dmbs(time_t t); void check_master_browser_exists(time_t t); void run_elections(time_t t); -void process_election(struct subnet_record *subrec, struct packet_struct *p, char *buf); +void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf); bool check_elections(void); void nmbd_message_election(struct messaging_context *msg, void *private_data, @@ -59,18 +59,18 @@ void nmbd_message_election(struct messaging_context *msg, /* The following definitions come from nmbd/nmbd_incomingdgrams.c */ void tell_become_backup(void); -void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf); -void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf); -void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf); +void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf); +void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf); +void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf); void process_master_browser_announce(struct subnet_record *subrec, - struct packet_struct *p,char *buf); -void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len); + struct packet_struct *p,const char *buf); +void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len); void process_get_backup_list_request(struct subnet_record *subrec, - struct packet_struct *p,char *buf); + struct packet_struct *p,const char *buf); void process_reset_browser(struct subnet_record *subrec, - struct packet_struct *p,char *buf); -void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf); -void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len); + struct packet_struct *p,const char *buf); +void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf); +void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len); /* The following definitions come from nmbd/nmbd_incomingrequests.c */ @@ -250,7 +250,7 @@ bool send_mailslot(bool unique, const char *mailslot,char *buf, size_t len, bool initialize_nmbd_proxy_logon(void); -void process_logon_packet(struct packet_struct *p, char *buf,int len, +void process_logon_packet(struct packet_struct *p, const char *buf,int len, const char *mailslot); /* The following definitions come from nmbd/nmbd_responserecordsdb.c */ diff --git a/source3/registry/reg_util_internal.c b/source3/registry/reg_util_internal.c index a1aeaa4..b15015b 100644 --- a/source3/registry/reg_util_internal.c +++ b/source3/registry/reg_util_internal.c @@ -97,12 +97,11 @@ char *normalize_reg_path(TALLOC_CTX *ctx, const char *keyname ) char *nkeyname; /* skip leading '\' chars */ - p = (char *)keyname; - while (*p == '\\') { - p++; + while (*keyname == '\\') { + keyname++; } - nkeyname = talloc_strdup(ctx, p); + nkeyname = talloc_strdup(ctx, keyname); -- Samba Shared Repository