summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-01-02 09:07:17 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-01-02 09:07:17 +0000
commit6d66fb308ab85bd9691d541764e683e6040cf724 (patch)
tree10b705921665cb7bafdd332ca53b8a943e13f0e5 /source3/libsmb
parentc105c12d122e599fe57dde8b2b73c52231f0c1d2 (diff)
downloadsamba-6d66fb308ab85bd9691d541764e683e6040cf724.tar.gz
samba-6d66fb308ab85bd9691d541764e683e6040cf724.tar.bz2
samba-6d66fb308ab85bd9691d541764e683e6040cf724.zip
BIG patch...
This patch makes Samba compile cleanly with -Wwrite-strings. - That is, all string literals are marked as 'const'. These strings are always read only, this just marks them as such for passing to other functions. What is most supprising is that I didn't need to change more than a few lines of code (all in 'net', which got a small cleanup of net.h and extern variables). The rest is just adding a lot of 'const'. As far as I can tell, I have not added any new warnings - apart from making all of tdbutil.c's function const (so they warn for adding that const string to struct). Andrew Bartlett (This used to be commit 92a777d0eaa4fb3a1c7835816f93c6bdd456816d)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/asn1.c2
-rw-r--r--source3/libsmb/clidgram.c4
-rw-r--r--source3/libsmb/clientgen.c2
-rw-r--r--source3/libsmb/clierror.c6
-rw-r--r--source3/libsmb/clikrb5.c2
-rw-r--r--source3/libsmb/cliprint.c2
-rw-r--r--source3/libsmb/clirap.c6
-rw-r--r--source3/libsmb/clirap2.c2
-rw-r--r--source3/libsmb/clireadwrite.c5
-rw-r--r--source3/libsmb/doserr.c4
-rw-r--r--source3/libsmb/errormap.c6
-rw-r--r--source3/libsmb/nmblib.c8
-rw-r--r--source3/libsmb/nterr.c8
-rw-r--r--source3/libsmb/smberr.c12
-rw-r--r--source3/libsmb/unexpected.c4
15 files changed, 37 insertions, 36 deletions
diff --git a/source3/libsmb/asn1.c b/source3/libsmb/asn1.c
index b7cfca41fb..b967927871 100644
--- a/source3/libsmb/asn1.c
+++ b/source3/libsmb/asn1.c
@@ -338,7 +338,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID)
}
/* check that the next object ID is correct */
-BOOL asn1_check_OID(ASN1_DATA *data, char *OID)
+BOOL asn1_check_OID(ASN1_DATA *data, const char *OID)
{
char *id;
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c
index 8f4bdf7be6..5ab6bef87b 100644
--- a/source3/libsmb/clidgram.c
+++ b/source3/libsmb/clidgram.c
@@ -26,7 +26,7 @@
* cli_send_mailslot, send a mailslot for client code ...
*/
-int cli_send_mailslot(int dgram_sock, BOOL unique, char *mailslot,
+int cli_send_mailslot(int dgram_sock, BOOL unique, const char *mailslot,
char *buf, int len,
const char *srcname, int src_type,
const char *dstname, int dest_type,
@@ -100,7 +100,7 @@ int cli_send_mailslot(int dgram_sock, BOOL unique, char *mailslot,
/*
* cli_get_response: Get a response ...
*/
-int cli_get_response(int dgram_sock, BOOL unique, char *mailslot, char *buf, int bufsiz)
+int cli_get_response(int dgram_sock, BOOL unique, const char *mailslot, char *buf, int bufsiz)
{
struct packet_struct *packet;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index c843d49d27..ed1286d627 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -327,7 +327,7 @@ void cli_shutdown(struct cli_state *cli)
Set socket options on a open connection.
****************************************************************************/
-void cli_sockopt(struct cli_state *cli, char *options)
+void cli_sockopt(struct cli_state *cli, const char *options)
{
set_socket_options(cli->fd, options);
}
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index f5281eb047..12a7b5dba1 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -33,7 +33,7 @@
static const struct
{
int err;
- char *message;
+ const char *message;
} rap_errmap[] =
{
{5, "RAP5: User has insufficient privilege" },
@@ -62,7 +62,7 @@ static const struct
/****************************************************************************
return a description of an SMB error
****************************************************************************/
-static char *cli_smb_errstr(struct cli_state *cli)
+static const char *cli_smb_errstr(struct cli_state *cli)
{
return smb_dos_errstr(cli->inbuf);
}
@@ -73,7 +73,7 @@ static char *cli_smb_errstr(struct cli_state *cli)
in which case they can be safely ignored.
****************************************************************************/
-char *cli_errstr(struct cli_state *cli)
+const char *cli_errstr(struct cli_state *cli)
{
static fstring cli_error_message;
uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), errnum;
diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c
index 54a8a6ffe8..a7b11d777e 100644
--- a/source3/libsmb/clikrb5.c
+++ b/source3/libsmb/clikrb5.c
@@ -94,7 +94,7 @@ cleanup_princ:
/*
get a kerberos5 ticket for the given service
*/
-DATA_BLOB krb5_get_ticket(char *principal, time_t time_offset)
+DATA_BLOB krb5_get_ticket(const char *principal, time_t time_offset)
{
krb5_error_code retval;
krb5_data packet;
diff --git a/source3/libsmb/cliprint.c b/source3/libsmb/cliprint.c
index 92fbf02e91..bfa33bc514 100644
--- a/source3/libsmb/cliprint.c
+++ b/source3/libsmb/cliprint.c
@@ -27,7 +27,7 @@
This function contains code to prevent core dumps if the server returns
invalid data.
*****************************************************************************/
-static char *fix_char_ptr(unsigned int datap, unsigned int converter,
+static const char *fix_char_ptr(unsigned int datap, unsigned int converter,
char *rdata, int rdrcnt)
{
if (datap == 0) { /* turn NULL pointers into zero length strings */
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index b4924fd773..792a3e7aa0 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -26,7 +26,7 @@
/****************************************************************************
Call a remote api on an arbitrary pipe. takes param, data and setup buffers.
****************************************************************************/
-BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name,
+BOOL cli_api_pipe(struct cli_state *cli, const char *pipe_name,
uint16 *setup, uint32 setup_count, uint32 max_setup_count,
char *params, uint32 param_count, uint32 max_param_count,
char *data, uint32 data_count, uint32 max_data_count,
@@ -176,7 +176,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co
char *sname = p;
int type = SVAL(p,14);
int comment_offset = IVAL(p,16) & 0xFFFF;
- char *cmnt = comment_offset?(rdata+comment_offset-converter):"";
+ const char *cmnt = comment_offset?(rdata+comment_offset-converter):"";
pstring s1, s2;
pull_ascii_pstring(s1, sname);
@@ -253,7 +253,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
for (i = 0;i < count;i++, p += 26) {
char *sname = p;
int comment_offset = (IVAL(p,22) & 0xFFFF)-converter;
- char *cmnt = comment_offset?(rdata+comment_offset):"";
+ const char *cmnt = comment_offset?(rdata+comment_offset):"";
pstring s1, s2;
if (comment_offset < 0 || comment_offset > rdrcnt) continue;
diff --git a/source3/libsmb/clirap2.c b/source3/libsmb/clirap2.c
index 9c3ec212d5..948e88061a 100644
--- a/source3/libsmb/clirap2.c
+++ b/source3/libsmb/clirap2.c
@@ -128,7 +128,7 @@
pull_ascii_pstring(s, off?(r+off-c):"");\
} while(0)
-static char *make_header(char *param, uint16 apinum, char *reqfmt, char *datafmt)
+static char *make_header(char *param, uint16 apinum, const char *reqfmt, const char *datafmt)
{
PUTWORD(param,apinum);
if (reqfmt)
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index d35b0dfdfd..0715aa7f1a 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -248,7 +248,8 @@ ssize_t cli_readraw(struct cli_state *cli, int fnum, char *buf, off_t offset, si
issue a single SMBwrite and don't wait for a reply
****************************************************************************/
-static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint16 mode, char *buf,
+static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset,
+ uint16 mode, const char *buf,
size_t size, int i)
{
char *p;
@@ -319,7 +320,7 @@ static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint1
ssize_t cli_write(struct cli_state *cli,
int fnum, uint16 write_mode,
- char *buf, off_t offset, size_t size)
+ const char *buf, off_t offset, size_t size)
{
int bwritten = 0;
int issued = 0;
diff --git a/source3/libsmb/doserr.c b/source3/libsmb/doserr.c
index 02db625685..c9de4cf319 100644
--- a/source3/libsmb/doserr.c
+++ b/source3/libsmb/doserr.c
@@ -24,7 +24,7 @@
typedef const struct
{
- char *dos_errstr;
+ const char *dos_errstr;
WERROR werror;
} werror_code_struct;
@@ -73,7 +73,7 @@ werror_code_struct dos_errs[] =
/*****************************************************************************
returns a DOS error message. not amazingly helpful, but better than a number.
*****************************************************************************/
-char *dos_errstr(WERROR werror)
+const char *dos_errstr(WERROR werror)
{
static pstring msg;
int idx = 0;
diff --git a/source3/libsmb/errormap.c b/source3/libsmb/errormap.c
index 8bd29b55c0..09340caccd 100644
--- a/source3/libsmb/errormap.c
+++ b/source3/libsmb/errormap.c
@@ -45,7 +45,7 @@
*/
/* NT status -> dos error map */
-const static struct {
+static const struct {
uint8 dos_class;
uint32 dos_code;
NTSTATUS ntstatus;
@@ -611,7 +611,7 @@ const static struct {
/* dos -> nt status error map */
-const static struct {
+static const struct {
uint8 dos_class;
uint32 dos_code;
NTSTATUS ntstatus;
@@ -866,7 +866,7 @@ const static struct {
};
/* errmap NTSTATUS->Win32 */
-const static struct {
+static const struct {
NTSTATUS ntstatus;
WERROR werror;
} ntstatus_to_werror_map[] = {
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index d38e2ff0ec..30ce5b6b10 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -25,7 +25,7 @@ int num_good_sends = 0;
int num_good_receives = 0;
static const struct opcode_names {
- char *nmb_opcode_name;
+ const char *nmb_opcode_name;
int opcode;
} nmb_header_opcode_names[] = {
{"Query", 0 },
@@ -57,7 +57,7 @@ static const char *lookup_opcode_name( int opcode )
/****************************************************************************
print out a res_rec structure
****************************************************************************/
-static void debug_nmb_res_rec(struct res_rec *res, char *hdr)
+static void debug_nmb_res_rec(struct res_rec *res, const char *hdr)
{
int i, j;
@@ -1005,7 +1005,7 @@ struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id)
queue. The packet must be a reply packet and have the specified mailslot name
The timeout is in milliseconds
***************************************************************************/
-struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name)
+struct packet_struct *receive_dgram_packet(int fd, int t, const char *mailslot_name)
{
struct packet_struct *p;
@@ -1024,7 +1024,7 @@ struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name)
/****************************************************************************
see if a datagram has the right mailslot name
***************************************************************************/
-BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name)
+BOOL match_mailslot_name(struct packet_struct *p, const char *mailslot_name)
{
struct dgram_packet *dgram = &p->packet.dgram;
char *buf;
diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c
index e494995f86..dbad05b91e 100644
--- a/source3/libsmb/nterr.c
+++ b/source3/libsmb/nterr.c
@@ -24,7 +24,7 @@
typedef const struct
{
- char *nt_errstr;
+ const char *nt_errstr;
NTSTATUS nt_errcode;
} nt_err_code_struct;
@@ -575,7 +575,7 @@ nt_err_code_struct nt_err_desc[] =
/*****************************************************************************
returns an NT error message. not amazingly helpful, but better than a number.
*****************************************************************************/
-char *nt_errstr(NTSTATUS nt_code)
+const char *nt_errstr(NTSTATUS nt_code)
{
static pstring msg;
int idx = 0;
@@ -597,7 +597,7 @@ char *nt_errstr(NTSTATUS nt_code)
Print friendler version fo NT error code
***********************************************************************/
-char *get_friendly_nt_error_msg(NTSTATUS nt_code)
+const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
{
int idx = 0;
@@ -617,7 +617,7 @@ char *get_friendly_nt_error_msg(NTSTATUS nt_code)
/*****************************************************************************
returns an NT_STATUS constant as a string for inclusion in autogen C code
*****************************************************************************/
-char *get_nt_error_c_code(NTSTATUS nt_code)
+const char *get_nt_error_c_code(NTSTATUS nt_code)
{
static pstring out;
int idx = 0;
diff --git a/source3/libsmb/smberr.c b/source3/libsmb/smberr.c
index 724c8edd54..82efbdb689 100644
--- a/source3/libsmb/smberr.c
+++ b/source3/libsmb/smberr.c
@@ -37,9 +37,9 @@
typedef const struct
{
- char *name;
+ const char *name;
int code;
- char *message;
+ const char *message;
} err_code_struct;
/* Dos Error Messages */
@@ -142,7 +142,7 @@ err_code_struct hard_msgs[] = {
const struct
{
int code;
- char *class;
+ const char *class;
err_code_struct *err_msgs;
} err_classes[] = {
{0,"SUCCESS",NULL},
@@ -160,7 +160,7 @@ const struct
/****************************************************************************
return a SMB error name from a class and code
****************************************************************************/
-char *smb_dos_err_name(uint8 class, uint16 num)
+const char *smb_dos_err_name(uint8 class, uint16 num)
{
static pstring ret;
int i,j;
@@ -184,7 +184,7 @@ char *smb_dos_err_name(uint8 class, uint16 num)
/* Return a string for a DOS error */
-char *get_dos_error_msg(WERROR result)
+const char *get_dos_error_msg(WERROR result)
{
uint16 errnum;
@@ -196,7 +196,7 @@ char *get_dos_error_msg(WERROR result)
/****************************************************************************
return a SMB error class name as a string.
****************************************************************************/
-char *smb_dos_err_class(uint8 class)
+const char *smb_dos_err_class(uint8 class)
{
static pstring ret;
int i;
diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c
index 4fc3914481..97d6071e71 100644
--- a/source3/libsmb/unexpected.c
+++ b/source3/libsmb/unexpected.c
@@ -110,7 +110,7 @@ void clear_unexpected(time_t t)
static struct packet_struct *matched_packet;
static int match_id;
static enum packet_type match_type;
-static char *match_name;
+static const char *match_name;
/****************************************************************************
tdb traversal fn to find a matching 137 packet
@@ -144,7 +144,7 @@ static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void
check for a particular packet in the unexpected packet queue
**************************************************************************/
struct packet_struct *receive_unexpected(enum packet_type packet_type, int id,
- char *mailslot_name)
+ const char *mailslot_name)
{
TDB_CONTEXT *tdb2;