Skip to content

Commit

Permalink
PS-3767: Fixed clang 4/5 warnings for PS 5.7.
Browse files Browse the repository at this point in the history
* Initialized uninitailized variables
* Marked debug variables as possibly unused
* Marked the functions generated by the define_xdr_funcs macro possibly unused. This macro generates several functions, and only some of them is used.
* Removed the unused MYSQLX_PORT global constant
* Corrected two unsigned/signed std::max
* Disabled the unused variable warning for rocksdb, as it's in 3rd party code
* Removed non-null attributes from rocksdb (those parameters also have non null assertions)
* Added a missing override specifier
* Added additional braces to a struct initalizer
* Added a missing initializer parameter in tokudb
* Changed how optimization is disabled for a function
* Updated the Percona-TokuBackup submodule
* Added an ifdef around a variable in keyring_vault
* Modified travis config to include the llvm-dev package, to solve linking issues
* Marked two functions as possibly unused in yassl
  • Loading branch information
dutow committed Jan 30, 2018
1 parent 27a5f8f commit 320473c
Show file tree
Hide file tree
Showing 23 changed files with 99 additions and 84 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ matrix:
- env: GCC=gcc-4.8 CXX=g++-4.8 LIBTYPE=system CMAKE_OPT="-DWITH_READLINE=system"
- env: GCC=gcc-7 CXX=g++-7 LIBTYPE=system CMAKE_OPT="-DWITH_READLINE=system" PACKAGES=g++-7 PPA=ubuntu-toolchain-r/test
- env: GCC=gcc-7 CXX=g++-7 LIBTYPE=bundled CMAKE_OPT="-DWITH_PAM=1" PACKAGES=g++-7 PPA=ubuntu-toolchain-r/test
- env: GCC=clang-5.0 CXX=clang++-5.0 LIBTYPE=system CMAKE_OPT="-DWITH_READLINE=system" PACKAGES=clang-5.0 LLVM=llvm-toolchain-trusty-5.0
- env: GCC=clang-5.0 CXX=clang++-5.0 LIBTYPE=system CMAKE_OPT="-DWITH_READLINE=system" PACKAGES="clang-5.0 llvm-5.0-dev" LLVM=llvm-toolchain-trusty-5.0
# only for pull requests
- env: GCC=gcc-5 CXX=g++-5 LIBTYPE=system CMAKE_OPT="-DWITH_READLINE=system" PACKAGES=g++-5 PPA=ubuntu-toolchain-r/test
- env: GCC=gcc-6 CXX=g++-6 LIBTYPE=system CMAKE_OPT="-DWITH_READLINE=system" PACKAGES=g++-6 PPA=ubuntu-toolchain-r/test
- env: GCC=clang-4.0 CXX=clang++-4.0 LIBTYPE=system CMAKE_OPT="-DWITH_READLINE=system" PACKAGES=clang-4.0 PPA=ubuntu-toolchain-r/test LLVM=llvm-toolchain-trusty-4.0
- env: GCC=clang-5.0 CXX=clang++-5.0 LIBTYPE=bundled CMAKE_OPT="-DWITH_PAM=1" PACKAGES=clang-5.0 LLVM=llvm-toolchain-trusty-5.0
- env: GCC=clang-4.0 CXX=clang++-4.0 LIBTYPE=system CMAKE_OPT="-DWITH_READLINE=system" PACKAGES="clang-4.0 llvm-4.0-dev" PPA=ubuntu-toolchain-r/test LLVM=llvm-toolchain-trusty-4.0
- env: GCC=clang-5.0 CXX=clang++-5.0 LIBTYPE=bundled CMAKE_OPT="-DWITH_PAM=1" PACKAGES="clang-5.0 llvm-5.0-dev" LLVM=llvm-toolchain-trusty-5.0

script:
- export CC=$GCC
Expand Down
2 changes: 1 addition & 1 deletion client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ int main(int argc,char *argv[])
"statement.\n");
put_info(buff,INFO_INFO);

