summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-02-05 14:57:46 +0200
committerMonty <monty@mariadb.org>2021-02-08 12:16:29 +0200
commit5d6ad2ad66a677b67f2377d7665d6c140dd93323 (patch)
tree85a54b1a982beb401f04d5bcb621a1166b33b653 /extra
parente30a3048dacca5180e8d7b2934d0b1fe44b4f383 (diff)
downloadmariadb-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 'extra')
-rw-r--r--extra/comp_err.c2
-rw-r--r--extra/innochecksum.cc2
-rw-r--r--extra/mariabackup/innobackupex.cc4
-rw-r--r--extra/mariabackup/xbstream.cc7
-rw-r--r--extra/mariabackup/xtrabackup.cc11
-rw-r--r--extra/mariabackup/xtrabackup.h2
-rw-r--r--extra/my_print_defaults.c2
-rw-r--r--extra/mysql_waitpid.c2
-rw-r--r--extra/perror.c2
-rw-r--r--extra/resolve_stack_dump.c2
-rw-r--r--extra/resolveip.c2
11 files changed, 20 insertions, 18 deletions
diff --git a/extra/comp_err.c b/extra/comp_err.c
index 5e1e042f6ed..aab57c5ff28 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -1140,7 +1140,7 @@ static void print_version(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__ ((unused)),
+ const char *argument __attribute__ ((unused)),
const char *filename __attribute__ ((unused)))
{
DBUG_ENTER("get_one_option");
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc
index 7805dc4283f..833e66341c7 100644
--- a/extra/innochecksum.cc
+++ b/extra/innochecksum.cc
@@ -1332,7 +1332,7 @@ static void usage(void)
extern "C" my_bool
innochecksum_get_one_option(
const struct my_option *opt,
- char *argument MY_ATTRIBUTE((unused)),
+ const char *argument MY_ATTRIBUTE((unused)),
const char *)
{
switch (opt->id) {
diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc
index 9e95d2e6b16..e874890ad27 100644
--- a/extra/mariabackup/innobackupex.cc
+++ b/extra/mariabackup/innobackupex.cc
@@ -88,7 +88,7 @@ char *opt_ibx_incremental_history_name = NULL;
char *opt_ibx_incremental_history_uuid = NULL;
char *opt_ibx_user = NULL;
-char *opt_ibx_password = NULL;
+const char *opt_ibx_password = NULL;
char *opt_ibx_host = NULL;
char *opt_ibx_defaults_group = NULL;
char *opt_ibx_socket = NULL;
@@ -731,7 +731,7 @@ indicates an error.\n");
static
my_bool
ibx_get_one_option(const struct my_option *opt,
- char *argument, const char *)
+ const char *argument, const char *)
{
switch(opt->id) {
case '?':
diff --git a/extra/mariabackup/xbstream.cc b/extra/mariabackup/xbstream.cc
index c22c7cc8f39..3fe9d17d86e 100644
--- a/extra/mariabackup/xbstream.cc
+++ b/extra/mariabackup/xbstream.cc
@@ -90,7 +90,7 @@ static int get_options(int *argc, char ***argv);
static int mode_create(int argc, char **argv);
static int mode_extract(int n_threads, int argc, char **argv);
static my_bool get_one_option(const struct my_option *opt,
- char *argument, const char *filename);
+ const char *argument, const char *filename);
int
main(int argc, char **argv)
@@ -138,7 +138,8 @@ get_options(int *argc, char ***argv)
int ho_error;
if ((ho_error= handle_options(argc, argv, my_long_options,
- get_one_option))) {
+ get_one_option)))
+ {
exit(EXIT_FAILURE);
}
@@ -191,7 +192,7 @@ set_run_mode(run_mode_t mode)
static
my_bool
-get_one_option(const struct my_option *opt, char *, const char *)
+get_one_option(const struct my_option *opt, const char *, const char *)
{
switch (opt->id) {
case 'c':
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index b8cdf4cd9db..495c7d7e2fe 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -311,7 +311,7 @@ char *opt_incremental_history_name;
char *opt_incremental_history_uuid;
char *opt_user;
-char *opt_password;
+const char *opt_password;
char *opt_host;
char *opt_defaults_group;
char *opt_socket;
@@ -1861,7 +1861,7 @@ check_if_param_set(const char *param)
my_bool
xb_get_one_option(const struct my_option *opt,
- char *argument, const char *)
+ const char *argument, const char *)
{
switch(opt->id) {
case 'h':
@@ -6348,9 +6348,10 @@ void handle_options(int argc, char **argv, char ***argv_server,
if (opt_password)
{
- char *argument= opt_password;
- char *start= argument;
- opt_password= my_strdup(PSI_NOT_INSTRUMENTED, opt_password, MYF(MY_FAE));
+ char *argument= (char*) opt_password;
+ char *start= (char*) opt_password;
+ opt_password= my_strdup(PSI_NOT_INSTRUMENTED, opt_password,
+ MYF(MY_FAE));
while (*argument)
*argument++= 'x'; // Destroy argument
if (*start)
diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h
index 6376849430c..aff7d1cb287 100644
--- a/extra/mariabackup/xtrabackup.h
+++ b/extra/mariabackup/xtrabackup.h
@@ -144,7 +144,7 @@ extern char *opt_incremental_history_name;
extern char *opt_incremental_history_uuid;
extern char *opt_user;
-extern char *opt_password;
+extern const char *opt_password;
extern char *opt_host;
extern char *opt_defaults_group;
extern char *opt_socket;
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index 09bd26c59ea..a8c8050cb1d 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -105,7 +105,7 @@ static void usage()
static my_bool
get_one_option(const struct my_option *opt __attribute__((unused)),
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename)
{
switch (opt->id) {
diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c
index 92716489bea..8f2a5c99395 100644
--- a/extra/mysql_waitpid.c
+++ b/extra/mysql_waitpid.c
@@ -45,7 +45,7 @@ static struct my_option my_long_options[] =
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/extra/perror.c b/extra/perror.c
index 131dd2676ec..ee6e362e06b 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -97,7 +97,7 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch (opt->id) {
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c
index c4ed2a9ccd7..cb4d6ed33e5 100644
--- a/extra/resolve_stack_dump.c
+++ b/extra/resolve_stack_dump.c
@@ -112,7 +112,7 @@ void local_exit(int error)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/extra/resolveip.c b/extra/resolveip.c
index 6812bc47e8e..890912d9850 100644
--- a/extra/resolveip.c
+++ b/extra/resolveip.c
@@ -72,7 +72,7 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch (opt->id) {