Fix many const compiler warnings.
authorJeremy Allison <jra@samba.org>
Thu, 5 May 2011 17:41:59 +0000 (10:41 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 5 May 2011 17:41:59 +0000 (10:41 -0700)
26 files changed:
lib/util/charset/util_str.c
lib/util/charset/util_unistr_w.c
source3/include/proto.h
source3/include/smb.h
source3/include/smb_macros.h
source3/lib/tldap.c
source3/lib/util.c
source3/lib/winbind_util.c
source3/librpc/crypto/gse.c
source3/libsmb/libsmb_context.c
source3/libsmb/libsmb_file.c
source3/rpc_client/cli_pipe.c
source3/smbd/aio.c
source3/smbd/blocking.c
source3/smbd/filename.c
source3/smbd/ipc.c
source3/smbd/nttrans.c
source3/smbd/perfcount.c
source3/smbd/pipes.c
source3/smbd/process.c
source3/smbd/proto.h
source3/smbd/reply.c
source3/smbd/seal.c
source3/smbd/trans2.c
source3/smbd/vfs.c
source4/libcli/raw/smb.h

index 4f4ca93cfdd8275589535c06a29b410226355b65..e76c1dbbf592b00599fb425d9f34c082fc0cd5aa 100644 (file)
@@ -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);
index 22f22ab754cefd73b90a406afcc9a5e4b378193b..5b61d52e7f88c190a02f44e983e73615ba817084 100644 (file)
@@ -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;
index 2dd30d988b079a10155bc07ffa0c1178ab92ef76..2305a7ac6871601312e564bd16b26ffbc14f7b4a 100644 (file)
@@ -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);
index 57de387661afde6c36144f61c99120eca136dd08..28bc49f85849635a2688900d21c3bf4c0d5efb8f 100644 (file)
@@ -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 */
index 79aa4c54068100f48c000a327ec793ed47d4f19e..f7cfaaf325e3fb899e03fbe0d146871923a87e38 100644 (file)
 
 /* 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'. */
index ba27028649ef91b70db09294bffe5932db3a559d..3afdaea41942f43d3ea4d51aac0a89fa093c5d05 100644 (file)
@@ -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);
index 718500a684fd2517ad9a6269eed3344b335e68bc..cd856ee3556f2aecca24acaff0afb7434dc475e4 100644 (file)
@@ -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);
 }
 
 /*******************************************************************
index f30bcfc612668ab61e0611fdc3f23d0ef8dab86c..3fa1485d45291073f73b97feb201cb0d81f1978c 100644 (file)
@@ -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);
 
index ca99f9b03ac5bf0e284d252f761145040966f426..34742bc4aa1cdbbe1c290cf3902b6cd5d0c51c9f 100644 (file)
@@ -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;
index 9c8429aab477f2f103f83ed53b8894ad8f0c64b7..f81631e5f6132b46e5cc85bf7e7fa985b9f6f68f 100644 (file)
@@ -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) {
index 4ab6cd22e53b234ce8232480c76782ed3427899a..e21eff30295ff083f3288bb72c7bfa3af23f8658 100644 (file)
@@ -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);
index d5521da50974fa0d2b4e91ac35ce2fb488cf11e4..24db5dcba6a09def7fd2dbbc1f90ee0833ed863c 100644 (file)
@@ -2581,7 +2581,7 @@ static NTSTATUS rpc_pipe_get_tcp_port(const char *host,
 
        status = dcerpc_epm_Map(epm_handle,
                                tmp_ctx,
-                               CONST_DISCARD(struct GUID *,
+                               discard_const_p(struct GUID,
                                              &(abstract_syntax->uuid)),
                                map_tower,
                                entry_handle,
index 0cb94acece851857d5c0688581ef3791405f21b9..1923c945a806c422e0899936318e23ee955cc09e 100644 (file)
@@ -251,7 +251,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
 
 NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
                              struct smb_request *smbreq,
-                             files_struct *fsp, char *data,
+                             files_struct *fsp, const char *data,
                              SMB_OFF_T startpos,
                              size_t numtowrite)
 {
@@ -329,7 +329,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
        /* Now set up the aio record for the write call. */
 
        a->aio_fildes = fsp->fh->fd;