uint protocol, ssl_mode;
uint protocol= 0, ssl_mode= 0;
if (!mysql_get_option(&mysql, MYSQL_OPT_PROTOCOL, &protocol) &&
!mysql_get_option(&mysql, MYSQL_OPT_SSL_MODE, &ssl_mode))
{
Expand Down
1 change: 1 addition & 0 deletions client/mysqladmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
/* Warn about password being set in non ssl connection */
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
uint ssl_mode;
ssl_mode= 0;
if (!mysql_get_option(mysql, MYSQL_OPT_SSL_MODE, &ssl_mode) &&
ssl_mode <= SSL_MODE_PREFERRED)
{
Expand Down
2 changes: 2 additions & 0 deletions mysys_ssl/yassl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ static int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
return 1;
}

#ifndef NDEBUG
static int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx)
{
return ctx->key_len;
Expand All @@ -116,6 +117,7 @@ static int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
{
return ctx->flags & EVP_CIPH_ECB_MODE ? 0 : TaoCrypt::AES::BLOCK_SIZE;
}
#endif

static void do_whole_blocks(EVP_CIPHER_CTX *ctx, uchar *out, int *outl,
const uchar *in, int inl)
Expand Down
2 changes: 2 additions & 0 deletions plugin/keyring_vault/vault_curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ static const size_t max_response_size = 32000000;
static MY_TIMER_INFO curl_timer_info;
static ulonglong last_ping_time;
static bool was_thd_wait_started = false;
#ifndef NDEBUG
static const ulonglong slow_connection_threshold = 100; // [ms]
#endif

class Thd_wait_end_guard
{
Expand Down
2 changes: 1 addition & 1 deletion plugin/tokudb-backup-plugin/Percona-TokuBackup
19 changes: 11 additions & 8 deletions plugin/tokudb-backup-plugin/tokudb_backup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ static bool tokudb_backup_check_slave_sql_thread_running(THD *thd) {
++it)
{
Master_info *mi= it->second;
if (mi != NULL && mi->inited && mi->host && mi->host[0]) {
compile_time_assert(sizeof(mi->host) / sizeof(void*) > 1);
if (mi != NULL && mi->inited && mi->host[0]) {
have_slave = true;
scoped_lock_wrapper<BasicLockableMysqlMutextT>
with_mi_data_locked_1(BasicLockableMysqlMutextT(
Expand Down Expand Up @@ -359,7 +360,8 @@ static bool tokudb_backup_stop_slave_sql_thread(THD *thd) {
++it)
{
Master_info *mi = it->second;
if (mi && mi->inited && mi->host && mi->host[0]) {
compile_time_assert(sizeof(mi->host) / sizeof(void*) > 1);
if (mi && mi->inited && mi->host[0]) {
bool temp_tables_warning = false;
have_slave = true;
result = !stop_slave(thd, mi, 0, 0, &temp_tables_warning);
Expand Down Expand Up @@ -398,7 +400,8 @@ static bool tokudb_backup_start_slave_sql_thread(THD *thd) {
++it)
{
Master_info *mi= it->second;
if (mi && mi->inited && mi->host && mi->host[0]) {
compile_time_assert(sizeof(mi->host) / sizeof(void*) > 1);
if (mi && mi->inited && mi->host[0]) {
have_slave = true;
result = !start_slave(thd,
&thd->lex->slave_connection,
Expand Down Expand Up @@ -457,11 +460,10 @@ static bool tokudb_backup_wait_for_safe_slave(THD *thd, uint timeout) {
}

if (!n_attemts &&
slave_open_temp_tables.atomic_get()) {

(sql_thread_started &&
slave_open_temp_tables.atomic_get() &&
sql_thread_started &&
!tokudb_backup_check_slave_sql_thread_running(thd) &&
!tokudb_backup_start_slave_sql_thread(thd));
!tokudb_backup_start_slave_sql_thread(thd)) {

return false;
}
Expand Down Expand Up @@ -576,7 +578,8 @@ static void tokudb_backup_get_master_infos(
++it)
{
mi= it->second;
if (mi != NULL && mi->host && mi->host[0])
compile_time_assert(sizeof(mi->host) / sizeof(void*) > 1);
if (mi != NULL && mi->host[0])
tokudb_backup_get_master_info(mi,
executed_gtid_set,
master_info_channels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,10 @@ void Gcs_xcom_state_exchange::reset_with_flush()

void Gcs_xcom_state_exchange::reset()
{
#ifndef NDEBUG
Gcs_xcom_communication_interface *binding_broadcaster=
static_cast<Gcs_xcom_communication_interface *>(m_broadcaster);
#endif
assert(binding_broadcaster->number_buffered_messages() == 0);

m_configuration_id= null_synode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ extern "C" {
/**
Initialize an array
*/
#define def_init_xdr_array(name) static inline void init_##name##_array(name##_array *x)
#define def_init_xdr_array(name) \
MY_ATTRIBUTE((unused)) \
static inline void init_##name##_array(name##_array *x)
#define init_xdr_array(name) \
def_init_xdr_array(name) { \
x->name##_array_len = 2; \
Expand All @@ -35,7 +37,9 @@ extern "C" {
/**
Free the contents of an array
*/
#define def_free_xdr_array(name) static inline void free_##name##_array(name##_array *x)
#define def_free_xdr_array(name) \
MY_ATTRIBUTE((unused)) \
static inline void free_##name##_array(name##_array *x)
#define free_xdr_array(name)\
def_free_xdr_array(name)\
{\
Expand All @@ -62,6 +66,7 @@ def_free_xdr_array(name)\
Define a set function for an array
*/
#define def_set_xdr_array(name) \
MY_ATTRIBUTE((unused)) \
static inline void set_##name(name##_array *x, name a, u_int n)
#define set_xdr_array(name) \
def_set_xdr_array(name) { \
Expand All @@ -73,7 +78,9 @@ def_free_xdr_array(name)\
/**
Define a get function for an array
*/
#define def_get_xdr_array(name) static inline name get_##name(name##_array *x, u_int n)
#define def_get_xdr_array(name) \
MY_ATTRIBUTE((unused)) \
static inline name get_##name(name##_array *x, u_int n)
#define get_xdr_array(name) \
def_get_xdr_array(name) \
{ \
Expand All @@ -87,6 +94,7 @@ def_free_xdr_array(name)\
Define a function to clone an array
*/
#define def_clone_xdr_array(name) \
MY_ATTRIBUTE((unused)) \
static inline name##_array clone_##name##_array(name##_array x)
#define clone_xdr_array(name) \
def_clone_xdr_array(name) { \
Expand Down
1 change: 0 additions & 1 deletion rapid/plugin/x/mysqlxtest_src/mysqlxtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
const char * const CMD_ARG_BE_QUIET = "be-quiet";
const char * const MYSQLXTEST_VERSION = "1.0";
const char CMD_ARG_SEPARATOR = '\t';
const unsigned short MYSQLX_PORT = 33060;

#include <mysql/service_my_snprintf.h>
#include <mysql.h>
Expand Down
2 changes: 1 addition & 1 deletion sql/item_geofunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ append_geometry(Geometry::wkb_parser *parser, Json_object *geometry,
}
else
{
bool result;
bool result= false;
Json_array *points= new (std::nothrow) Json_array();
if (points == NULL || collection->append_alias(points))
return true;
Expand Down
9 changes: 6 additions & 3 deletions sql/sql_join_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ class JOIN_CACHE :public QEP_operation
/* Shall calculate how much space is remaining in the join buffer */
virtual ulong rem_space()
{
return std::max<ulong>(buff_size-(end_pos-buff)-aux_buff_size, 0UL);
return static_cast<ulong>(
std::max<long>(buff_size-(end_pos-buff)-aux_buff_size, 0L)
);
}

/* Shall skip record from the join buffer if its match flag is on */
Expand Down Expand Up @@ -812,8 +814,9 @@ class JOIN_CACHE_BKA_UNIQUE :public JOIN_CACHE_BKA
*/
ulong rem_space()
{
return std::max(static_cast<ulong>(last_key_entry - end_pos-aux_buff_size),
0UL);
return static_cast<ulong>(
std::max<long>(last_key_entry - end_pos-aux_buff_size, 0L)
);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/ut0new.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ class ut_allocator {

/* e.g. "btr0cur", derived from "/path/to/btr0cur.cc" */
char keyname[FILENAME_MAX];
const size_t len = ut_basename_noext(file, keyname,
sizeof(keyname));
const size_t len MY_ATTRIBUTE((unused)) =
ut_basename_noext(file, keyname, sizeof(keyname));
/* If sizeof(keyname) was not enough then the output would
be truncated, assert that this did not happen. */
ut_a(len < sizeof(keyname));
Expand Down
4 changes: 4 additions & 0 deletions storage/rocksdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
ENDIF()
ENDIF()

# Relax unused variable warnings
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable")

# check that compiler supports cxx11 and set options
INCLUDE (check_stdcxx11)
IF (!HAVE_STDCXX11)
Expand Down
8 changes: 3 additions & 5 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11466,9 +11466,9 @@ const char *get_rdb_io_error_string(const RDB_IO_ERROR_TYPE err_type) {
// In case of core dump generation we want this function NOT to be optimized
// so that we can capture as much data as possible to debug the root cause
// more efficiently.
#pragma GCC push_options
#pragma GCC optimize("O0")

#if defined(DBUG_OFF)
MY_ATTRIBUTE((optnone))
#endif
void rdb_handle_io_error(const rocksdb::Status status,
const RDB_IO_ERROR_TYPE err_type) {
if (status.IsIOError()) {
Expand Down Expand Up @@ -11517,8 +11517,6 @@ void rdb_handle_io_error(const rocksdb::Status status,
}
}

#pragma GCC pop_options

Rdb_dict_manager *rdb_get_dict_manager(void) { return &dict_manager; }

Rdb_ddl_manager *rdb_get_ddl_manager(void) { return &ddl_manager; }
Expand Down
Loading

0 comments on commit 320473c

Please sign in to comment.