summaryrefslogtreecommitdiffstats
path: root/source3/lib
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/lib
parentc105c12d122e599fe57dde8b2b73c52231f0c1d2 (diff)
downloadsamba-6d66fb308ab85bd9691d541764e683e6040cf724.tar.gz
samba-6d66fb308ab85bd9691d541764e683e6040cf724.tar.xz
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/lib')
-rw-r--r--source3/lib/account_pol.c4
-rw-r--r--source3/lib/adt_tree.c2
-rw-r--r--source3/lib/charcnv.c12
-rw-r--r--source3/lib/genrand.c2
-rw-r--r--source3/lib/iconv.c12
-rw-r--r--source3/lib/messages.c2
-rw-r--r--source3/lib/pam_errors.c4
-rw-r--r--source3/lib/pidfile.c4
-rw-r--r--source3/lib/smbpasswd.c2
-rw-r--r--source3/lib/system.c2
-rw-r--r--source3/lib/util.c8
-rw-r--r--source3/lib/util_sid.c7
-rw-r--r--source3/lib/util_sock.c2
-rw-r--r--source3/lib/util_str.c4
14 files changed, 34 insertions, 33 deletions
diff --git a/source3/lib/account_pol.c b/source3/lib/account_pol.c
index 6f51c916d71..2e619c0c6b3 100644
--- a/source3/lib/account_pol.c
+++ b/source3/lib/account_pol.c
@@ -31,7 +31,7 @@ static TDB_CONTEXT *tdb; /* used for driver files */
BOOL init_account_policy(void)
{
static pid_t local_pid;
- char *vstring = "INFO/version";
+ const char *vstring = "INFO/version";
uint32 version;
if (tdb && local_pid == sys_getpid())
@@ -67,7 +67,7 @@ BOOL init_account_policy(void)
static const struct {
int field;
- char *string;
+ const char *string;
} account_policy_names[] = {
{AP_MIN_PASSWORD_LEN, "min password length"},
{AP_PASSWORD_HISTORY, "password history"},
diff --git a/source3/lib/adt_tree.c b/source3/lib/adt_tree.c
index 2c18bb1198c..0bc224ec232 100644
--- a/source3/lib/adt_tree.c
+++ b/source3/lib/adt_tree.c
@@ -325,7 +325,7 @@ done:
Recursive routine to print out all children of a TREE_NODE
*************************************************************************/
-static void sorted_tree_print_children( TREE_NODE *node, int debug, char *path )
+static void sorted_tree_print_children( TREE_NODE *node, int debug, const char *path )
{
int i;
int num_children;
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 04145fd17ab..3428377d952 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -30,9 +30,9 @@ static smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS];
Return the name of a charset to give to iconv().
****************************************************************************/
-static char *charset_name(charset_t ch)
+static const char *charset_name(charset_t ch)
{
- char *ret = NULL;
+ const char *ret = NULL;
if (ch == CH_UCS2) ret = "UCS-2LE";
else if (ch == CH_UNIX) ret = lp_unix_charset();
@@ -75,8 +75,8 @@ void init_iconv(void)
for (c1=0;c1<NUM_CHARSETS;c1++) {
for (c2=0;c2<NUM_CHARSETS;c2++) {
- char *n1 = charset_name((charset_t)c1);
- char *n2 = charset_name((charset_t)c2);
+ const char *n1 = charset_name((charset_t)c1);
+ const char *n2 = charset_name((charset_t)c2);
if (conv_handles[c1][c2] &&
strcmp(n1, conv_handles[c1][c2]->from_name) == 0 &&
strcmp(n2, conv_handles[c1][c2]->to_name) == 0)
@@ -140,7 +140,7 @@ size_t convert_string(charset_t from, charset_t to,
o_len=destlen;
retval = smb_iconv(descriptor, &inbuf, &i_len, &outbuf, &o_len);
if(retval==-1) {
- char *reason="unknown error";
+ const char *reason="unknown error";
switch(errno) {
case EINVAL:
reason="Incomplete multibyte sequence";
@@ -215,7 +215,7 @@ convert:
&inbuf, &i_len,
&outbuf, &o_len);
if(retval == -1) {
- char *reason="unknown error";
+ const char *reason="unknown error";
switch(errno) {
case EINVAL:
reason="Incomplete multibyte sequence";
diff --git a/source3/lib/genrand.c b/source3/lib/genrand.c
index fe756169a66..bc9f21c6403 100644
--- a/source3/lib/genrand.c
+++ b/source3/lib/genrand.c
@@ -101,7 +101,7 @@ static void get_random_stream(unsigned char *data, size_t datasize)
Note that the hash is not initialised.
*****************************************************************/
-static void do_filehash(char *fname, unsigned char *the_hash)
+static void do_filehash(const char *fname, unsigned char *the_hash)
{
unsigned char buf[1011]; /* deliberate weird size */
unsigned char tmp_md4[16];
diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c
index e54a74864e1..5292e9cf0a6 100644
--- a/source3/lib/iconv.c
+++ b/source3/lib/iconv.c
@@ -29,12 +29,12 @@ static size_t ucs2hex_pull(void *,char **, size_t *, char **, size_t *);
static size_t ucs2hex_push(void *,char **, size_t *, char **, size_t *);
static size_t iconv_copy(void *,char **, size_t *, char **, size_t *);
-struct charset_functions builtin_functions[] = {
- {"UCS-2LE", iconv_copy, iconv_copy},
- {"UTF8", utf8_pull, utf8_push},
- {"ASCII", ascii_pull, ascii_push},
- {"UCS2-HEX", ucs2hex_pull, ucs2hex_push},
- {NULL, NULL, NULL}
+static struct charset_functions builtin_functions[] = {
+ {"UCS-2LE", iconv_copy, iconv_copy},
+ {"UTF8", utf8_pull, utf8_push},
+ {"ASCII", ascii_pull, ascii_push},
+ {"UCS2-HEX", ucs2hex_pull, ucs2hex_push},
+ {NULL, NULL, NULL}
};
static struct charset_functions *charsets = NULL;
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 36a23e28ab9..8200b2f8c30 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -81,7 +81,7 @@ static void sig_usr1(void)
static void ping_message(int msg_type, pid_t src, void *buf, size_t len)
{
- char *msg = buf ? buf : "none";
+ const char *msg = buf ? buf : "none";
DEBUG(1,("INFO: Received PING message from PID %u [%s]\n",(unsigned int)src, msg));
message_send_pid(src, MSG_PONG, buf, len, True);
}
diff --git a/source3/lib/pam_errors.c b/source3/lib/pam_errors.c
index e1d02151a62..925441fb1d4 100644
--- a/source3/lib/pam_errors.c
+++ b/source3/lib/pam_errors.c
@@ -28,7 +28,7 @@
#endif
/* PAM -> NT_STATUS map */
-const static struct {
+static const struct {
int pam_code;
NTSTATUS ntstatus;
} pam_to_nt_status_map[] = {
@@ -58,7 +58,7 @@ const static struct {
};
/* NT_STATUS -> PAM map */
-const static struct {
+static const struct {
NTSTATUS ntstatus;
int pam_code;
} nt_status_to_pam_map[] = {
diff --git a/source3/lib/pidfile.c b/source3/lib/pidfile.c
index 393fb579944..16a12656b3a 100644
--- a/source3/lib/pidfile.c
+++ b/source3/lib/pidfile.c
@@ -28,7 +28,7 @@
/* return the pid in a pidfile. return 0 if the process (or pidfile)
does not exist */
-pid_t pidfile_pid(char *name)
+pid_t pidfile_pid(const char *name)
{
int fd;
char pidstr[20];
@@ -69,7 +69,7 @@ pid_t pidfile_pid(char *name)
}
/* create a pid file in the pid directory. open it and leave it locked */
-void pidfile_create(char *name)
+void pidfile_create(const char *name)
{
int fd;
char buf[20];
diff --git a/source3/lib/smbpasswd.c b/source3/lib/smbpasswd.c
index c27af5540b6..92ae1ffea26 100644
--- a/source3/lib/smbpasswd.c
+++ b/source3/lib/smbpasswd.c
@@ -60,7 +60,7 @@ BOOL smbpasswd_gethexpwd(char *p, unsigned char *pwd)
{
int i;
unsigned char lonybble, hinybble;
- char *hexchars = "0123456789ABCDEF";
+ const char *hexchars = "0123456789ABCDEF";
char *p1, *p2;
if (!p) return (False);
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 873b8737d50..fed9b117ca7 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -1233,7 +1233,7 @@ int sys_dup2(int oldfd, int newfd)
Wrapper for Admin Logs.
****************************************************************************/
-void sys_adminlog(int priority, char *format_str, ...)
+void sys_adminlog(int priority, const char *format_str, ...)
{
va_list ap;
int ret;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 0adfe34032d..39c58534cd4 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -676,7 +676,7 @@ smb_ucs2_t *unix_clean_path(const smb_ucs2_t *s)
Make a dir struct.
****************************************************************************/
-void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date)
+void make_dir_struct(char *buf, const char *mask, const char *fname,SMB_OFF_T size,int mode,time_t date)
{
char *p;
pstring mask2;
@@ -1398,7 +1398,7 @@ gid_t nametogid(const char *name)
Something really nasty happened - panic !
********************************************************************/
-void smb_panic(char *why)
+void smb_panic(const char *why)
{
char *cmd = lp_panic_action();
int result;
@@ -1463,7 +1463,7 @@ char *readdirname(DIR *p)
of a path matches a (possibly wildcarded) entry in a namelist.
********************************************************************/
-BOOL is_in_path(char *name, name_compare_entry *namelist)
+BOOL is_in_path(const char *name, name_compare_entry *namelist)
{
pstring last_component;
char *p;
@@ -2247,7 +2247,7 @@ BOOL ms_has_wild_w(const smb_ucs2_t *s)
of the ".." name.
*******************************************************************/
-BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive)
+BOOL mask_match(const char *string, char *pattern, BOOL is_case_sensitive)
{
fstring p2, s2;
diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c
index edd59ae1094..824987f1892 100644
--- a/source3/lib/util_sid.c
+++ b/source3/lib/util_sid.c
@@ -79,9 +79,9 @@ NT_USER_TOKEN system_token = {
Lookup string names for SID types.
****************************************************************************/
-const static struct {
+static const struct {
enum SID_NAME_USE sid_type;
- char *string;
+ const char *string;
} sid_name_type[] = {
{SID_NAME_USER, "User"},
{SID_NAME_DOM_GRP, "Domain Group"},
@@ -181,7 +181,8 @@ NT_USER_TOKEN *get_system_token(void)
void split_domain_name(const char *fullname, char *domain, char *name)
{
pstring full_name;
- char *p, *sep;
+ const char *sep;
+ char *p;
sep = lp_winbind_separator();
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 2acb20861b9..e162e5cd771 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -43,7 +43,7 @@ BOOL is_a_socket(int fd)
enum SOCK_OPT_TYPES {OPT_BOOL,OPT_INT,OPT_ON};
typedef struct smb_socket_option {
- char *name;
+ const char *name;
int level;
int option;
int value;
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 7d056e98d2c..a76278e532f 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -576,7 +576,7 @@ size_t strhex_to_str(char *p, size_t len, const char *strhex)
size_t i;
size_t num_chars = 0;
unsigned char lonybble, hinybble;
- char *hexchars = "0123456789ABCDEF";
+ const char *hexchars = "0123456789ABCDEF";
char *p1 = NULL, *p2 = NULL;
for (i = 0; i < len && strhex[i] != 0; i++) {
@@ -958,7 +958,7 @@ void split_at_last_component(char *path, char *front, char sep, char *back)
Write an octal as a string.
****************************************************************************/
-char *octal_string(int i)
+const char *octal_string(int i)
{
static char ret[64];
if (i == -1)