From c2a26fe5e78bf5eaa7cc8fe929bb9546dc9c45bd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 26 Feb 2014 20:16:26 +0100 Subject: [PATCH] s3:utils: avoid argv related const warnings Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- source3/utils/log2pcaphex.c | 4 ++-- source3/utils/net.c | 7 ++++--- source3/utils/nmblookup.c | 4 ++-- source3/utils/pdbedit.c | 4 ++-- source3/utils/profiles.c | 4 ++-- source3/utils/regedit.c | 4 ++-- source3/utils/smbcacls.c | 5 +++-- source3/utils/smbcquotas.c | 5 +++-- source3/utils/smbtree.c | 7 ++++--- source3/utils/status.c | 4 ++-- 10 files changed, 26 insertions(+), 22 deletions(-) diff --git a/source3/utils/log2pcaphex.c b/source3/utils/log2pcaphex.c index 8425a5e71de..866abfd07fb 100644 --- a/source3/utils/log2pcaphex.c +++ b/source3/utils/log2pcaphex.c @@ -295,7 +295,7 @@ static long read_log_data(FILE *in, unsigned char *buffer, long data_length) return data_length; } -int main (int argc, char **argv) +int main(int argc, const char **argv) { const char *infile, *outfile; FILE *out, *in; @@ -312,7 +312,7 @@ int main (int argc, char **argv) POPT_TABLEEND }; - pc = poptGetContext(NULL, argc, (const char **) argv, long_options, + pc = poptGetContext(NULL, argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, "[ []]"); diff --git a/source3/utils/net.c b/source3/utils/net.c index 1308d9492e4..a6a9ec0119d 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -767,13 +767,14 @@ static struct functable net_func[] = { /**************************************************************************** main program ****************************************************************************/ - int main(int argc, const char **argv) + int main(int argc, char **argv) { int opt,i; char *p; int rc = 0; int argc_new = 0; const char ** argv_new; + const char **argv_const = discard_const_p(const char *, argv); poptContext pc; TALLOC_CTX *frame = talloc_stackframe(); struct net_context *c = talloc_zero(frame, struct net_context); @@ -852,7 +853,7 @@ static struct functable net_func[] = { lp_set_cmdline("log level", "0"); c->private_data = net_func; - pc = poptGetContext(NULL, argc, (const char **) argv, long_options, + pc = poptGetContext(NULL, argc, argv_const, long_options, POPT_CONTEXT_KEEP_FIRST); while((opt = poptGetNextOpt(pc)) != -1) { @@ -883,7 +884,7 @@ static struct functable net_func[] = { default: d_fprintf(stderr, _("\nInvalid option %s: %s\n"), poptBadOption(pc, 0), poptStrerror(opt)); - net_help(c, argc, argv); + net_help(c, argc, argv_const); exit(1); } } diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 0d5e64a8e46..9bbbc60eb78 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -214,7 +214,7 @@ static bool query_one(const char *lookup, unsigned int lookup_type) /**************************************************************************** main program ****************************************************************************/ -int main(int argc,char *argv[]) +int main(int argc, const char *argv[]) { int opt; unsigned int lookup_type = 0x0; @@ -246,7 +246,7 @@ int main(int argc,char *argv[]) setup_logging(argv[0], DEBUG_STDOUT); - pc = poptGetContext("nmblookup", argc, (const char **)argv, + pc = poptGetContext("nmblookup", argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, " ..."); diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 8e3a5a514bd..555b839899f 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -983,7 +983,7 @@ static int delete_machine_entry(const char *machinename) Start here. **********************************************************/ -int main (int argc, char **argv) +int main(int argc, const char **argv) { static int list_users = False; static int verbose = False; @@ -1068,7 +1068,7 @@ int main (int argc, char **argv) setup_logging("pdbedit", DEBUG_STDOUT); - pc = poptGetContext(NULL, argc, (const char **) argv, long_options, + pc = poptGetContext(NULL, argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); while((opt = poptGetNextOpt(pc)) != -1) { diff --git a/source3/utils/profiles.c b/source3/utils/profiles.c index 30c6ad0a1fb..442a7de0188 100644 --- a/source3/utils/profiles.c +++ b/source3/utils/profiles.c @@ -194,7 +194,7 @@ static bool copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, /********************************************************************* *********************************************************************/ -int main( int argc, char *argv[] ) +int main( int argc, const char *argv[] ) { TALLOC_CTX *frame = talloc_stackframe(); int opt; @@ -218,7 +218,7 @@ int main( int argc, char *argv[] ) setup_logging( "profiles", DEBUG_STDERR); - pc = poptGetContext("profiles", argc, (const char **)argv, long_options, + pc = poptGetContext("profiles", argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, ""); diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c index bd9765e5db8..21fd257e410 100644 --- a/source3/utils/regedit.c +++ b/source3/utils/regedit.c @@ -498,7 +498,7 @@ static void display_window(TALLOC_CTX *mem_ctx, struct registry_context *ctx) endwin(); } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct poptOption long_options[] = { POPT_AUTOHELP @@ -526,7 +526,7 @@ int main(int argc, char **argv) exit(1); } popt_common_set_auth_info(auth_info); - pc = poptGetContext("regedit", argc, (const char **)argv, long_options, 0); + pc = poptGetContext("regedit", argc, argv, long_options, 0); while ((opt = poptGetNextOpt(pc)) != -1) { /* TODO */ diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index e3b7099f4fd..8d3071cc956 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -1355,8 +1355,9 @@ static struct cli_state *connect_one(struct user_auth_info *auth_info, /**************************************************************************** main program ****************************************************************************/ - int main(int argc, const char *argv[]) +int main(int argc, char *argv[]) { + const char **argv_const = discard_const_p(const char *, argv); char *share; int opt; enum acl_mode mode = SMB_ACL_SET; @@ -1415,7 +1416,7 @@ static struct cli_state *connect_one(struct user_auth_info *auth_info, } popt_common_set_auth_info(auth_info); - pc = poptGetContext("smbcacls", argc, argv, long_options, 0); + pc = poptGetContext("smbcacls", argc, argv_const, long_options, 0); poptSetOtherOptionHelp(pc, "//server1/share1 filename\nACLs look like: " "'ACL:user:[ALLOWED|DENIED]/flags/permissions'"); diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 2791b93424f..cf382bc0259 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -553,8 +553,9 @@ static struct cli_state *connect_one(const char *share) /**************************************************************************** main program ****************************************************************************/ - int main(int argc, const char *argv[]) +int main(int argc, char *argv[]) { + const char **argv_const = discard_const_p(const char *, argv); char *share; int opt; int result; @@ -609,7 +610,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, } popt_common_set_auth_info(smbcquotas_auth_info); - pc = poptGetContext("smbcquotas", argc, argv, long_options, 0); + pc = poptGetContext("smbcquotas", argc, argv_const, long_options, 0); poptSetOtherOptionHelp(pc, "//server1/share1"); diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 76ee6489b99..89f77f76054 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -285,9 +285,10 @@ static bool print_tree(struct user_auth_info *user_info) /**************************************************************************** main program ****************************************************************************/ - int main(int argc,char *argv[]) +int main(int argc, char *argv[]) { TALLOC_CTX *frame = talloc_stackframe(); + const char **argv_const = discard_const_p(const char *, argv); struct user_auth_info *auth_info; struct poptOption long_options[] = { POPT_AUTOHELP @@ -313,8 +314,8 @@ static bool print_tree(struct user_auth_info *user_info) } popt_common_set_auth_info(auth_info); - pc = poptGetContext("smbtree", argc, (const char **)argv, long_options, - POPT_CONTEXT_KEEP_FIRST); + pc = poptGetContext("smbtree", argc, argv_const, long_options, + POPT_CONTEXT_KEEP_FIRST); while(poptGetNextOpt(pc) != -1); poptFreeContext(pc); popt_burn_cmdline_password(argc, argv); diff --git a/source3/utils/status.c b/source3/utils/status.c index 1ff0e36ad33..40d38c9064f 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -336,7 +336,7 @@ static void print_notify_recs(const char *path, printf("\n"); } - int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { int c; int profile_only = 0; @@ -375,7 +375,7 @@ static void print_notify_recs(const char *path, goto done; } - pc = poptGetContext(NULL, argc, (const char **) argv, long_options, + pc = poptGetContext(NULL, argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); while ((c = poptGetNextOpt(pc)) != -1) {