-       a->aio_buf = data;
+       a->aio_buf = discard_const_p(char, data);
        a->aio_nbytes = numtowrite;
        a->aio_offset = startpos;
        a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
index c208234bdcf332d0ad48efc4b67c7a13018c136e..d125a74439047e118053b57e9f957eea5b2faeec 100644 (file)
@@ -337,7 +337,7 @@ static void reply_lockingX_error(struct blocking_lock_record *blr, NTSTATUS stat
        uint8_t *data;
        int i;
 
-       data = (uint8_t *)blr->req->buf
+       data = discard_const_p(uint8_t, blr->req->buf)
                + ((large_file_format ? 20 : 10)*num_ulocks);
 
        /* 
@@ -429,7 +429,7 @@ static bool process_lockingX(struct blocking_lock_record *blr)
        uint8_t *data;
        NTSTATUS status = NT_STATUS_OK;
 
-       data = (uint8_t *)blr->req->buf
+       data = discard_const_p(uint8_t, blr->req->buf)
                + ((large_file_format ? 20 : 10)*num_ulocks);
 
        /* 
index 08bc79dfd2273a7b0012e0620371a90588cd3d6e..f09dd12013b45aca0d74f624480678dbdc4e590a 100644 (file)
@@ -167,7 +167,7 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
         * here as last_component points
         * into our smb_fname->base_name.
         */
-       *pp_start = CONST_DISCARD(char *,last_component);
+       *pp_start = discard_const_p(char, last_component);
 
        /* Update dirpath. */
        TALLOC_FREE(*pp_dirpath);
index f303e8f17136616751d498469b76d0f9c138a556..7cc690451080c831acf3747536a8b20886f2a210 100644 (file)
@@ -808,7 +808,7 @@ void reply_transs(struct smb_request *req)
 
        START_PROFILE(SMBtranss);
 
-       show_msg((char *)req->inbuf);
+       show_msg((const char *)req->inbuf);
 
        if (req->wct < 8) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
index f4bd969300e1980d7abd5f833dd37df7fb667357..33f05bd789e46c87895654267156087c86a33fac 100644 (file)
@@ -2861,7 +2861,7 @@ static void handle_nttrans(connection_struct *conn,
 {
        if (get_Protocol() >= PROTOCOL_NT1) {
                req->flags2 |= 0x40; /* IS_LONG_NAME */
-               SSVAL(req->inbuf,smb_flg2,req->flags2);
+               SSVAL(discard_const_p(uint8_t, req->inbuf),smb_flg2,req->flags2);
        }
 
 
@@ -3203,7 +3203,7 @@ void reply_nttranss(struct smb_request *req)
 
        START_PROFILE(SMBnttranss);
 
-       show_msg((char *)req->inbuf);
+       show_msg((const char *)req->inbuf);
 
        if (req->wct < 18) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
index 3bc83b98d5f048aa8d97267983c71ceab40b5583..1561893758210dea733c93e80db45ddccc3967e5 100644 (file)
@@ -85,7 +85,7 @@ NTSTATUS smb_register_perfcounter(int interface_version, const char *name,
 
        entry = SMB_XMALLOC_P(struct smb_perfcount_module);
        entry->name = smb_xstrdup(name);
-       entry->handlers = (struct smb_perfcount_handlers*) handlers;
+       entry->handlers = discard_const_p(struct smb_perfcount_handlers, handlers);
 
        DLIST_ADD(modules, entry);
        DEBUG(3, ("Successfully added perfcounter module '%s'\n", name));
index 35dd9a74b905665906c946103fca27059671f1aa..c8829cd58a1a77f9414ff95e7f70005f4e8d01ae 100644 (file)
@@ -270,7 +270,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
 {
        files_struct *fsp = file_fsp(req, SVAL(req->vwv+2, 0));
        int smb_doff = SVAL(req->vwv+11, 0);
-       uint8_t *data;
+       const uint8_t *data;
        struct pipe_write_andx_state *state;
        struct tevent_req *subreq;
 
@@ -299,7 +299,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
        DEBUG(6, ("reply_pipe_write_and_X: %x name: %s len: %d\n",
                  (int)fsp->fnum, fsp_str_dbg(fsp), (int)state->numtowrite));
 
-       data = (uint8_t *)smb_base(req->inbuf) + smb_doff;
+       data = (const uint8_t *)smb_base(req->inbuf) + smb_doff;
 
        if (state->pipe_start_message_raw) {
                /*
index 169c45953466f929044d8184950f52c8097a2076..9306aa3e93ae1d9ecd426fd1ea572dd96b6aa3f3 100644 (file)
@@ -503,9 +503,9 @@ static bool init_smb_request(struct smb_request *req,
        req->vuid   = SVAL(inbuf, smb_uid);
        req->tid    = SVAL(inbuf, smb_tid);
        req->wct    = CVAL(inbuf, smb_wct);
-       req->vwv    = (uint16_t *)(inbuf+smb_vwv);
+       req->vwv    = discard_const_p(uint16_t, (inbuf+smb_vwv));
        req->buflen = smb_buflen(inbuf);
-       req->buf    = (const uint8_t *)smb_buf(inbuf);
+       req->buf    = (const uint8_t *)smb_buf_const(inbuf);
        req->unread_bytes = unread_bytes;
        req->encrypted = encrypted;
        req->sconn = sconn;
@@ -524,7 +524,7 @@ static bool init_smb_request(struct smb_request *req,
                return false;
        }
        /* Ensure bcc is correct. */
-       if (((uint8 *)smb_buf(inbuf)) + req->buflen > inbuf + req_size) {
+       if (((const uint8_t *)smb_buf_const(inbuf)) + req->buflen > inbuf + req_size) {
                DEBUG(0,("init_smb_request: invalid bcc number %u "
                        "(wct = %u, size %u)\n",
                        (unsigned int)req->buflen,
@@ -1350,7 +1350,7 @@ static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
                char *msg;
                if (asprintf(&msg, "num_bytes too large: %u",
                             (unsigned)num_bytes) == -1) {
-                       msg = CONST_DISCARD(char *, "num_bytes too large");
+                       msg = discard_const_p(char, "num_bytes too large");
                }
                smb_panic(msg);
        }
@@ -1377,7 +1377,7 @@ static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
 void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
 {
        char *outbuf;
-       if (!create_outbuf(req, req, (char *)req->inbuf, &outbuf, num_words,
+       if (!create_outbuf(req, req, (const char *)req->inbuf, &outbuf, num_words,
                           num_bytes)) {
                smb_panic("could not allocate output buffer\n");
        }
@@ -1449,7 +1449,7 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
 
        if (smb_messages[type].fn == NULL) {
                DEBUG(0,("Unknown message type %d!\n",type));
-               smb_dump("Unknown", 1, (char *)req->inbuf, size);
+               smb_dump("Unknown", 1, (const char *)req->inbuf, size);
                reply_unknown_new(req, type);
                return NULL;
        }
@@ -1464,10 +1464,10 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
        DEBUG(3,("switch message %s (pid %d) conn 0x%lx\n", smb_fn_name(type),
                 (int)sys_getpid(), (unsigned long)conn));
 
-       smb_dump(smb_fn_name(type), 1, (char *)req->inbuf, size);
+       smb_dump(smb_fn_name(type), 1, (const char *)req->inbuf, size);
 
        /* Ensure this value is replaced in the incoming packet. */
-       SSVAL(req->inbuf,smb_uid,session_tag);
+       SSVAL(discard_const_p(uint8_t, req->inbuf),smb_uid,session_tag);
 
        /*
         * Ensure the correct username is in current_user_info.  This is a
@@ -1753,7 +1753,7 @@ static void construct_reply_common(struct smb_request *req, const char *inbuf,
 
 void construct_reply_common_req(struct smb_request *req, char *outbuf)
 {
-       construct_reply_common(req, (char *)req->inbuf, outbuf);
+       construct_reply_common(req, (const char *)req->inbuf, outbuf);
 }
 
 /*
@@ -1976,9 +1976,9 @@ void chain_reply(struct smb_request *req)
        uint32_t chain_offset;  /* uint32_t to avoid overflow */
 
        uint8_t wct;
-       uint16_t *vwv;
+       const uint16_t *vwv;
        uint16_t buflen;
-       uint8_t *buf;
+       const uint8_t *buf;
 
        if (IVAL(req->outbuf, smb_rcls) != 0) {
                fixup_chain_error_packet(req);
@@ -2127,7 +2127,7 @@ void chain_reply(struct smb_request *req)
        if (length_needed > smblen) {
                goto error;
        }
-       vwv = (uint16_t *)(smb_base(req->inbuf) + chain_offset + 1);
+       vwv = (const uint16_t *)(smb_base(req->inbuf) + chain_offset + 1);
 
        /*
         * Now grab the new byte buffer....
@@ -2143,11 +2143,11 @@ void chain_reply(struct smb_request *req)
        if (length_needed > smblen) {
                goto error;
        }
-       buf = (uint8_t *)(vwv+wct+1);
+       buf = (const uint8_t *)(vwv+wct+1);
 
        req->cmd = chain_cmd;
        req->wct = wct;
-       req->vwv = vwv;
+       req->vwv = discard_const_p(uint16_t, vwv);
        req->buflen = buflen;
        req->buf = buf;
 
@@ -2613,7 +2613,7 @@ static bool smbd_echo_reply(uint8_t *inbuf, size_t inbuf_len,
                return false;
        }
 
-       if (!create_outbuf(talloc_tos(), &req, (char *)req.inbuf, &outbuf,
+       if (!create_outbuf(talloc_tos(), &req, (const char *)req.inbuf, &outbuf,
                           1, req.buflen)) {
                DEBUG(10, ("create_outbuf failed\n"));
                return false;
@@ -3162,7 +3162,7 @@ void smbd_process(struct smbd_server_connection *sconn)
 
 bool req_is_in_chain(struct smb_request *req)
 {
-       if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) {
+       if (req->vwv != (const uint16_t *)(req->inbuf+smb_vwv)) {
                /*
                 * We're right now handling a subsequent request, so we must
                 * be in a chain
index 86745f122ddf1be7cf50fa2c2a8079e30688025d..2ea01c2a5ea0ba21430f688be95db0a6e4360396 100644 (file)
@@ -23,7 +23,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
                             size_t smb_maxcnt);
 NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
                              struct smb_request *req,
-                             files_struct *fsp, char *data,
+                             files_struct *fsp, const char *data,
                              SMB_OFF_T startpos,
                              size_t numtowrite);
 NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
index 9c66ddee029b1af1aaa1120b11c86fc426e632f6..fc381d89e7f1e39de51933d350a21879466611b3 100644 (file)
@@ -314,7 +314,7 @@ size_t srvstr_get_path_req_wcard(TALLOC_CTX *mem_ctx, struct smb_request *req,
                                 char **pp_dest, const char *src, int flags,
                                 NTSTATUS *err, bool *contains_wcard)
 {
-       return srvstr_get_path_wcard(mem_ctx, (char *)req->inbuf, req->flags2,
+       return srvstr_get_path_wcard(mem_ctx, (const char *)req->inbuf, req->flags2,
                                     pp_dest, src, smbreq_bufrem(req, src),
                                     flags, err, contains_wcard);
 }
@@ -873,7 +873,7 @@ void reply_tcon_and_X(struct smb_request *req)
                 service));
 
        /* set the incoming and outgoing tid to the just created one */
-       SSVAL(req->inbuf,smb_tid,conn->cnum);
+       SSVAL(discard_const_p(uint8_t, req->inbuf),smb_tid,conn->cnum);
        SSVAL(req->outbuf,smb_tid,conn->cnum);
 
        END_PROFILE(SMBtconX);
@@ -3896,7 +3896,7 @@ void reply_writebraw(struct smb_request *req)
        size_t numtowrite=0;
        size_t tcount;
        SMB_OFF_T startpos;
-       char *data=NULL;
+       const char *data=NULL;
        bool write_through;
        files_struct *fsp;
        struct lock_struct lock;
@@ -3909,7 +3909,7 @@ void reply_writebraw(struct smb_request *req)
         * type of SMBwritec, not SMBwriteBraw, as this tells the client
         * we're finished.
         */
-       SCVAL(req->inbuf,smb_com,SMBwritec);
+       SCVAL(discard_const_p(uint8_t, req->inbuf),smb_com,SMBwritec);
 
        if (srv_is_signing_active(req->sconn)) {
                END_PROFILE(SMBwritebraw);
@@ -3955,8 +3955,8 @@ void reply_writebraw(struct smb_request *req)
                on whether we are using the core+ or lanman1.0 protocol */
 
        if(get_Protocol() <= PROTOCOL_COREPLUS) {
-               numtowrite = SVAL(smb_buf(req->inbuf),-2);
-               data = smb_buf(req->inbuf);
+               numtowrite = SVAL(smb_buf_const(req->inbuf),-2);
+               data = smb_buf_const(req->inbuf);
        } else {
                numtowrite = SVAL(req->vwv+10, 0);
                data = smb_base(req->inbuf) + SVAL(req->vwv+11, 0);
@@ -4474,7 +4474,7 @@ void reply_write_and_X(struct smb_request *req)
        ssize_t nwritten;
        unsigned int smb_doff;
        unsigned int smblen;
-       char *data;
+       const char *data;
        NTSTATUS status;
        int saved_errno = 0;
 
index b3dd84264a89c8ffc69ff71e12ff709d443ab5a8..a34a19a684d719d1b9dfc6dc0001c0c0d2777889 100644 (file)
@@ -133,7 +133,7 @@ static NTSTATUS get_srv_gss_creds(const char *service,
        NTSTATUS status = NT_STATUS_OK;
 
        gss_OID_desc nt_hostbased_service =
-       {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
+       {10, discard_const_p(char, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
 
        if (asprintf(&host_princ_s, "%s@%s", service, name) == -1) {
                return NT_STATUS_NO_MEMORY;
index 7c8b43c10c0b1ffc2cf515952fdccb926d7db2d1..733f1bc2a8143efbd752306c3b5c15f496fb540a 100644 (file)
@@ -8322,7 +8322,7 @@ static void call_trans2getdfsreferral(connection_struct *conn,
                return;
        }
 
-       SSVAL(req->inbuf, smb_flg2,
+       SSVAL((discard_const_p(uint8_t, req->inbuf)), smb_flg2,
              SVAL(req->inbuf,smb_flg2) | FLAGS2_DFS_PATHNAMES);
        send_trans2_replies(conn, req,0,0,*ppdata,reply_size, max_data_bytes);
 
@@ -8453,7 +8453,7 @@ static void handle_trans2(connection_struct *conn, struct smb_request *req,
 {
        if (get_Protocol() >= PROTOCOL_NT1) {
                req->flags2 |= 0x40; /* IS_LONG_NAME */
-               SSVAL(req->inbuf,smb_flg2,req->flags2);
+               SSVAL((discard_const_p(uint8_t, req->inbuf)),smb_flg2,req->flags2);
        }
 
        if (conn->encrypt_level == Required && !req->encrypted) {
@@ -8812,7 +8812,7 @@ void reply_transs2(struct smb_request *req)
 
        START_PROFILE(SMBtranss2);
 
-       show_msg((char *)req->inbuf);
+       show_msg((const char *)req->inbuf);
 
        if (req->wct < 8) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
index 3bde0a388e51a7eb05920935e148fa7e1314206f..e6ea34bd18481b72f30f0390db4d31155a4df7f7 100644 (file)
@@ -1506,7 +1506,7 @@ NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
                }
 
                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(fsp->conn, &local_fname);
index f1d0bfd294f6d20300fa5e64ed817f890cc6a54c..008ab57c0de4d1eeca8040982b88a9b927743c09 100644 (file)
 
 /* where to find the base of the SMB packet proper */
 /* REWRITE TODO: smb_base needs to be removed */
-#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 */