diff options
author | Monty <monty@mariadb.org> | 2021-02-05 14:57:46 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2021-02-08 12:16:29 +0200 |
commit | 5d6ad2ad66a677b67f2377d7665d6c140dd93323 (patch) | |
tree | 85a54b1a982beb401f04d5bcb621a1166b33b653 /client/mysqlcheck.c | |
parent | e30a3048dacca5180e8d7b2934d0b1fe44b4f383 (diff) | |
download | mariadb-git-5d6ad2ad66a677b67f2377d7665d6c140dd93323.tar.gz |
Added 'const' to arguments in get_one_option and find_typeset()
One should not change the program arguments!
This change also reduces warnings from the icc compiler.
Almost all changes are just syntax changes (adding const to
'get_one_option function' declarations).
Other changes:
- Added a few cast of 'argument' from 'const char*' to 'char *'. This
was mainly in calls to 'external' functions we don't have control of.
- Ensure that all reset of 'password command line argument' are similar.
(In almost all cases it was just adding a comment and a cast)
- In mysqlbinlog.cc and mysqld.cc there was a few cases that changed
the command line argument. These places where changed to instead allocate
the option in a MEM_ROOT to avoid changing the argument. Some of this
code was changed to ensure that different programs did parsing the
same way. Added a test case for the changes in mysqlbinlog.cc
- Changed a few variables that took their value from command line options
from 'char *' to 'const char *'.
Diffstat (limited to 'client/mysqlcheck.c')
-rw-r--r-- | client/mysqlcheck.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index d7eeec6198b..fb3103a318d 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -285,7 +285,8 @@ static void usage(void) static my_bool get_one_option(const struct my_option *opt, - char *argument, const char *filename __attribute__((unused))) + const char *argument, + const char *filename __attribute__((unused))) { int orig_what_to_do= what_to_do; DBUG_ENTER("get_one_option"); @@ -324,10 +325,15 @@ get_one_option(const struct my_option *opt, argument= (char*) ""; /* Don't require password */ if (argument) { - char *start = argument; + /* + One should not really change the argument, but we make an + exception for passwords + */ + char *start= (char*) argument; my_free(opt_password); opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); - while (*argument) *argument++= 'x'; /* Destroy argument */ + while (*argument) + *(char*) argument++= 'x'; /* Destroy argument */ if (*start) start[1] = 0; /* Cut length of argument */ tty_password= 0; |