More const fixes. Remove CONST_DISCARD.
authorJeremy Allison <jra@samba.org>
Thu, 5 May 2011 23:19:49 +0000 (16:19 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 5 May 2011 23:44:07 +0000 (01:44 +0200)
37 files changed:
lib/addns/dnsgss.c
lib/addns/dnsrecord.c
libcli/auth/krb5_wrap.c
libgpo/gpext/gpext.c
nsswitch/pam_winbind.c
source3/auth/auth_server.c
source3/include/includes.h
source3/include/popt_common.h
source3/lib/smbldap.c
source3/lib/tldap_util.c
source3/libsmb/clikrb5.c
source3/modules/vfs_acl_common.c
source3/modules/vfs_fileid.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_hpuxacl.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_smb_traffic_analyzer.c
source3/modules/vfs_streams_xattr.c
source3/modules/vfs_xattr_tdb.c
source3/pam_smbpass/support.c
source3/passdb/pdb_ldap.c
source3/registry/reg_parse.c
source3/rpc_server/rpc_handles.c
source3/rpc_server/spoolss/srv_spoolss_nt.c
source3/rpc_server/srv_pipe_hnd.c
source3/rpc_server/srv_pipe_hnd.h
source3/smbd/dmapi.c
source3/smbd/filename.c
source3/torture/mangle_test.c
source3/utils/eventlogadm.c
source3/utils/net_printing.c
source3/utils/ntlm_auth.c
source3/utils/smbcontrol.c
source3/utils/smbget.c
source3/winbindd/idmap_adex/domain_util.c
source3/winbindd/idmap_adex/provider_unified.c
source3/winbindd/winbindd_msrpc.c

index c903741..19b734a 100644 (file)
@@ -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;
 
index 559c264..528fdf2 100644 (file)
@@ -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;
index 7725261..485a722 100644 (file)
@@ -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;
index 080bf07..f38d873 100644 (file)
@@ -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,
index a385e74..f7637e7 100644 (file)
@@ -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)
 {
index 5dc8ea7..37705c7 100644 (file)
@@ -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;
        }
index 0079619..59aa45a 100644 (file)
@@ -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_;
index 70d7278..10dd2f4 100644 (file)
@@ -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 },
index 002b170..d7d06e9 100644 (file)
@@ -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"));
index 0c22d65..e4cb5f0 100644 (file)
@@ -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);
index df8ba0a..73a37b3 100644 (file)
@@ -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] */
index 6c57acb..a177146 100644 (file)
@@ -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);
index 4c230a0..6426280 100644 (file)
@@ -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));
        }
 
index 7d5d199..d52122c 100644 (file)
@@ -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));
index 2155945..8a57444 100644 (file)
@@ -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;
index df3bde7..3613f25 100644 (file)
@@ -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));
 }
 
 /*
index e8aa385..d1340c3 100644 (file)
@@ -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;  
index 34e01b0..0a56b55 100644 (file)
@@ -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);
index 5b62565..b8281dd 100644 (file)
@@ -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);
index 79f92a8..3dfdff3 100644 (file)
@@ -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;
index 7ce5edc..aef1d31 100644 (file)
@@ -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",
index 0c596a8..f1258fc 100644 (file)
@@ -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);
index 0c2789e..493149b 100644 (file)
@@ -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;
 
index c50e284..720564f 100644 (file)
@@ -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;
 }
index 0c128a0..5702a0e 100644 (file)
@@ -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,
index 245b719..680add4 100644 (file)
@@ -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_ */
index 2869b6d..2844078 100644 (file)
@@ -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,
index f09dd12..ec8d113 100644 (file)
@@ -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.
         */
index f76ef7e..2794b4b 100644 (file)
@@ -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);
        }
index 9ddd9c7..971a0c0 100644 (file)
@@ -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;
index 11c87bb..ade399b 100644 (file)
@@ -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;
index 73f41a7..72d4c05 100644 (file)
@@ -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;
 
index ea1b681..0c14985 100644 (file)
@@ -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;
        }
index c1ff16b..d60a13f 100644 (file)
@@ -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");
        }
 
index c373106..4d2b44f 100644 (file)
@@ -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;
index b61666f..03f9d33 100644 (file)
@@ -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;
index 1f8b398..42879f2 100644 (file)
@@ -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)