r1123: Make all lp_ string functions return 'const char *'.
authorAndrew Bartlett <abartlet@samba.org>
Sun, 13 Jun 2004 23:50:55 +0000 (23:50 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:56:38 +0000 (12:56 -0500)
Fix other 'const' warnings in the torture code.

Andrew Bartlett
(This used to be commit 5d39d7497f189da15d659b3f83b7314026040a15)

14 files changed:
source4/lib/debug.c
source4/lib/util.c
source4/ntvfs/cifs/vfs_cifs.c
source4/param/loadparm.c
source4/script/mkproto.pl
source4/smb_server/connection.c
source4/smb_server/service.c
source4/smbd/rewrite.c
source4/torture/nbench/nbench.c
source4/torture/rpc/mgmt.c
source4/torture/rpc/scanner.c
source4/torture/rpc/schannel.c
source4/torture/rpc/winreg.c
source4/torture/torture.c

index c9247f380f4c19bde9081da24cd69d3a9acfb27e..4f6ba125d354cf253465449964391d781df92994 100644 (file)
@@ -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;
 
index 16f5e7a88870e18d84f6ce00afbfb48ac16a1e0b..0dbc2a125d2ffa7eef07532a093b53e3c5a46a11 100644 (file)
@@ -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) {
index 27c9e38ec4d8a9f5f8bc01269d351c6bb2f18050..9e8768ae221f8676af817020e3a8ac4a7742358a 100644 (file)
@@ -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;
 
index dba8a01dfdc6138e56fc5f5e6662abaa58c60a8e..029d5aade8baba4f74baaee74f9272a1dec8eaa9 100644 (file)
@@ -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)
index 02291fbb5b0a75d907834bf57ccc640aeafceda7..3c505f64d2fe1dbe57f05e5aacdb00fe858f33f0 100644 (file)
@@ -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 **",
index d7e26f4614f4da067bb07d4643aa2ba1fd83b148..389cf3c6dcb9ce6cb793fc37c1d86e7c75c27cb2 100644 (file)
@@ -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;
 };
 
index 1f8b00ae0dc4b6c26534e70395873dcabd2c80b3..5d4cb3f0fdc0cc2eda52c8ecea4bca7651b07146 100644 (file)
@@ -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();
index 38b8ad30158a50c1aa6ecde4ea5c39dc0b91418e..e32cd96a0e9b73a799bad0b869101c71ed6cfd57 100644 (file)
@@ -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)
index 53ca760b99ec8891040753e75bd5f0dd024aae3e..30291a829e0b075a19170a9fe8a108bf7ad18669 100644 (file)
@@ -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) {
index 431502fc5c13c0daf7bf8406ef4b05f07ea5dd99..a95fe43fb878727703b48c2b84107d24cdbcec30 100644 (file)
@@ -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");
index be83b6b6c6e1d7653183b404cd3bdc755165b06c..0c2f8dfbbe4decf310b4224e0e84ce3ee16cffda 100644 (file)
@@ -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");
index 712c2563a35494a3122fa005607a847f4e0ad270..e120c0d2adce9494af3867f14953372cf8caf8d5 100644 (file)
@@ -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;
 
index 3a1d7be68b28926db47867ebb4e5b6c30b4f6402..86b91eacc27903015c5ddd4fc3e6c47a40d57a4b 100644 (file)
@@ -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;
index 4d8fbd0a69a955f60ad79b983f182d67ab56b382..93e6c3ec7928ab9a08de8f6f51c538b63c4d865c 100644 (file)
@@ -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;