summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-03-12 19:46:41 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-03-12 19:46:41 +0200
commitf224525204dcd5a4f907cf9eccbba82ee7ea9018 (patch)
treea27012713cbab24419c81ac5d1708e34d897b849 /extra
parentd82ac8d374241b100f9e019400b23a5d905f622c (diff)
downloadmariadb-git-f224525204dcd5a4f907cf9eccbba82ee7ea9018.tar.gz
MDEV-21907: InnoDB: Enable -Wconversion on clang and GCC
The -Wconversion in GCC seems to be stricter than in clang. GCC at least since version 4.4.7 issues truncation warnings for assignments to bitfields, while clang 10 appears to only issue warnings when the sizes in bytes rounded to the nearest integer powers of 2 are different. Before GCC 10.0.0, -Wconversion required more casts and would not allow some operations, such as x<<=1 or x+=1 on a data type that is narrower than int. GCC 5 (but not GCC 4, GCC 6, or any later version) is complaining about x|=y even when x and y are compatible types that are narrower than int. Hence, we must rewrite some x|=y as x=static_cast<byte>(x|y) or similar, or we must disable -Wconversion. In GCC 6 and later, the warning for assigning wider to bitfields that are narrower than 8, 16, or 32 bits can be suppressed by applying a bitwise & with the exact bitmask of the bitfield. For older GCC, we must disable -Wconversion for GCC 4 or 5 in such cases. The bitwise negation operator appears to promote short integers to a wider type, and hence we must add explicit truncation casts around them. Microsoft Visual C does not allow a static_cast to truncate a constant, such as static_cast<byte>(1) truncating int. Hence, we will use the constructor-style cast byte(~1) for such cases. This has been tested at least with GCC 4.8.5, 5.4.0, 7.4.0, 9.2.1, 10.0.0, clang 9.0.1, 10.0.0, and MSVC 14.22.27905 (Microsoft Visual Studio 2019) on 64-bit and 32-bit targets (IA-32, AMD64, POWER 8, POWER 9, ARMv8).
Diffstat (limited to 'extra')
-rw-r--r--extra/mariabackup/backup_mysql.cc3
-rw-r--r--extra/mariabackup/crc/crc-intel-pclmul.c2
-rw-r--r--extra/mariabackup/xtrabackup.cc68
3 files changed, 30 insertions, 43 deletions
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc
index 847340e6dc7..6c13079a8fc 100644
--- a/extra/mariabackup/backup_mysql.cc
+++ b/extra/mariabackup/backup_mysql.cc
@@ -505,7 +505,8 @@ get_mysql_vars(MYSQL *connection)
}
if (page_zip_level_var != NULL) {
- page_zip_level = strtoul(page_zip_level_var, &endptr, 10);
+ page_zip_level = static_cast<uint>(strtoul(page_zip_level_var,
+ &endptr, 10));
ut_ad(*endptr == 0);
}
diff --git a/extra/mariabackup/crc/crc-intel-pclmul.c b/extra/mariabackup/crc/crc-intel-pclmul.c
index cf4f3ef4380..032802c1823 100644
--- a/extra/mariabackup/crc/crc-intel-pclmul.c
+++ b/extra/mariabackup/crc/crc-intel-pclmul.c
@@ -358,7 +358,7 @@ crc32_reflected_less_than_16 (u32 *pcrc, const byte *inbuf, size_t inlen,
else
{
data = ((const struct u16_unaligned_s *)inbuf)->a;
- data |= inbuf[2] << 16;
+ data |= ((u32) inbuf[2]) << 16;
data ^= crc;
data <<= 8;
crc >>= 24;
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index aac87c61742..f3f216226aa 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -242,11 +242,6 @@ static char* innobase_ignored_opt;
char* innobase_data_home_dir;
char* innobase_data_file_path;
-my_bool innobase_use_doublewrite;
-my_bool innobase_file_per_table;
-my_bool innobase_rollback_on_timeout;
-my_bool innobase_create_status_file;
-
/* The following counter is used to convey information to InnoDB
about server activity: in selects it is not sensible to call
srv_active_wake_master_thread after each fetch or search, we only do
@@ -1236,8 +1231,8 @@ struct my_option xb_server_options[] =
&innobase_data_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE,
"Enable InnoDB doublewrite buffer during --prepare.",
- (G_PTR*) &innobase_use_doublewrite,
- (G_PTR*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ (G_PTR*) &srv_use_doublewrite_buf,
+ (G_PTR*) &srv_use_doublewrite_buf, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
"Number of IOPs the server can do. Tunes the background IO rate",
(G_PTR*) &srv_io_capacity, (G_PTR*) &srv_io_capacity,
@@ -1256,8 +1251,8 @@ struct my_option xb_server_options[] =
1, 0},
{"innodb_file_per_table", OPT_INNODB_FILE_PER_TABLE,
"Stores each InnoDB table to an .ibd file in the database dir.",
- (G_PTR*) &innobase_file_per_table,
- (G_PTR*) &innobase_file_per_table, 0, GET_BOOL, NO_ARG,
+ (G_PTR*) &srv_file_per_table,
+ (G_PTR*) &srv_file_per_table, 0, GET_BOOL, NO_ARG,
FALSE, 0, 0, 0, 0, 0},
{"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
@@ -1528,9 +1523,9 @@ static int prepare_export()
outf= popen(cmdline,"r");
if (!outf)
goto end;
-
+
char outline[FN_REFLEN];
- while(fgets(outline, sizeof(outline)-1, outf))
+ while (fgets(outline, FN_REFLEN - 1, outf))
fprintf(stderr,"%s",outline);
err = pclose(outf);
@@ -1887,14 +1882,7 @@ static bool innodb_init_param()
srv_n_read_io_threads = (ulint) innobase_read_io_threads;
srv_n_write_io_threads = (ulint) innobase_write_io_threads;
- srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
-
- row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
-
- srv_file_per_table = (my_bool) innobase_file_per_table;
-
srv_max_n_open_files = ULINT_UNDEFINED - 5;
- srv_innodb_status = (ibool) innobase_create_status_file;
srv_print_verbose_log = verbose ? 2 : 1;
@@ -2770,7 +2758,7 @@ static os_thread_ret_t DECLARE_THREAD(log_copying_thread)(void*)
for (;;) {
os_event_reset(log_copying_stop);
os_event_wait_time_low(log_copying_stop,
- xtrabackup_log_copy_interval * 1000ULL,
+ xtrabackup_log_copy_interval * 1000U,
0);
if (xtrabackup_copy_logfile()) {
break;
@@ -3764,26 +3752,23 @@ xb_filters_free()
}
}
-/***********************************************************************
+#ifdef RLIMIT_NOFILE
+/**
Set the open files limit. Based on set_max_open_files().
-
+@param max_file_limit requested open files limit
@return the resulting open files limit. May be less or more than the requested
value. */
-static uint
-xb_set_max_open_files(
-/*==================*/
- uint max_file_limit) /*!<in: open files limit */
+static ulong xb_set_max_open_files(rlim_t max_file_limit)
{
-#if defined(RLIMIT_NOFILE)
struct rlimit rlimit;
- uint old_cur;
+ rlim_t old_cur;
if (getrlimit(RLIMIT_NOFILE, &rlimit)) {
goto end;
}
- old_cur = (uint) rlimit.rlim_cur;
+ old_cur = rlimit.rlim_cur;
if (rlimit.rlim_cur == RLIM_INFINITY) {
@@ -3799,8 +3784,8 @@ xb_set_max_open_files(
rlimit.rlim_cur = rlimit.rlim_max = max_file_limit;
if (setrlimit(RLIMIT_NOFILE, &rlimit)) {
-
- max_file_limit = old_cur; /* Use original value */
+ /* Use original value */
+ max_file_limit = static_cast<ulong>(old_cur);
} else {
rlimit.rlim_cur = 0; /* Safety if next call fails */
@@ -3810,16 +3795,16 @@ xb_set_max_open_files(
if (rlimit.rlim_cur) {
/* If call didn't fail */
- max_file_limit = (uint) rlimit.rlim_cur;
+ max_file_limit = rlimit.rlim_cur;
}
}
end:
- return(max_file_limit);
+ return static_cast<ulong>(max_file_limit);
+}
#else
- return(0);
+# define xb_set_max_open_files(x) 0
#endif
-}
static void stop_backup_threads()
{
@@ -3950,8 +3935,8 @@ static bool xtrabackup_backup_func()
}
msg("cd to %s", mysql_real_data_home);
encryption_plugin_backup_init(mysql_connection);
- msg("open files limit requested %u, set to %u",
- (uint) xb_open_files_limit,
+ msg("open files limit requested %lu, set to %lu",
+ xb_open_files_limit,
xb_set_max_open_files(xb_open_files_limit));
mysql_data_home= mysql_data_home_buff;
@@ -4515,10 +4500,11 @@ xb_space_create_file(
fprintf(stderr, "zip_size = " ULINTPF "\n", zip_size);
#ifdef UNIV_DEBUG
- page_zip.m_start =
+ page_zip.m_start = 0;
#endif /* UNIV_DEBUG */
- page_zip.m_end = page_zip.m_nonempty =
- page_zip.n_blobs = 0;
+ page_zip.m_end = 0;
+ page_zip.m_nonempty = 0;
+ page_zip.n_blobs = 0;
buf_flush_init_for_writing(NULL, page, &page_zip, false);
@@ -6197,10 +6183,10 @@ static int main_low(char** argv)
incremental_lsn);
}
- if (xtrabackup_export && innobase_file_per_table == FALSE) {
+ if (xtrabackup_export && !srv_file_per_table) {
msg("mariabackup: auto-enabling --innodb-file-per-table due to "
"the --export option");
- innobase_file_per_table = TRUE;
+ srv_file_per_table = TRUE;
}
/* cannot execute both for now */