summaryrefslogtreecommitdiff
path: root/source3/torture
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/torture
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/torture')
-rw-r--r--source3/torture/denytest.c20
-rw-r--r--source3/torture/locktest2.c2
-rw-r--r--source3/torture/masktest.c16
-rw-r--r--source3/torture/nsstest.c4
-rw-r--r--source3/torture/scanner.c16
-rw-r--r--source3/torture/torture.c62
-rw-r--r--source3/torture/vfstest.c4
-rw-r--r--source3/torture/vfstest.h6
8 files changed, 66 insertions, 64 deletions
diff --git a/source3/torture/denytest.c b/source3/torture/denytest.c
index 045246f126..017bb1c06d 100644
--- a/source3/torture/denytest.c
+++ b/source3/torture/denytest.c
@@ -27,11 +27,11 @@ extern BOOL torture_showall;
enum deny_result {A_0=0, A_X=1, A_R=2, A_W=3, A_RW=5};
-static char *denystr(int denymode)
+static const char *denystr(int denymode)
{
struct {
int v;
- char *name;
+ const char *name;
} deny_modes[] = {
{DENY_DOS, "DENY_DOS"},
{DENY_ALL, "DENY_ALL"},
@@ -47,11 +47,11 @@ static char *denystr(int denymode)
return "DENY_XXX";
}
-static char *openstr(int mode)
+static const char *openstr(int mode)
{
struct {
int v;
- char *name;
+ const char *name;
} open_modes[] = {
{O_RDWR, "O_RDWR"},
{O_RDONLY, "O_RDONLY"},
@@ -64,11 +64,11 @@ static char *openstr(int mode)
return "O_XXX";
}
-static char *resultstr(enum deny_result res)
+static const char *resultstr(enum deny_result res)
{
struct {
enum deny_result res;
- char *name;
+ const char *name;
} results[] = {
{A_X, "X"},
{A_0, "-"},
@@ -1412,7 +1412,7 @@ BOOL torture_denytest1(int dummy)
int fnum1, fnum2;
int i;
BOOL correct = True;
- char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"};
+ const char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"};
if (!torture_open_connection(&cli1)) {
return False;
@@ -1431,7 +1431,7 @@ BOOL torture_denytest1(int dummy)
for (i=0; i<ARRAY_SIZE(denytable1); i++) {
enum deny_result res;
- char *fname = fnames[denytable1[i].isexe];
+ const char *fname = fnames[denytable1[i].isexe];
progress_bar(i, ARRAY_SIZE(denytable1));
@@ -1498,7 +1498,7 @@ BOOL torture_denytest2(int dummy)
int fnum1, fnum2;
int i;
BOOL correct = True;
- char *fnames[2] = {"\\denytest2.dat", "\\denytest2.exe"};
+ const char *fnames[2] = {"\\denytest2.dat", "\\denytest2.exe"};
if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
return False;
@@ -1515,7 +1515,7 @@ BOOL torture_denytest2(int dummy)
for (i=0; i<ARRAY_SIZE(denytable2); i++) {
enum deny_result res;
- char *fname = fnames[denytable2[i].isexe];
+ const char *fname = fnames[denytable2[i].isexe];
progress_bar(i, ARRAY_SIZE(denytable1));
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index c4323ac377..3166d6e326 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -62,7 +62,7 @@ struct record {
static struct record *recorded;
-static int try_open(struct cli_state *c, char *nfs, int fstype, char *fname, int flags)
+static int try_open(struct cli_state *c, char *nfs, int fstype, const char *fname, int flags)
{
pstring path;
diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
index 637e9ef63a..9b83619e85 100644
--- a/source3/torture/masktest.c
+++ b/source3/torture/masktest.c
@@ -28,16 +28,16 @@ static int got_pass;
static int max_protocol = PROTOCOL_NT1;
static BOOL showall = False;
static BOOL old_list = False;
-static char *maskchars = "<>\"?*abc.";
-static char *filechars = "abcdefghijklm.";
+static const char *maskchars = "<>\"?*abc.";
+static const char *filechars = "abcdefghijklm.";
static int verbose;
static int die_on_error;
static int NumLoops = 0;
/* a test fn for LANMAN mask support */
-int ms_fnmatch_lanman_core(char *pattern, char *string)
+int ms_fnmatch_lanman_core(const char *pattern, const char *string)
{
- char *p = pattern, *n = string;
+ const char *p = pattern, *n = string;
char c;
if (strcmp(p,"?")==0 && strcmp(n,".")==0) goto match;
@@ -109,10 +109,12 @@ next:
return 0;
}
-int ms_fnmatch_lanman(char *pattern, char *string)
+int ms_fnmatch_lanman(const char *pattern, const char *string)
{
if (!strpbrk(pattern, "?*<>\"")) {
- if (strcmp(string,"..") == 0) string = ".";
+ if (strcmp(string,"..") == 0)
+ string = ".";
+
return strcmp(pattern, string);
}
@@ -124,7 +126,7 @@ int ms_fnmatch_lanman(char *pattern, char *string)
return ms_fnmatch_lanman_core(pattern, string);
}
-static BOOL reg_match_one(struct cli_state *cli, char *pattern, char *file)
+static BOOL reg_match_one(struct cli_state *cli, const char *pattern, const char *file)
{
/* oh what a weird world this is */
if (old_list && strcmp(pattern, "*.*") == 0) return True;
diff --git a/source3/torture/nsstest.c b/source3/torture/nsstest.c
index c9b068aa04..a82fa05203 100644
--- a/source3/torture/nsstest.c
+++ b/source3/torture/nsstest.c
@@ -20,8 +20,8 @@
#include "includes.h"
-static char *so_path = "/lib/libnss_winbind.so";
-static char *nss_name = "winbind";
+static const char *so_path = "/lib/libnss_winbind.so";
+static const char *nss_name = "winbind";
static int nss_errno;
static NSS_STATUS last_error;
static int total_errors;
diff --git a/source3/torture/scanner.c b/source3/torture/scanner.c
index 4f4164ea33..7db3dde9c0 100644
--- a/source3/torture/scanner.c
+++ b/source3/torture/scanner.c
@@ -29,7 +29,7 @@
/****************************************************************************
look for a partial hit
****************************************************************************/
-static void trans2_check_hit(char *format, int op, int level, NTSTATUS status)
+static void trans2_check_hit(const char *format, int op, int level, NTSTATUS status)
{
if (NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_INVALID_LEVEL) ||
NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_NOT_IMPLEMENTED) ||
@@ -78,7 +78,7 @@ static NTSTATUS try_trans2(struct cli_state *cli,
static NTSTATUS try_trans2_len(struct cli_state *cli,
- char *format,
+ const char *format,
int op, int level,
char *param, char *data,
int param_len, int *data_len,
@@ -113,7 +113,7 @@ static NTSTATUS try_trans2_len(struct cli_state *cli,
check for existance of a trans2 call
****************************************************************************/
static BOOL scan_trans2(struct cli_state *cli, int op, int level,
- int fnum, int dnum, char *fname)
+ int fnum, int dnum, const char *fname)
{
int data_len = 0;
int param_len = 0;
@@ -193,7 +193,7 @@ BOOL torture_trans2_scan(int dummy)
{
static struct cli_state cli;
int op, level;
- char *fname = "\\scanner.dat";
+ const char *fname = "\\scanner.dat";
int fnum, dnum;
printf("starting trans2 scan test\n");
@@ -233,7 +233,7 @@ BOOL torture_trans2_scan(int dummy)
/****************************************************************************
look for a partial hit
****************************************************************************/
-static void nttrans_check_hit(char *format, int op, int level, NTSTATUS status)
+static void nttrans_check_hit(const char *format, int op, int level, NTSTATUS status)
{
if (NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_INVALID_LEVEL) ||
NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_NOT_IMPLEMENTED) ||
@@ -280,7 +280,7 @@ static NTSTATUS try_nttrans(struct cli_state *cli,
static NTSTATUS try_nttrans_len(struct cli_state *cli,
- char *format,
+ const char *format,
int op, int level,
char *param, char *data,
int param_len, int *data_len,
@@ -315,7 +315,7 @@ static NTSTATUS try_nttrans_len(struct cli_state *cli,
check for existance of a nttrans call
****************************************************************************/
static BOOL scan_nttrans(struct cli_state *cli, int op, int level,
- int fnum, int dnum, char *fname)
+ int fnum, int dnum, const char *fname)
{
int data_len = 0;
int param_len = 0;
@@ -395,7 +395,7 @@ BOOL torture_nttrans_scan(int dummy)
{
static struct cli_state cli;
int op, level;
- char *fname = "\\scanner.dat";
+ const char *fname = "\\scanner.dat";
int fnum, dnum;
printf("starting nttrans scan test\n");
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 49ddba52e1..5b25002213 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -24,7 +24,7 @@
static fstring host, workgroup, share, password, username, myname;
static int max_protocol = PROTOCOL_NT1;
-static char *sockops="TCP_NODELAY";
+static const char *sockops="TCP_NODELAY";
static int nprocs=1;
int torture_numops=100;
static int procnum; /* records process count number when forking */
@@ -32,7 +32,7 @@ static struct cli_state current_cli;
static fstring randomfname;
static BOOL use_oplocks;
static BOOL use_level_II_oplocks;
-static char *client_txt = "client_oplocks.txt";
+static const char *client_txt = "client_oplocks.txt";
static BOOL use_kerberos;
BOOL torture_showall = False;
@@ -221,7 +221,7 @@ static BOOL wait_lock(struct cli_state *c, int fnum, uint32 offset, uint32 len)
static BOOL rw_torture(struct cli_state *c)
{
- char *lockfname = "\\torture.lck";
+ const char *lockfname = "\\torture.lck";
fstring fname;
int fnum;
int fnum2;
@@ -428,7 +428,7 @@ static BOOL rw_torture3(struct cli_state *c, char *lockfname)
static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2)
{
- char *lockfname = "\\torture2.lck";
+ const char *lockfname = "\\torture2.lck";
int fnum1;
int fnum2;
int i;
@@ -554,7 +554,7 @@ static BOOL run_readwritelarge(int dummy)
{
static struct cli_state cli1;
int fnum1;
- char *lockfname = "\\large.dat";
+ const char *lockfname = "\\large.dat";
size_t fsize;
char buf[126*1024];
BOOL correct = True;
@@ -782,7 +782,7 @@ static BOOL run_nbench(int dummy)
static BOOL run_locktest1(int dummy)
{
static struct cli_state cli1, cli2;
- char *fname = "\\lockt1.lck";
+ const char *fname = "\\lockt1.lck";
int fnum1, fnum2, fnum3;
time_t t1, t2;
unsigned lock_timeout;
@@ -893,7 +893,7 @@ static BOOL run_locktest1(int dummy)
static BOOL run_tcon_test(int dummy)
{
static struct cli_state cli1;
- char *fname = "\\tcontest.tmp";
+ const char *fname = "\\tcontest.tmp";
int fnum1;
uint16 cnum;
char buf[4];
@@ -976,7 +976,7 @@ static BOOL run_tcon_test(int dummy)
static BOOL run_locktest2(int dummy)
{
static struct cli_state cli;
- char *fname = "\\lockt2.lck";
+ const char *fname = "\\lockt2.lck";
int fnum1, fnum2, fnum3;
BOOL correct = True;
@@ -1112,7 +1112,7 @@ static BOOL run_locktest2(int dummy)
static BOOL run_locktest3(int dummy)
{
static struct cli_state cli1, cli2;
- char *fname = "\\lockt3.lck";
+ const char *fname = "\\lockt3.lck";
int fnum1, fnum2, i;
uint32 offset;
BOOL correct = True;
@@ -1237,7 +1237,7 @@ static BOOL run_locktest3(int dummy)
static BOOL run_locktest4(int dummy)
{
static struct cli_state cli1, cli2;
- char *fname = "\\lockt4.lck";
+ const char *fname = "\\lockt4.lck";
int fnum1, fnum2, f;
BOOL ret;
char buf[1000];
@@ -1408,7 +1408,7 @@ static BOOL run_locktest4(int dummy)
static BOOL run_locktest5(int dummy)
{
static struct cli_state cli1, cli2;
- char *fname = "\\lockt5.lck";
+ const char *fname = "\\lockt5.lck";
int fnum1, fnum2, fnum3;
BOOL ret;
char buf[1000];
@@ -1532,7 +1532,7 @@ static BOOL run_locktest5(int dummy)
static BOOL run_locktest6(int dummy)
{
static struct cli_state cli;
- char *fname[1] = { "\\lock6.txt" };
+ const char *fname[1] = { "\\lock6.txt" };
int i;
int fnum;
NTSTATUS status;
@@ -1576,7 +1576,7 @@ security hole)
static BOOL run_fdpasstest(int dummy)
{
static struct cli_state cli1, cli2, cli3;
- char *fname = "\\fdpass.tst";
+ const char *fname = "\\fdpass.tst";
int fnum1;
pstring buf;
@@ -1631,7 +1631,7 @@ static BOOL run_fdpasstest(int dummy)
static BOOL run_unlinktest(int dummy)
{
static struct cli_state cli;
- char *fname = "\\unlink.tst";
+ const char *fname = "\\unlink.tst";
int fnum;
BOOL correct = True;
@@ -1680,7 +1680,7 @@ test how many open files this server supports on the one socket
static BOOL run_maxfidtest(int dummy)
{
static struct cli_state cli;
- char *template = "\\maxfid.%d.%d";
+ const char *template = "\\maxfid.%d.%d";
fstring fname;
int fnums[0x11000], i;
int retries=4;
@@ -1866,7 +1866,7 @@ static BOOL run_attrtest(int dummy)
static struct cli_state cli;
int fnum;
time_t t, t2;
- char *fname = "\\attrib.tst";
+ const char *fname = "\\attrib.tst";
BOOL correct = True;
printf("starting attrib test\n");
@@ -1931,9 +1931,9 @@ static BOOL run_trans2test(int dummy)
int fnum;
size_t size;
time_t c_time, a_time, m_time, w_time, m_time2;
- char *fname = "\\trans2.tst";
- char *dname = "\\trans2";
- char *fname2 = "\\trans2\\trans2.tst";
+ const char *fname = "\\trans2.tst";
+ const char *dname = "\\trans2";
+ const char *fname2 = "\\trans2\\trans2.tst";
pstring pname;
BOOL correct = True;
@@ -2083,7 +2083,7 @@ static BOOL run_w2ktest(int dummy)
{
static struct cli_state cli;
int fnum;
- char *fname = "\\w2ktest\\w2k.tst";
+ const char *fname = "\\w2ktest\\w2k.tst";
int level;
BOOL correct = True;
@@ -2118,7 +2118,7 @@ static BOOL run_w2ktest(int dummy)
static BOOL run_oplock1(int dummy)
{
static struct cli_state cli1;
- char *fname = "\\lockt1.lck";
+ const char *fname = "\\lockt1.lck";
int fnum1;
BOOL correct = True;
@@ -2167,7 +2167,7 @@ static BOOL run_oplock1(int dummy)
static BOOL run_oplock2(int dummy)
{
static struct cli_state cli1, cli2;
- char *fname = "\\lockt2.lck";
+ const char *fname = "\\lockt2.lck";
int fnum1, fnum2;
int saved_use_oplocks = use_oplocks;
char buf[4];
@@ -2309,7 +2309,7 @@ static BOOL oplock3_handler(struct cli_state *cli, int fnum, unsigned char level
static BOOL run_oplock3(int dummy)
{
static struct cli_state cli;
- char *fname = "\\oplockt3.dat";
+ const char *fname = "\\oplockt3.dat";
int fnum;
char buf[4] = "abcd";
BOOL correct = True;
@@ -2364,7 +2364,7 @@ static BOOL run_deletetest(int dummy)
{
static struct cli_state cli1;
static struct cli_state cli2;
- char *fname = "\\delete.file";
+ const char *fname = "\\delete.file";
int fnum1 = -1;
int fnum2 = -1;
BOOL correct = True;
@@ -2843,7 +2843,7 @@ static BOOL run_properties(int dummy)
static BOOL run_xcopy(int dummy)
{
static struct cli_state cli1;
- char *fname = "\\test.txt";
+ const char *fname = "\\test.txt";
BOOL correct = True;
int fnum1, fnum2;
@@ -2885,8 +2885,8 @@ static BOOL run_xcopy(int dummy)
static BOOL run_rename(int dummy)
{
static struct cli_state cli1;
- char *fname = "\\test.txt";
- char *fname1 = "\\test1.txt";
+ const char *fname = "\\test.txt";
+ const char *fname1 = "\\test1.txt";
BOOL correct = True;
int fnum1;
@@ -3004,7 +3004,7 @@ static BOOL run_rename(int dummy)
static BOOL run_pipe_number(int dummy)
{
static struct cli_state cli1;
- char *pipe_name = "\\SPOOLSS";
+ const char *pipe_name = "\\SPOOLSS";
int fnum;
int num_pipes = 0;
@@ -3037,7 +3037,7 @@ static BOOL run_opentest(int dummy)
{
static struct cli_state cli1;
static struct cli_state cli2;
- char *fname = "\\readonly.file";
+ const char *fname = "\\readonly.file";
int fnum1, fnum2;
char buf[20];
size_t fsize;
@@ -3884,7 +3884,7 @@ static double create_procs(BOOL (*fn)(int), BOOL *result)
#define FLAG_MULTIPROC 1
static struct {
- char *name;
+ const char *name;
BOOL (*fn)(int);
unsigned flags;
} torture_ops[] = {
@@ -3935,7 +3935,7 @@ static struct {
/****************************************************************************
run a specified test or "ALL"
****************************************************************************/
-static BOOL run_test(char *name)
+static BOOL run_test(const char *name)
{
BOOL ret = True;
BOOL result = True;
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index c8250f15f8..78d22a07ac 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -403,7 +403,7 @@ static void process_file(struct vfs_state *pvfs, char *filename) {
}
}
-void exit_server(char *reason)
+void exit_server(const char *reason)
{
DEBUG(3,("Server exit (%s)\n", (reason ? reason : "")));
exit(0);
@@ -484,7 +484,7 @@ int main(int argc, char *argv[])
extern BOOL AllowDebugChange;
static struct vfs_state vfs;
int i;
- static char *filename = "";
+ static const char *filename = "";
/* make sure the vars that get altered (4th field) are in
a fixed location or certain compilers complain */
diff --git a/source3/torture/vfstest.h b/source3/torture/vfstest.h
index b086faa402..5910c5ce37 100644
--- a/source3/torture/vfstest.h
+++ b/source3/torture/vfstest.h
@@ -37,9 +37,9 @@ struct vfs_state {
};
struct cmd_set {
- char *name;
+ const char *name;
NTSTATUS (*fn)(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
char **argv);
- char *description;
- char *usage;
+ const char *description;
+ const char *usage;
};