summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/addns/dnsgss.c4
-rw-r--r--lib/addns/dnsrecord.c2
-rw-r--r--libcli/auth/krb5_wrap.c4
-rw-r--r--libgpo/gpext/gpext.c2
-rw-r--r--nsswitch/pam_winbind.c2
-rw-r--r--source3/auth/auth_server.c2
-rw-r--r--source3/include/includes.h4
-rw-r--r--source3/include/popt_common.h2
-rw-r--r--source3/lib/smbldap.c4
-rw-r--r--source3/lib/tldap_util.c2
-rw-r--r--source3/libsmb/clikrb5.c2
-rw-r--r--source3/modules/vfs_acl_common.c10
-rw-r--r--source3/modules/vfs_fileid.c2
-rw-r--r--source3/modules/vfs_gpfs.c10
-rw-r--r--source3/modules/vfs_hpuxacl.c8
-rw-r--r--source3/modules/vfs_shadow_copy2.c4
-rw-r--r--source3/modules/vfs_smb_traffic_analyzer.c6
-rw-r--r--source3/modules/vfs_streams_xattr.c4
-rw-r--r--source3/modules/vfs_xattr_tdb.c2
-rw-r--r--source3/pam_smbpass/support.c8
-rw-r--r--source3/passdb/pdb_ldap.c12
-rw-r--r--source3/registry/reg_parse.c2
-rw-r--r--source3/rpc_server/rpc_handles.c4
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.c4
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c10
-rw-r--r--source3/rpc_server/srv_pipe_hnd.h2
-rw-r--r--source3/smbd/dmapi.c4
-rw-r--r--source3/smbd/filename.c2
-rw-r--r--source3/torture/mangle_test.c2
-rw-r--r--source3/utils/eventlogadm.c2
-rw-r--r--source3/utils/net_printing.c2
-rw-r--r--source3/utils/ntlm_auth.c6
-rw-r--r--source3/utils/smbcontrol.c4
-rw-r--r--source3/utils/smbget.c2
-rw-r--r--source3/winbindd/idmap_adex/domain_util.c2
-rw-r--r--source3/winbindd/idmap_adex/provider_unified.c2
-rw-r--r--source3/winbindd/winbindd_msrpc.c2
37 files changed, 71 insertions, 77 deletions
diff --git a/lib/addns/dnsgss.c b/lib/addns/dnsgss.c
index c9037417da..19b734a6a3 100644
--- a/lib/addns/dnsgss.c
+++ b/lib/addns/dnsgss.c
@@ -92,7 +92,7 @@ static DNS_ERROR dns_negotiate_gss_ctx_int( TALLOC_CTX *mem_ctx,
DNS_ERROR err;
gss_OID_desc krb5_oid_desc =
- { 9, (char *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" };
+ { 9, (const char *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" };
*ctx = GSS_C_NO_CONTEXT;
input_ptr = NULL;
@@ -222,7 +222,7 @@ DNS_ERROR dns_negotiate_sec_ctx( const char *target_realm,
gss_name_t targ_name;
gss_OID_desc nt_host_oid_desc =
- {10, (char *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01"};
+ {10, (const char *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01"};
TALLOC_CTX *mem_ctx;
diff --git a/lib/addns/dnsrecord.c b/lib/addns/dnsrecord.c
index 559c2644d4..528fdf29ab 100644
--- a/lib/addns/dnsrecord.c
+++ b/lib/addns/dnsrecord.c
@@ -131,7 +131,7 @@ DNS_ERROR dns_create_a_record(TALLOC_CTX *mem_ctx, const char *host,
return ERROR_DNS_SUCCESS;
}
- ip = ((struct sockaddr_in *)pss)->sin_addr;
+ ip = ((const struct sockaddr_in *)pss)->sin_addr;
if (!(data = (uint8 *)TALLOC_MEMDUP(mem_ctx, (const void *)&ip.s_addr,
sizeof(ip.s_addr)))) {
return ERROR_DNS_NO_MEMORY;
diff --git a/libcli/auth/krb5_wrap.c b/libcli/auth/krb5_wrap.c
index 7725261408..485a722d8c 100644
--- a/libcli/auth/krb5_wrap.c
+++ b/libcli/auth/krb5_wrap.c
@@ -203,8 +203,8 @@ krb5_error_code smb_krb5_unparse_name(TALLOC_CTX *mem_ctx,
for (i = 0; i < len1; i++) {
- p1 = krb5_princ_component(context, CONST_DISCARD(krb5_principal, princ1), i);
- p2 = krb5_princ_component(context, CONST_DISCARD(krb5_principal, princ2), i);
+ p1 = krb5_princ_component(context, discard_const(krb5_principal, princ1), i);
+ p2 = krb5_princ_component(context, discard_const(krb5_principal, princ2), i);
if (p1->length != p2->length || memcmp(p1->data, p2->data, p1->length))
return False;
diff --git a/libgpo/gpext/gpext.c b/libgpo/gpext/gpext.c
index 080bf07452..f38d87358a 100644
--- a/libgpo/gpext/gpext.c
+++ b/libgpo/gpext/gpext.c
@@ -442,7 +442,7 @@ static WERROR gp_extension_store_reg_entry(TALLOC_CTX *mem_ctx,
subkeyname = GUID_string2(mem_ctx, &entry->guid);
W_ERROR_HAVE_NO_MEMORY(subkeyname);
- strupper_m(CONST_DISCARD(char *,subkeyname));
+ strupper_m(discard_const_p(char, subkeyname));
werr = gp_store_reg_subkey(mem_ctx,
subkeyname,
diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c
index a385e744cc..f7637e7ea7 100644
--- a/nsswitch/pam_winbind.c
+++ b/nsswitch/pam_winbind.c
@@ -11,8 +11,6 @@
*/
#include "pam_winbind.h"
-#define CONST_DISCARD(type,ptr) ((type)(void *)ptr)
-
static int wbc_error_to_pam_error(wbcErr status)
{
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index 5dc8ea7f04..37705c7b19 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -258,7 +258,7 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
/* The return must be allocated on the caller's mem_ctx, as our own will be
destoyed just after the call. */
- return data_blob_talloc((TALLOC_CTX *)auth_context, cli->secblob.data,8);
+ return data_blob_talloc(discard_const_p(TALLOC_CTX, auth_context), cli->secblob.data,8);
} else {
return data_blob_null;
}
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 0079619372..59aa45afd7 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -652,10 +652,6 @@ char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) PRINTF_ATT
#undef HAVE_MMAP
#endif
-#ifndef CONST_DISCARD
-#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
-#endif
-
void dump_core(void) _NORETURN_;
void exit_server(const char *const reason) _NORETURN_;
void exit_server_cleanly(const char *const reason) _NORETURN_;
diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h
index 70d7278f01..10dd2f4ebe 100644
--- a/source3/include/popt_common.h
+++ b/source3/include/popt_common.h
@@ -42,7 +42,7 @@ extern const struct poptOption popt_common_dynconfig[];
#define POPT_COMMON_CONFIGFILE { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile, 0, "Common samba config:", NULL },
#define POPT_COMMON_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL },
#define POPT_COMMON_DYNCONFIG { NULL, 0, POPT_ARG_INCLUDE_TABLE, \
- CONST_DISCARD(poptOption *, popt_common_dynconfig), 0, \
+ discard_const_p(poptOption, popt_common_dynconfig), 0, \
"Build-time configuration overrides:", NULL },
#define POPT_COMMON_DEBUGLEVEL { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debuglevel, 0, "Common samba debugging:", NULL },
#define POPT_COMMON_OPTION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_option, 0, "Common samba commandline config:", NULL },
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index 002b1706b2..d7d06e9e08 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -1480,7 +1480,7 @@ static int smbldap_search_ext(struct smbldap_state *ldap_state,
while (another_ldap_try(ldap_state, &rc, &attempts, endtime)) {
rc = ldap_search_ext_s(ldap_state->ldap_struct, base, scope,
utf8_filter,
- CONST_DISCARD(char **, attrs),
+ discard_const_p(char *, attrs),
attrsonly, sctrls, cctrls, &timeout,
sizelimit, res);
if (rc != LDAP_SUCCESS) {
@@ -1924,7 +1924,7 @@ static bool smbldap_check_root_dse(LDAP *ld, const char **attrs, const char *val
}
rc = ldap_search_s(ld, "", LDAP_SCOPE_BASE,
- "(objectclass=*)", CONST_DISCARD(char **, attrs), 0 , &msg);
+ "(objectclass=*)", discard_const_p(char *, attrs), 0 , &msg);
if (rc != LDAP_SUCCESS) {
DEBUG(3,("smbldap_check_root_dse: Could not search rootDSE\n"));
diff --git a/source3/lib/tldap_util.c b/source3/lib/tldap_util.c
index 0c22d6564e..e4cb5f040b 100644
--- a/source3/lib/tldap_util.c
+++ b/source3/lib/tldap_util.c
@@ -325,7 +325,7 @@ bool tldap_make_mod_fmt(struct tldap_message *existing, TALLOC_CTX *mem_ctx,
blob.length = strlen(newval);
if (blob.length != 0) {
- blob.data = CONST_DISCARD(uint8_t *, newval);
+ blob.data = discard_const_p(uint8_t, newval);
}
ret = tldap_make_mod_blob_int(existing, mem_ctx, pmods, pnum_mods,
attrib, blob, compare_utf8_blobs);
diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c
index df8ba0ac40..73a37b3115 100644
--- a/source3/libsmb/clikrb5.c
+++ b/source3/libsmb/clikrb5.c
@@ -721,7 +721,7 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context,
retval = krb5_fwd_tgt_creds(context,/* Krb5 context [in] */
*auth_context, /* Authentication context [in] */
- CONST_DISCARD(char *, KRB5_TGS_NAME), /* Ticket service name ("krbtgt") [in] */
+ discard_const_p(char, KRB5_TGS_NAME), /* Ticket service name ("krbtgt") [in] */
credsp->client, /* Client principal for the tgt [in] */
credsp->server, /* Server principal for the tgt [in] */
ccache, /* Credential cache to use for storage [in] */
diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index 6c57acb13d..a1771464fa 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -144,7 +144,7 @@ static NTSTATUS create_acl_blob(const struct security_descriptor *psd,
xacl.version = 3;
xacl.info.sd_hs3 = &sd_hs3;
- xacl.info.sd_hs3->sd = CONST_DISCARD(struct security_descriptor *, psd);
+ xacl.info.sd_hs3->sd = discard_const_p(struct security_descriptor, psd);
xacl.info.sd_hs3->hash_type = hash_type;
memcpy(&xacl.info.sd_hs3->hash[0], hash, XATTR_SD_HASH_SIZE);
@@ -190,7 +190,7 @@ static void add_directory_inheritable_components(vfs_handle_struct *handle,
/* Fake a quick smb_filename. */
ZERO_STRUCT(smb_fname);
smb_fname.st = *psbuf;
- smb_fname.base_name = CONST_DISCARD(char *, name);
+ smb_fname.base_name = discard_const_p(char, name);
dir_mode = unix_mode(conn,
FILE_ATTRIBUTE_DIRECTORY, &smb_fname, NULL);
@@ -729,7 +729,7 @@ static NTSTATUS fset_nt_acl_common(vfs_handle_struct *handle, files_struct *fsp,
DEBUG(10,("fset_nt_acl_xattr: incoming sd for file %s\n",
fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor,
- CONST_DISCARD(struct security_descriptor *,orig_psd));
+ discard_const_p(struct security_descriptor, orig_psd));
}
status = get_nt_acl_internal(handle, fsp,
@@ -784,7 +784,7 @@ static NTSTATUS fset_nt_acl_common(vfs_handle_struct *handle, files_struct *fsp,
DEBUG(10,("fset_nt_acl_xattr: storing xattr sd for file %s\n",
fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor,
- CONST_DISCARD(struct security_descriptor *,psd));
+ discard_const_p(struct security_descriptor, psd));
}
create_acl_blob(psd, &blob, XATTR_SD_HASH_TYPE_SHA256, hash);
store_acl_blob_fsp(handle, fsp, &blob);
@@ -836,7 +836,7 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
}
ZERO_STRUCT(local_fname);
- local_fname.base_name = CONST_DISCARD(char *,final_component);
+ local_fname.base_name = discard_const_p(char, final_component);
/* Must use lstat here. */
ret = SMB_VFS_LSTAT(conn, &local_fname);
diff --git a/source3/modules/vfs_fileid.c b/source3/modules/vfs_fileid.c
index 4c230a0566..642628082a 100644
--- a/source3/modules/vfs_fileid.c
+++ b/source3/modules/vfs_fileid.c
@@ -144,7 +144,7 @@ static uint64_t fileid_device_mapping_fsname(struct fileid_handle_data *data,
if (!m) return dev;
if (m->devid == (uint64_t)-1) {
- m->devid = fileid_uint64_hash((uint8_t *)m->mnt_fsname,
+ m->devid = fileid_uint64_hash((const uint8_t *)m->mnt_fsname,
strlen(m->mnt_fsname));
}
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 7d5d199405..d52122c25b 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -998,7 +998,7 @@ static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path,
}
- ret = set_gpfs_winattrs(CONST_DISCARD(char *, path),
+ ret = set_gpfs_winattrs(discard_const_p(char, path),
GPFS_WINATTR_SET_ATTRS, &attrs);
if ( ret == -1){
if (errno == ENOSYS) {
@@ -1029,7 +1029,7 @@ static ssize_t gpfs_get_xattr(struct vfs_handle_struct *handle, const char *pat
return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
}
- ret = get_gpfs_winattrs(CONST_DISCARD(char *, path), &attrs);
+ ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
if ( ret == -1){
if (errno == ENOSYS) {
return SMB_VFS_NEXT_GETXATTR(handle, path, name, value,
@@ -1083,7 +1083,7 @@ static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
errno = map_errno_from_nt_status(status);
return -1;
}
- ret = get_gpfs_winattrs(CONST_DISCARD(char *, fname), &attrs);
+ ret = get_gpfs_winattrs(discard_const_p(char, fname), &attrs);
TALLOC_FREE(fname);
if (ret == 0) {
smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
@@ -1131,7 +1131,7 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
errno = map_errno_from_nt_status(status);
return -1;
}
- ret = get_gpfs_winattrs(CONST_DISCARD(char *, path), &attrs);
+ ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
TALLOC_FREE(path);
if (ret == 0) {
smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
@@ -1172,7 +1172,7 @@ static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
attrs.creationTime.tv_sec = ft->create_time.tv_sec;
attrs.creationTime.tv_nsec = ft->create_time.tv_nsec;
- ret = set_gpfs_winattrs(CONST_DISCARD(char *, path),
+ ret = set_gpfs_winattrs(discard_const_p(char, path),
GPFS_WINATTR_SET_CREATION_TIME, &attrs);
if(ret == -1 && errno != ENOSYS){
DEBUG(1,("vfs_gpfs_ntimes: set GPFS ntimes failed %d\n",ret));
diff --git a/source3/modules/vfs_hpuxacl.c b/source3/modules/vfs_hpuxacl.c
index 2155945b95..8a57444352 100644
--- a/source3/modules/vfs_hpuxacl.c
+++ b/source3/modules/vfs_hpuxacl.c
@@ -307,7 +307,7 @@ int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
}
DEBUG(10, ("resulting acl is valid.\n"));
- ret = acl(CONST_DISCARD(char *, smb_fname->base_name), ACL_SET, count,
+ ret = acl(discard_const_p(char, smb_fname->base_name), ACL_SET, count,
hpux_acl);
if (ret != 0) {
DEBUG(0, ("ERROR calling acl: %s\n", strerror(errno)));
@@ -394,7 +394,7 @@ int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
DEBUG(10, ("resulting acl is not valid!\n"));
goto done;
}
- ret = acl(CONST_DISCARD(char *, path), ACL_SET, count, hpux_acl);
+ ret = acl(discard_const_p(char, path), ACL_SET, count, hpux_acl);
if (ret != 0) {
DEBUG(10, ("settinge file acl failed!\n"));
}
@@ -682,7 +682,7 @@ static bool hpux_acl_get_file(const char *name, HPUX_ACL_T *hpux_acl,
* instantiated or malloced each time this function is
* called). Btw: the count parameter does not seem to matter...
*/
- *count = acl(CONST_DISCARD(char *, name), ACL_CNT, 0, &dummy_ace);
+ *count = acl(discard_const_p(char, name), ACL_CNT, 0, &dummy_ace);
if (*count < 0) {
DEBUG(10, ("acl ACL_CNT failed: %s\n", strerror(errno)));
goto done;
@@ -692,7 +692,7 @@ static bool hpux_acl_get_file(const char *name, HPUX_ACL_T *hpux_acl,
DEBUG(10, ("error allocating memory for hpux acl...\n"));
goto done;
}
- *count = acl(CONST_DISCARD(char *, name), ACL_GET, *count, *hpux_acl);
+ *count = acl(discard_const_p(char, name), ACL_GET, *count, *hpux_acl);
if (*count < 0) {
DEBUG(10, ("acl ACL_GET failed: %s\n", strerror(errno)));
goto done;
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index df3bde72c9..3613f25b92 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -825,12 +825,12 @@ static int shadow_copy2_chmod_acl(vfs_handle_struct *handle,
static int shadow_copy2_label_cmp_asc(const void *x, const void *y)
{
- return strncmp((char *)x, (char *)y, sizeof(SHADOW_COPY_LABEL));
+ return strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
}
static int shadow_copy2_label_cmp_desc(const void *x, const void *y)
{
- return -strncmp((char *)x, (char *)y, sizeof(SHADOW_COPY_LABEL));
+ return -strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
}
/*
diff --git a/source3/modules/vfs_smb_traffic_analyzer.c b/source3/modules/vfs_smb_traffic_analyzer.c
index e8aa385d69..d1340c310c 100644
--- a/source3/modules/vfs_smb_traffic_analyzer.c
+++ b/source3/modules/vfs_smb_traffic_analyzer.c
@@ -174,7 +174,7 @@ static char *smb_traffic_analyzer_encrypt( TALLOC_CTX *ctx,
char *output;
unsigned char crypted[18];
if (akey == NULL) return NULL;
- samba_AES_set_encrypt_key((unsigned char *) akey, 128, &key);
+ samba_AES_set_encrypt_key((const unsigned char *) akey, 128, &key);
s1 = strlen(str) / 16;
s2 = strlen(str) % 16;
for (h = 0; h < s2; h++) *(filler+h)=*(str+(s1*16)+h);
@@ -183,10 +183,10 @@ static char *smb_traffic_analyzer_encrypt( TALLOC_CTX *ctx,
output = talloc_array(ctx, char, (s1*16)+17 );
d=0;
for (h = 0; h < s1; h++) {
- samba_AES_encrypt((unsigned char *) str+(16*h), crypted, &key);
+ samba_AES_encrypt((const unsigned char *) str+(16*h), crypted, &key);
for (d = 0; d<16; d++) output[d+(16*h)]=crypted[d];
}
- samba_AES_encrypt( (unsigned char *) str+(16*h), filler, &key );
+ samba_AES_encrypt( (const unsigned char *) str+(16*h), filler, &key );
for (d = 0;d < 16; d++) output[d+(16*h)]=*(filler+d);
*len = (s1*16)+16;
return output;
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 34e01b0b5f..0a56b55806 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -52,9 +52,9 @@ static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
SMB_ASSERT(upper_sname != NULL);
MD5Init(&ctx);
- MD5Update(&ctx, (unsigned char *)&(sbuf->st_ex_dev),
+ MD5Update(&ctx, (const unsigned char *)&(sbuf->st_ex_dev),
sizeof(sbuf->st_ex_dev));
- MD5Update(&ctx, (unsigned char *)&(sbuf->st_ex_ino),
+ MD5Update(&ctx, (const unsigned char *)&(sbuf->st_ex_ino),
sizeof(sbuf->st_ex_ino));
MD5Update(&ctx, (unsigned char *)upper_sname,
talloc_get_size(upper_sname)-1);
diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c
index 5b62565d62..b8281dda21 100644
--- a/source3/modules/vfs_xattr_tdb.c
+++ b/source3/modules/vfs_xattr_tdb.c
@@ -314,7 +314,7 @@ static int xattr_tdb_setattr(struct db_context *db_ctx,
}
attribs->eas[i].name = name;
- attribs->eas[i].value.data = CONST_DISCARD(uint8 *, value);
+ attribs->eas[i].value.data = discard_const_p(uint8, value);
attribs->eas[i].value.length = size;
status = xattr_tdb_save_attrs(rec, attribs);
diff --git a/source3/pam_smbpass/support.c b/source3/pam_smbpass/support.c
index 79f92a8758..3dfdff3c02 100644
--- a/source3/pam_smbpass/support.c
+++ b/source3/pam_smbpass/support.c
@@ -150,7 +150,7 @@ int make_remark( pam_handle_t * pamh, unsigned int ctrl
struct pam_response *resp;
pmsg[0] = &msg[0];
- msg[0].msg = CONST_DISCARD(char *, text);
+ msg[0].msg = discard_const_p(char, text);
msg[0].msg_style = type;
resp = NULL;
@@ -550,7 +550,7 @@ int _smb_read_password( pam_handle_t * pamh, unsigned int ctrl,
if (comment != NULL && off(SMB__QUIET, ctrl)) {
pmsg[0] = &msg[0];
msg[0].msg_style = PAM_TEXT_INFO;
- msg[0].msg = CONST_DISCARD(char *, comment);
+ msg[0].msg = discard_const_p(char, comment);
i = 1;
} else {
i = 0;
@@ -558,12 +558,12 @@ int _smb_read_password( pam_handle_t * pamh, unsigned int ctrl,
pmsg[i] = &msg[i];
msg[i].msg_style = PAM_PROMPT_ECHO_OFF;
- msg[i++].msg = CONST_DISCARD(char *, prompt1);
+ msg[i++].msg = discard_const_p(char, prompt1);
if (prompt2 != NULL) {
pmsg[i] = &msg[i];
msg[i].msg_style = PAM_PROMPT_ECHO_OFF;
- msg[i++].msg = CONST_DISCARD(char *, prompt2);
+ msg[i++].msg = discard_const_p(char, prompt2);
expect = 2;
} else
expect = 1;
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 7ce5edcefa..aef1d31eb6 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -4564,7 +4564,7 @@ static bool ldapuser2displayentry(struct ldap_search_state *state,
return False;
}
if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **, &result->account_name),
+ discard_const_p(char *, &result->account_name),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
@@ -4577,7 +4577,7 @@ static bool ldapuser2displayentry(struct ldap_search_state *state,
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"displayName\" not found\n"));
else if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **, &result->fullname),
+ discard_const_p(char *, &result->fullname),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
@@ -4590,7 +4590,7 @@ static bool ldapuser2displayentry(struct ldap_search_state *state,
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"description\" not found\n"));
else if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **, &result->description),
+ discard_const_p(char *, &result->description),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
@@ -4724,7 +4724,7 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
return False;
}
if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **,
+ discard_const_p(char *,
&result->account_name),
vals[0], &converted_size))
{
@@ -4733,7 +4733,7 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
}
}
else if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **,
+ discard_const_p(char *,
&result->account_name),
vals[0], &converted_size))
{
@@ -4747,7 +4747,7 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"description\" not found\n"));
else if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **, &result->description),
+ discard_const_p(char *, &result->description),
vals[0], &converted_size))
{
DEBUG(0,("ldapgroup2displayentry: pull_utf8_talloc failed: %s",
diff --git a/source3/registry/reg_parse.c b/source3/registry/reg_parse.c
index 0c596a8f5e..f1258fca6d 100644
--- a/source3/registry/reg_parse.c
+++ b/source3/registry/reg_parse.c
@@ -622,7 +622,7 @@ static bool lookslike_utf16(const char* line, size_t len, bool* little_endian)
bool le;
size_t l = MIN(len/2, 64);
- uint16_t* u = (uint16_t*)line;
+ const uint16_t* u = (const uint16_t*)line;
int i;
assert(len >= 2);
diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c
index 0c2789e070..493149b2c3 100644
--- a/source3/rpc_server/rpc_handles.c
+++ b/source3/rpc_server/rpc_handles.c
@@ -230,7 +230,7 @@ static struct dcesrv_handle *find_policy_by_hnd_internal(struct pipes_struct *p,
for (h = p->pipe_handles->handles; h != NULL; h = h->next) {
if (memcmp(&h->wire_handle, hnd, sizeof(*hnd)) == 0) {
DEBUG(4,("Found policy hnd[%u] ", count));
- dump_data(4, (uint8 *)hnd, sizeof(*hnd));
+ dump_data(4, (const uint8 *)hnd, sizeof(*hnd));
if (data_p) {
*data_p = h->data;
}
@@ -240,7 +240,7 @@ static struct dcesrv_handle *find_policy_by_hnd_internal(struct pipes_struct *p,
}
DEBUG(4,("Policy not found: "));
- dump_data(4, (uint8_t *)hnd, sizeof(*hnd));
+ dump_data(4, (const uint8_t *)hnd, sizeof(*hnd));
p->bad_handle_fault_state = true;
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index c50e284593..720564f88d 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -575,7 +575,7 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename,
(unsigned long)strlen(handlename)));
- aprinter = CONST_DISCARD(char *, handlename);
+ aprinter = discard_const_p(char, handlename);
if ( *handlename == '\\' ) {
servername = canon_servername(handlename);
if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) {
@@ -1501,7 +1501,7 @@ static bool srv_spoolss_drv_upgrade_printer(const char *drivername,
messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
MSG_PRINTER_DRVUPGRADE,
- (uint8_t *)drivername, len+1);
+ (const uint8_t *)drivername, len+1);
return true;
}
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index 0c128a0ac5..5702a0e8d7 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -37,7 +37,7 @@
Ensures we have at least RPC_HEADER_LEN amount of data in the incoming buffer.
****************************************************************************/
-static ssize_t fill_rpc_header(struct pipes_struct *p, char *data, size_t data_to_copy)
+static ssize_t fill_rpc_header(struct pipes_struct *p, const char *data, size_t data_to_copy)
{
size_t len_needed_to_complete_hdr =
MIN(data_to_copy, RPC_HEADER_LEN - p->in_data.pdu.length);
@@ -126,7 +126,7 @@ static void free_pipe_context(struct pipes_struct *p)
Accepts incoming data on an rpc pipe. Processes the data in pdu sized units.
****************************************************************************/
-ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n)
+ssize_t process_incoming_data(struct pipes_struct *p, const char *data, size_t n)
{
size_t data_to_copy = MIN(n, RPC_MAX_PDU_FRAG_LEN
- p->in_data.pdu.length);
@@ -231,7 +231,7 @@ ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n)
Accepts incoming data on an internal rpc pipe.
****************************************************************************/
-static ssize_t write_to_internal_pipe(struct pipes_struct *p, char *data, size_t n)
+static ssize_t write_to_internal_pipe(struct pipes_struct *p, const char *data, size_t n)
{
size_t data_left = n;
@@ -535,7 +535,7 @@ struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct pipes_struct *p = talloc_get_type_abort(
handle->private_data, struct pipes_struct);
- state->nwritten = write_to_internal_pipe(p, (char *)data, len);
+ state->nwritten = write_to_internal_pipe(p, (const char *)data, len);
status = (state->nwritten >= 0)
? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR;
@@ -549,7 +549,7 @@ struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
state->ev = ev;
state->p = p;
- state->iov.iov_base = CONST_DISCARD(void *, data);
+ state->iov.iov_base = discard_const_p(void, data);
state->iov.iov_len = len;
subreq = tstream_writev_queue_send(state, ev,
diff --git a/source3/rpc_server/srv_pipe_hnd.h b/source3/rpc_server/srv_pipe_hnd.h
index 245b71979e..680add469b 100644
--- a/source3/rpc_server/srv_pipe_hnd.h
+++ b/source3/rpc_server/srv_pipe_hnd.h
@@ -46,6 +46,6 @@ struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
bool *is_data_outstanding);
-ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n);
+ssize_t process_incoming_data(struct pipes_struct *p, const char *data, size_t n);
#endif /* _RPC_SERVER_SRV_PIPE_HND_H_ */
diff --git a/source3/smbd/dmapi.c b/source3/smbd/dmapi.c
index 2869b6d781..28440783ab 100644
--- a/source3/smbd/dmapi.c
+++ b/source3/smbd/dmapi.c
@@ -289,7 +289,7 @@ uint32 dmapi_file_flags(const char * const path)
become_root();
#endif
- err = dm_path_to_handle(CONST_DISCARD(char *, path),
+ err = dm_path_to_handle(discard_const_p(char, path),
&dm_handle, &dm_handle_len);
if (err < 0) {
DEBUG(DMAPI_TRACE, ("dm_path_to_handle(%s): %s\n",
@@ -308,7 +308,7 @@ uint32 dmapi_file_flags(const char * const path)
set_effective_capability(DMAPI_ACCESS_CAPABILITY);
- err = dm_path_to_handle(CONST_DISCARD(char *, path),
+ err = dm_path_to_handle(discard_const_p(char, path),
&dm_handle, &dm_handle_len);
if (err < 0) {
DEBUG(DMAPI_TRACE,
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index f09dd12013..ec8d1139fa 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -163,7 +163,7 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
* last compnent to shorten the tree walk. */
/*
- * Safe to use CONST_DISCARD
+ * Safe to use discard_const_p
* here as last_component points
* into our smb_fname->base_name.
*/
diff --git a/source3/torture/mangle_test.c b/source3/torture/mangle_test.c
index f76ef7eebf..2794b4b57e 100644
--- a/source3/torture/mangle_test.c
+++ b/source3/torture/mangle_test.c
@@ -98,7 +98,7 @@ static bool test_one(struct cli_state *cli, const char *name)
} else {
TDB_DATA namedata;
/* store it for later */
- namedata.dptr = CONST_DISCARD(uint8 *, name);
+ namedata.dptr = discard_const_p(uint8, name);
namedata.dsize = strlen(name)+1;
tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE);
}
diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c
index 9ddd9c7df8..971a0c040a 100644
--- a/source3/utils/eventlogadm.c
+++ b/source3/utils/eventlogadm.c
@@ -178,7 +178,7 @@ static bool eventlog_add_source( const char *eventlog, const char *sourcename,
return False;
}
memcpy( wp, wrklist, sizeof( char * ) * numsources );
- *( wp + numsources ) = ( char * ) sourcename;
+ *( wp + numsources ) = (const char * ) sourcename;
*( wp + numsources + 1 ) = NULL;
if (!push_reg_multi_sz(ctx, &blob, wp)) {
return false;
diff --git a/source3/utils/net_printing.c b/source3/utils/net_printing.c
index 11c87bb5b4..ade399bf44 100644
--- a/source3/utils/net_printing.c
+++ b/source3/utils/net_printing.c
@@ -512,7 +512,7 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
continue;
}
- keyname = CONST_DISCARD(char *, r.printer_data[j].name);
+ keyname = discard_const_p(char, r.printer_data[j].name);
valuename = strchr(keyname, '\\');
if (valuename == NULL) {
continue;
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index 73f41a7fe6..72d4c053e0 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -313,13 +313,13 @@ int get_pam_winbind_config()
opt_pam_winbind_conf = PAM_WINBIND_CONFIG_FILE;
}
- d = iniparser_load(CONST_DISCARD(char *, opt_pam_winbind_conf));
+ d = iniparser_load(discard_const_p(char, opt_pam_winbind_conf));
if (!d) {
return 0;
}
- if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:krb5_auth"), false)) {
+ if (iniparser_getboolean(d, discard_const_p(char, "global:krb5_auth"), false)) {
ctrl |= WINBIND_KRB5_AUTH;
}
@@ -1722,7 +1722,7 @@ static void manage_client_ntlmssp_targ(struct spnego_data spnego)
spnego.type = SPNEGO_NEG_TOKEN_TARG;
spnego.negTokenTarg.negResult = SPNEGO_ACCEPT_INCOMPLETE;
- spnego.negTokenTarg.supportedMech = (char *)OID_NTLMSSP;
+ spnego.negTokenTarg.supportedMech = (const char *)OID_NTLMSSP;
spnego.negTokenTarg.responseToken = request;
spnego.negTokenTarg.mechListMIC = null_blob;
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index ea1b681588..0c14985bad 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -63,7 +63,7 @@ static bool send_message(struct messaging_context *msg_ctx,
if (procid_to_pid(&pid) != 0)
return NT_STATUS_IS_OK(
messaging_send_buf(msg_ctx, pid, msg_type,
- (uint8 *)buf, len));
+ (const uint8 *)buf, len));
ret = message_send_all(msg_ctx, msg_type, buf, len, &n_sent);
DEBUG(10,("smbcontrol/send_message: broadcast message to "
@@ -748,7 +748,7 @@ static bool do_printnotify(struct messaging_context *msg_ctx,
notify_printer_byname(messaging_event_context(msg_ctx),
msg_ctx, argv[2], attribute,
- CONST_DISCARD(char *, argv[4]));
+ discard_const_p(char, argv[4]));
goto send;
}
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index c1ff16bd04..d60a13fd69 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -670,7 +670,7 @@ int main(int argc, const char **argv)
if (smb_encrypt) {
SMBCCTX *smb_ctx = smbc_set_context(NULL);
smbc_option_set(smb_ctx,
- CONST_DISCARD(char *, "smb_encrypt_level"),
+ discard_const_p(char, "smb_encrypt_level"),
"require");
}
diff --git a/source3/winbindd/idmap_adex/domain_util.c b/source3/winbindd/idmap_adex/domain_util.c
index c373106446..4d2b44ff31 100644
--- a/source3/winbindd/idmap_adex/domain_util.c
+++ b/source3/winbindd/idmap_adex/domain_util.c
@@ -281,7 +281,7 @@ static struct dc_info *dc_find_domain(const char *dns_domain)
*cell = dc->domain_cell;
done:
- talloc_destroy(CONST_DISCARD(char*, base));
+ talloc_destroy(discard_const_p(char, base));
talloc_destroy(frame);
return nt_status;
diff --git a/source3/winbindd/idmap_adex/provider_unified.c b/source3/winbindd/idmap_adex/provider_unified.c
index b61666fa50..03f9d33ba3 100644
--- a/source3/winbindd/idmap_adex/provider_unified.c
+++ b/source3/winbindd/idmap_adex/provider_unified.c
@@ -237,7 +237,7 @@ static NTSTATUS search_cell(struct likewise_cell *c,
done:
PRINT_NTSTATUS_ERROR(nt_status, "search_cell", 4);
- talloc_destroy(CONST_DISCARD(char*, base));
+ talloc_destroy(discard_const_p(char, base));
talloc_destroy(frame);
return nt_status;
diff --git a/source3/winbindd/winbindd_msrpc.c b/source3/winbindd/winbindd_msrpc.c
index 1f8b398fd0..42879f2653 100644
--- a/source3/winbindd/winbindd_msrpc.c
+++ b/source3/winbindd/winbindd_msrpc.c
@@ -787,7 +787,7 @@ static int get_ldap_seq(const char *server, struct sockaddr_storage *ss, int por
to.tv_usec = 0;
if (ldap_search_st(ldp, "", LDAP_SCOPE_BASE, "(objectclass=*)",
- CONST_DISCARD(char **, attrs), 0, &to, &res))
+ discard_const_p(char *, attrs), 0, &to, &res))
goto done;
if (ldap_count_entries(ldp, res) != 1)