@@ -121,7 +121,6 @@ static struct my_option my_long_options[]=
121121 & opt_not_used , & opt_not_used , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
122122 {"host" , 'h' , "Connect to host." , 0 ,
123123 0 , 0 , GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
124- #define PASSWORD_OPT 12
125124 {"password" , 'p' ,
126125 "Password to use when connecting to server. If password is not given,"
127126 " it's solicited on the tty." , & opt_password ,& opt_password ,
@@ -158,7 +157,6 @@ static struct my_option my_long_options[]=
158157 {"upgrade-system-tables" , 's' , "Only upgrade the system tables in the mysql database. Tables in other databases are not checked or touched." ,
159158 & opt_systables_only , & opt_systables_only , 0 ,
160159 GET_BOOL , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
161- #define USER_OPT (array_elements (my_long_options ) - 6 )
162160 {"user" , 'u' , "User for login." , & opt_user ,
163161 & opt_user , 0 , GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
164162 {"verbose" , 'v' , "Display more output about the process; Using it twice will print connection argument; Using it 3 times will print out all CHECK, RENAME and ALTER TABLE during the check phase." ,
@@ -264,11 +262,11 @@ static void print_error(const char *error_msg, DYNAMIC_STRING *output)
264262*/
265263
266264static void add_one_option_cmd_line (DYNAMIC_STRING * ds ,
267- const struct my_option * opt ,
268- const char * arg )
265+ const char * name ,
266+ const char * arg )
269267{
270268 dynstr_append (ds , "--" );
271- dynstr_append (ds , opt -> name );
269+ dynstr_append (ds , name );
272270 if (arg )
273271 {
274272 dynstr_append (ds , "=" );
@@ -278,10 +276,10 @@ static void add_one_option_cmd_line(DYNAMIC_STRING *ds,
278276}
279277
280278static void add_one_option_cnf_file (DYNAMIC_STRING * ds ,
281- const struct my_option * opt ,
282- const char * arg )
279+ const char * name ,
280+ const char * arg )
283281{
284- dynstr_append (ds , opt -> name );
282+ dynstr_append (ds , name );
285283 if (arg )
286284 {
287285 dynstr_append (ds , "=" );
@@ -324,7 +322,7 @@ get_one_option(int optid, const struct my_option *opt,
324322 if (argument )
325323 {
326324 /* Add password to ds_args before overwriting the arg with x's */
327- add_one_option_cnf_file (& ds_args , opt , argument );
325+ add_one_option_cnf_file (& ds_args , opt -> name , argument );
328326 while (* argument )
329327 * argument ++ = 'x' ; /* Destroy argument */
330328 tty_password = 0 ;
@@ -383,7 +381,7 @@ get_one_option(int optid, const struct my_option *opt,
383381 case OPT_SHARED_MEMORY_BASE_NAME : /* --shared-memory-base-name */
384382 case OPT_PLUGIN_DIR : /* --plugin-dir */
385383 case OPT_DEFAULT_AUTH : /* --default-auth */
386- add_one_option_cmd_line (& conn_args , opt , argument );
384+ add_one_option_cmd_line (& conn_args , opt -> name , argument );
387385 break ;
388386 }
389387
@@ -394,7 +392,7 @@ get_one_option(int optid, const struct my_option *opt,
394392 it can be passed on to "mysql" and "mysqlcheck"
395393 Save it in the ds_args string
396394 */
397- add_one_option_cnf_file (& ds_args , opt , argument );
395+ add_one_option_cnf_file (& ds_args , opt -> name , argument );
398396 }
399397 return 0 ;
400398}
@@ -1349,12 +1347,10 @@ int main(int argc, char **argv)
13491347 {
13501348 opt_password = get_tty_password (NullS );
13511349 /* add password to defaults file */
1352- add_one_option_cnf_file (& ds_args , & my_long_options [PASSWORD_OPT ], opt_password );
1353- DBUG_ASSERT (strcmp (my_long_options [PASSWORD_OPT ].name , "password" ) == 0 );
1350+ add_one_option_cnf_file (& ds_args , "password" , opt_password );
13541351 }
13551352 /* add user to defaults file */
1356- add_one_option_cnf_file (& ds_args , & my_long_options [USER_OPT ], opt_user );
1357- DBUG_ASSERT (strcmp (my_long_options [USER_OPT ].name , "user" ) == 0 );
1353+ add_one_option_cnf_file (& ds_args , "user" , opt_user );
13581354
13591355 cnf_file_path = strmov (defaults_file , "--defaults-file=" );
13601356 {
0 commit comments