TS-1314: Apply const to argument descriptions
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b21ccf7d Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b21ccf7d Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b21ccf7d Branch: refs/heads/master Commit: b21ccf7dcaebfe8d1f458c7ab5ed867308bbcec9 Parents: c497ce5 Author: James Peach <[email protected]> Authored: Mon Jun 25 21:57:52 2012 -0700 Committer: James Peach <[email protected]> Committed: Tue Jul 10 08:47:50 2012 -0700 ---------------------------------------------------------------------- lib/ts/ink_args.cc | 22 +++++++++++----------- lib/ts/ink_args.h | 16 ++++++++-------- proxy/Main.cc | 6 +++--- proxy/Main.h | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b21ccf7d/lib/ts/ink_args.cc ---------------------------------------------------------------------- diff --git a/lib/ts/ink_args.cc b/lib/ts/ink_args.cc index f803ebf..a27bc63 100644 --- a/lib/ts/ink_args.cc +++ b/lib/ts/ink_args.cc @@ -33,16 +33,16 @@ Process arguments // Global variables // -char *file_arguments[MAX_FILE_ARGUMENTS] = { 0 }; -char *program_name = (char *) "Traffic Server"; -int n_file_arguments = 0; +const char *file_arguments[MAX_FILE_ARGUMENTS] = { 0 }; +const char *program_name = (char *) "Traffic Server"; +unsigned n_file_arguments = 0; // // Local variables // -static char *argument_types_keys = (char *) "ISDfFTL"; -static char *argument_types_descriptions[] = { +static const char *argument_types_keys = (char *) "ISDfFTL"; +static const char *argument_types_descriptions[] = { (char *) "int ", (char *) "str ", (char *) "dbl ", @@ -58,8 +58,8 @@ static char *argument_types_descriptions[] = { // static void -process_arg(ArgumentDescription * argument_descriptions, - int n_argument_descriptions, int i, char ***argv, const char *usage_string) +process_arg(const ArgumentDescription * argument_descriptions, + unsigned n_argument_descriptions, int i, char ***argv, const char *usage_string) { char *arg = NULL; if (argument_descriptions[i].type) { @@ -98,7 +98,7 @@ process_arg(ArgumentDescription * argument_descriptions, void -show_argument_configuration(ArgumentDescription * argument_descriptions, int n_argument_descriptions) +show_argument_configuration(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions) { int i = 0; printf("Argument Configuration\n"); @@ -133,9 +133,9 @@ show_argument_configuration(ArgumentDescription * argument_descriptions, int n_a } void -process_args(ArgumentDescription * argument_descriptions, int n_argument_descriptions, char **argv, const char *usage_string) +process_args(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions, char **argv, const char *usage_string) { - int i = 0; + unsigned i = 0; // // Grab Environment Variables // @@ -197,7 +197,7 @@ process_args(ArgumentDescription * argument_descriptions, int n_argument_descrip } void -usage(ArgumentDescription * argument_descriptions, int n_argument_descriptions, const char *usage_string) +usage(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions, const char *usage_string) { (void) argument_descriptions; (void) n_argument_descriptions; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b21ccf7d/lib/ts/ink_args.h ---------------------------------------------------------------------- diff --git a/lib/ts/ink_args.h b/lib/ts/ink_args.h index de6d34a..6686a93 100644 --- a/lib/ts/ink_args.h +++ b/lib/ts/ink_args.h @@ -34,7 +34,7 @@ Process arguments struct ArgumentDescription; -typedef void ArgumentFunction(ArgumentDescription * argument_descriptions, int n_argument_descriptions, const char *arg); +typedef void ArgumentFunction(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions, const char *arg); struct ArgumentDescription { @@ -59,19 +59,19 @@ struct ArgumentDescription /* Global Data */ -extern char *file_arguments[]; // exported by process_args() -extern int n_file_arguments; // exported by process_args() -extern char *program_name; // exported by process_args() +extern const char *file_arguments[]; // exported by process_args() +extern unsigned n_file_arguments; // exported by process_args() +extern const char *program_name; // exported by process_args() /* Print out arguments and values */ -void show_argument_configuration(ArgumentDescription * argument_descriptions, int n_argument_descriptions); +void show_argument_configuration(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions); -void usage(ArgumentDescription * argument_descriptions, int n_argument_descriptions, const char *arg_unused); +void usage(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions, const char *arg_unused); /* Process all arguments */ -void process_args(ArgumentDescription * argument_descriptions, - int n_argument_descriptions, char **argv, const char *usage_string = 0); +void process_args(const ArgumentDescription * argument_descriptions, + unsigned n_argument_descriptions, char **argv, const char *usage_string = 0); #endif /*_INK_ARGS_H*/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b21ccf7d/proxy/Main.cc ---------------------------------------------------------------------- diff --git a/proxy/Main.cc b/proxy/Main.cc index 257fd13..29ccb8c 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -178,14 +178,14 @@ extern int run_TestHook(); #endif void deinitSubAgent(); -Version version = { +const Version version = { {CACHE_DB_MAJOR_VERSION, CACHE_DB_MINOR_VERSION}, // cacheDB {CACHE_DIR_MAJOR_VERSION, CACHE_DIR_MINOR_VERSION}, // cacheDir {CLUSTER_MAJOR_VERSION, CLUSTER_MINOR_VERSION}, // current clustering {MIN_CLUSTER_MAJOR_VERSION, MIN_CLUSTER_MINOR_VERSION}, // min clustering }; -ArgumentDescription argument_descriptions[] = { +static const ArgumentDescription argument_descriptions[] = { {"lock_memory", 'l', "Lock process in memory (must be root)", "I", &lock_process, "PROXY_LOCK_PROCESS", NULL}, {"net_threads", 'n', "Number of Net Threads", "I", &num_of_net_threads, @@ -262,7 +262,7 @@ ArgumentDescription argument_descriptions[] = { NULL, NULL}, {"help", 'h', "HELP!", NULL, NULL, NULL, usage}, }; -int n_argument_descriptions = SIZE(argument_descriptions); +static const unsigned n_argument_descriptions = SIZE(argument_descriptions); // // Initialize operating system related information/services http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b21ccf7d/proxy/Main.h ---------------------------------------------------------------------- diff --git a/proxy/Main.h b/proxy/Main.h index 9ce0375..39b74a5 100644 --- a/proxy/Main.h +++ b/proxy/Main.h @@ -85,7 +85,7 @@ maintainance_mode() void syslog_thr_init(); -extern Version version; +extern const Version version; extern AppVersionInfo appVersionInfo; #define TS_ReadConfigInteger REC_ReadConfigInteger
