summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-05-05 10:41:59 -0700
committerJeremy Allison <jra@samba.org>2011-05-05 10:41:59 -0700
commit4f41be356a4e6b311d30de3b2e36e4c33aa72ca3 (patch)
tree91adb9035c762c36a6cb24f242c11408779bd3f7 /source3/smbd
parent10a628b6e181af07f0c43db36ba017411b4eaaaa (diff)
downloadsamba-4f41be356a4e6b311d30de3b2e36e4c33aa72ca3.tar.gz
samba-4f41be356a4e6b311d30de3b2e36e4c33aa72ca3.tar.bz2
samba-4f41be356a4e6b311d30de3b2e36e4c33aa72ca3.zip
Fix many const compiler warnings.
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/aio.c4
-rw-r--r--source3/smbd/blocking.c4
-rw-r--r--source3/smbd/filename.c2
-rw-r--r--source3/smbd/ipc.c2
-rw-r--r--source3/smbd/nttrans.c4
-rw-r--r--source3/smbd/perfcount.c2
-rw-r--r--source3/smbd/pipes.c4
-rw-r--r--source3/smbd/process.c32
-rw-r--r--source3/smbd/proto.h2
-rw-r--r--source3/smbd/reply.c14
-rw-r--r--source3/smbd/seal.c2
-rw-r--r--source3/smbd/trans2.c6
-rw-r--r--source3/smbd/vfs.c2
13 files changed, 40 insertions, 40 deletions
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 0cb94acece..1923c945a8 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -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;
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index c208234bdc..d125a74439 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -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);
/*
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 08bc79dfd2..f09dd12013 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -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);
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index f303e8f171..7cc6904510 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -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);
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index f4bd969300..33f05bd789 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -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);
diff --git a/source3/smbd/perfcount.c b/source3/smbd/perfcount.c
index 3bc83b98d5..1561893758 100644
--- a/source3/smbd/perfcount.c
+++ b/source3/smbd/perfcount.c
@@ -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));
diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c
index 35dd9a74b9..c8829cd58a 100644
--- a/source3/smbd/pipes.c
+++ b/source3/smbd/pipes.c
@@ -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) {
/*
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 169c459534..9306aa3e93 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -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
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 86745f122d..2ea01c2a5e 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -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,
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 9c66ddee02..fc381d89e7 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -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;
diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c
index b3dd84264a..a34a19a684 100644
--- a/source3/smbd/seal.c
+++ b/source3/smbd/seal.c
@@ -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;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 7c8b43c10c..733f1bc2a8 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -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);
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 3bde0a388e..e6ea34bd18 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -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);