From b1268fc4455f61ee49412fc256106cd34e98ce7c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 13 Jun 2004 23:50:55 +0000 Subject: r1123: Make all lp_ string functions return 'const char *'. Fix other 'const' warnings in the torture code. Andrew Bartlett (This used to be commit 5d39d7497f189da15d659b3f83b7314026040a15) --- source4/lib/debug.c | 2 +- source4/lib/util.c | 2 +- source4/ntvfs/cifs/vfs_cifs.c | 2 +- source4/param/loadparm.c | 20 ++++++++++---------- source4/script/mkproto.pl | 2 +- source4/smb_server/connection.c | 2 +- source4/smb_server/service.c | 2 +- source4/smbd/rewrite.c | 2 +- source4/torture/nbench/nbench.c | 4 ++-- source4/torture/rpc/mgmt.c | 2 +- source4/torture/rpc/scanner.c | 2 +- source4/torture/rpc/schannel.c | 2 +- source4/torture/rpc/winreg.c | 3 ++- source4/torture/torture.c | 32 ++++++++++++++++---------------- 14 files changed, 40 insertions(+), 39 deletions(-) (limited to 'source4') diff --git a/source4/lib/debug.c b/source4/lib/debug.c index c9247f380f..4f6ba125d3 100644 --- a/source4/lib/debug.c +++ b/source4/lib/debug.c @@ -68,7 +68,7 @@ void do_debug(const char *format, ...) */ void reopen_logs(void) { - char *logfile = lp_logfile(); + const char *logfile = lp_logfile(); char *fname = NULL; int old_fd = state.fd; diff --git a/source4/lib/util.c b/source4/lib/util.c index 16f5e7a888..0dbc2a125d 100644 --- a/source4/lib/util.c +++ b/source4/lib/util.c @@ -568,7 +568,7 @@ gid_t nametogid(const char *name) void smb_panic(const char *why) { - char *cmd = lp_panic_action(); + const char *cmd = lp_panic_action(); int result; if (cmd && *cmd) { diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 27c9e38ec4..9e8768ae22 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -92,7 +92,7 @@ static NTSTATUS cvfs_connect(struct request_context *req, const char *sharename) struct tcon_context *conn = req->conn; NTSTATUS status; struct cvfs_private *private; - char *map_calls; + const char *map_calls; struct fd_event fde; const char *host, *user, *pass, *domain, *remote_share; diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index dba8a01dfd..029d5aade8 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -1125,7 +1125,7 @@ void lp_talloc_free(void) callers without affecting the source string. ********************************************************************/ -static char *lp_string(const char *s) +static const char *lp_string(const char *s) { #if 0 /* until REWRITE done to make thread-safe */ size_t len = s ? strlen(s) : 0; @@ -1172,7 +1172,7 @@ static char *lp_string(const char *s) */ #define FN_GLOBAL_STRING(fn_name,ptr) \ - char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));} + const char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));} #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \ const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");} #define FN_GLOBAL_LIST(fn_name,ptr) \ @@ -1185,7 +1185,7 @@ static char *lp_string(const char *s) int fn_name(void) {return(*(int *)(ptr));} #define FN_LOCAL_STRING(fn_name,val) \ - char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));} + const char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));} #define FN_LOCAL_CONST_STRING(fn_name,val) \ const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);} #define FN_LOCAL_LIST(fn_name,val) \ @@ -1500,7 +1500,7 @@ static int lp_enum(const char *s,const struct enum_list *_enum) /* Parametric option has following syntax: 'Type: option = value' */ /* Returned value is allocated in 'lp_talloc' context */ -char *lp_parm_string(int lookup_service, const char *type, const char *option) +const char *lp_parm_string(int lookup_service, const char *type, const char *option) { const char *value = get_parametrics(lookup_service, type, option); @@ -2990,7 +2990,7 @@ BOOL lp_snum_ok(int iService) Auto-load some home services. ***************************************************************************/ -static void lp_add_auto_services(char *str) +static void lp_add_auto_services(const char *str) { return; } @@ -3325,9 +3325,9 @@ int lp_servicenumber(const char *pszServiceName) /******************************************************************* A useful volume label function. ********************************************************************/ -char *volume_label(int snum) +const char *volume_label(int snum) { - char *ret = lp_volume(snum); + const char *ret = lp_volume(snum); if (!*ret) return lp_servicename(snum); return (ret); @@ -3431,7 +3431,7 @@ void lp_remove_service(int snum) void lp_copy_service(int snum, const char *new_name) { - char *oldname = lp_servicename(snum); + const char *oldname = lp_servicename(snum); do_section(new_name); if (snum >= 0) { snum = lp_servicenumber(new_name); @@ -3458,7 +3458,7 @@ int lp_major_announce_version(void) { static BOOL got_major = False; static int major_version = DEFAULT_MAJOR_VERSION; - char *vers; + const char *vers; char *p; if (got_major) @@ -3480,7 +3480,7 @@ int lp_minor_announce_version(void) { static BOOL got_minor = False; static int minor_version = DEFAULT_MINOR_VERSION; - char *vers; + const char *vers; char *p; if (got_minor) diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl index 02291fbb5b..3c505f64d2 100644 --- a/source4/script/mkproto.pl +++ b/source4/script/mkproto.pl @@ -34,7 +34,7 @@ sub handle_loadparm { my %tmap = ( "BOOL" => "BOOL ", "CONST_STRING" => "const char *", - "STRING" => "char *", + "STRING" => "const char *", "INTEGER" => "int ", "CHAR" => "char ", "LIST" => "const char **", diff --git a/source4/smb_server/connection.c b/source4/smb_server/connection.c index d7e26f4614..389cf3c6dc 100644 --- a/source4/smb_server/connection.c +++ b/source4/smb_server/connection.c @@ -63,7 +63,7 @@ BOOL yield_connection(struct tcon_context *conn, const char *name) struct count_stat { pid_t mypid; int curr_connections; - char *name; + const char *name; BOOL Clear; }; diff --git a/source4/smb_server/service.c b/source4/smb_server/service.c index 1f8b00ae0d..5d4cb3f0fd 100644 --- a/source4/smb_server/service.c +++ b/source4/smb_server/service.c @@ -75,7 +75,7 @@ static int find_service(const char *service) int iPrinterService; if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) >= 0) { - char *pszTemp; + const char *pszTemp; DEBUG(3,("checking whether %s is a valid printer name...\n", service)); pszTemp = lp_printcapname(); diff --git a/source4/smbd/rewrite.c b/source4/smbd/rewrite.c index 38b8ad3015..e32cd96a0e 100644 --- a/source4/smbd/rewrite.c +++ b/source4/smbd/rewrite.c @@ -32,7 +32,7 @@ BOOL init_change_notify(void) { return True; } -BOOL pcap_printername_ok(const char *service, char *foo) +BOOL pcap_printername_ok(const char *service, const char *foo) { return True; } BOOL namecache_enable(void) diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c index 53ca760b99..30291a829e 100644 --- a/source4/torture/nbench/nbench.c +++ b/source4/torture/nbench/nbench.c @@ -23,7 +23,7 @@ int nbench_line_count = 0; static int timelimit = 600; static int warmup; -static char *loadfile; +static const char *loadfile; #define ival(s) strtol(s, NULL, 0) @@ -165,7 +165,7 @@ BOOL torture_nbench(int dummy) BOOL correct = True; extern int torture_nprocs; struct cli_state *cli; - char *p; + const char *p; p = lp_parm_string(-1, "torture", "timelimit"); if (p && *p) { diff --git a/source4/torture/rpc/mgmt.c b/source4/torture/rpc/mgmt.c index 431502fc5c..a95fe43fb8 100644 --- a/source4/torture/rpc/mgmt.c +++ b/source4/torture/rpc/mgmt.c @@ -173,7 +173,7 @@ BOOL torture_rpc_mgmt(int dummy) TALLOC_CTX *mem_ctx; BOOL ret = True; int i; - char *binding = lp_parm_string(-1, "torture", "binding"); + const char *binding = lp_parm_string(-1, "torture", "binding"); struct dcerpc_binding b; mem_ctx = talloc_init("torture_rpc_mgmt"); diff --git a/source4/torture/rpc/scanner.c b/source4/torture/rpc/scanner.c index be83b6b6c6..0c2f8dfbbe 100644 --- a/source4/torture/rpc/scanner.c +++ b/source4/torture/rpc/scanner.c @@ -134,7 +134,7 @@ BOOL torture_rpc_scanner(int dummy) TALLOC_CTX *mem_ctx; BOOL ret = True; int i; - char *binding = lp_parm_string(-1, "torture", "binding"); + const char *binding = lp_parm_string(-1, "torture", "binding"); struct dcerpc_binding b; mem_ctx = talloc_init("torture_rpc_scanner"); diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c index 712c2563a3..e120c0d2ad 100644 --- a/source4/torture/rpc/schannel.c +++ b/source4/torture/rpc/schannel.c @@ -61,7 +61,7 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx, void *join_ctx; const char *machine_password; NTSTATUS status; - char *binding = lp_parm_string(-1, "torture", "binding"); + const char *binding = lp_parm_string(-1, "torture", "binding"); struct dcerpc_binding b; struct dcerpc_pipe *p; diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index 3a1d7be68b..86b91eacc2 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -55,7 +55,8 @@ static BOOL test_GetVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } static BOOL test_CreateKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, char *name, const char *class) + struct policy_handle *handle, const char *name, + const char *class) { struct winreg_CreateKey r; struct policy_handle newhandle; diff --git a/source4/torture/torture.c b/source4/torture/torture.c index 4d8fbd0a69..93e6c3ec79 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -39,7 +39,7 @@ static struct cli_state *open_nbt_connection(void) struct nmb_name called, calling; struct in_addr ip; struct cli_state *cli; - char *host = lp_parm_string(-1, "torture", "host"); + const char *host = lp_parm_string(-1, "torture", "host"); make_nmb_name(&calling, lp_netbios_name(), 0x0); make_nmb_name(&called , host, 0x20); @@ -89,8 +89,8 @@ BOOL torture_open_connection_share(struct cli_state **c, BOOL retry; int flags = 0; NTSTATUS status; - char *username = lp_parm_string(-1, "torture", "username"); - char *password = lp_parm_string(-1, "torture", "password"); + const char *username = lp_parm_string(-1, "torture", "username"); + const char *password = lp_parm_string(-1, "torture", "password"); if (use_kerberos) flags |= CLI_FULL_CONNECTION_USE_KERBEROS; @@ -114,8 +114,8 @@ BOOL torture_open_connection_share(struct cli_state **c, BOOL torture_open_connection(struct cli_state **c) { - char *host = lp_parm_string(-1, "torture", "host"); - char *share = lp_parm_string(-1, "torture", "share"); + const char *host = lp_parm_string(-1, "torture", "host"); + const char *share = lp_parm_string(-1, "torture", "share"); return torture_open_connection_share(c, host, share); } @@ -145,7 +145,7 @@ NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p, uint32_t pipe_version) { NTSTATUS status; - char *binding = lp_parm_string(-1, "torture", "binding"); + const char *binding = lp_parm_string(-1, "torture", "binding"); if (!binding) { printf("You must specify a ncacn binding string\n"); @@ -670,9 +670,9 @@ static BOOL run_tcon_test(int dummy) char buf[4]; BOOL ret = True; struct cli_tree *tree1; - char *host = lp_parm_string(-1, "torture", "host"); - char *share = lp_parm_string(-1, "torture", "share"); - char *password = lp_parm_string(-1, "torture", "password"); + const char *host = lp_parm_string(-1, "torture", "host"); + const char *share = lp_parm_string(-1, "torture", "share"); + const char *password = lp_parm_string(-1, "torture", "password"); if (!torture_open_connection(&cli)) { return False; @@ -776,7 +776,7 @@ static BOOL tcon_devtest(struct cli_state *cli, { BOOL status; BOOL ret; - char *password = lp_parm_string(-1, "torture", "password"); + const char *password = lp_parm_string(-1, "torture", "password"); status = NT_STATUS_IS_OK(cli_send_tconX(cli, myshare, devtype, password)); @@ -822,10 +822,10 @@ static BOOL run_tcon_devtype_test(int dummy) int flags = 0; NTSTATUS status; BOOL ret = True; - char *host = lp_parm_string(-1, "torture", "host"); - char *share = lp_parm_string(-1, "torture", "share"); - char *username = lp_parm_string(-1, "torture", "username"); - char *password = lp_parm_string(-1, "torture", "password"); + const char *host = lp_parm_string(-1, "torture", "host"); + const char *share = lp_parm_string(-1, "torture", "share"); + const char *username = lp_parm_string(-1, "torture", "username"); + const char *password = lp_parm_string(-1, "torture", "password"); status = cli_full_connection(&cli1, lp_netbios_name(), host, NULL, @@ -1763,7 +1763,7 @@ test how many open files this server supports on the one socket static BOOL run_deferopen(struct cli_state *cli, int dummy) { - char *fname = "\\defer_open_test.dat"; + const char *fname = "\\defer_open_test.dat"; int retries=4; int i = 0; BOOL correct = True; @@ -3987,7 +3987,7 @@ double torture_create_procs(BOOL (*fn)(struct cli_state *, int), BOOL *result) int tries = 8; double start_time_limit = 10 + (torture_nprocs * 1.5); char **unc_list = NULL; - char *p; + const char *p; int num_unc_names = 0; synccount = 0; -- cgit