cmake: re-enable -Werror in the maintainer mode

now we can afford it. Fix -Werror errors. Note:
* old gcc is bad at detecting uninit variables, disable it.
* time_t is int or long, cast it for printf's
This commit is contained in:
Sergei Golubchik 2019-03-16 19:24:49 +01:00
parent 1a4746e128
commit f97d879bf8
25 changed files with 76 additions and 69 deletions

View File

@ -28,10 +28,15 @@ SET(MY_WARNING_FLAGS
-Woverloaded-virtual
-Wvla
-Wwrite-strings
-Werror
)
IF(MYSQL_MAINTAINER_MODE MATCHES "ON")
SET(WHERE)
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0")
SET(MY_WARNING_FLAGS ${MY_WARNING_FLAGS} -Wno-error=maybe-uninitialized)
ENDIF()
IF(MYSQL_MAINTAINER_MODE MATCHES "OFF")
RETURN()
ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO")
SET(WHERE DEBUG)
ENDIF()

View File

@ -32,17 +32,18 @@
*/
#undef MYSQL_PLUGIN_EXPORT
#if defined(_MSC_VER)
#ifdef __cplusplus
#define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
#else
#define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
#endif
#define MYSQL_PLUGIN_EXPORT_C __declspec(dllexport)
#else /*_MSC_VER */
#ifdef __cplusplus
#define MYSQL_PLUGIN_EXPORT extern "C"
#else
#define MYSQL_PLUGIN_EXPORT
#endif
#define MYSQL_PLUGIN_EXPORT_C
#endif
#ifdef __cplusplus
#define MYSQL_PLUGIN_EXPORT extern "C" MYSQL_PLUGIN_EXPORT_C
#define C_MODE_START extern "C" {
#define C_MODE_END }
#else
#define MYSQL_PLUGIN_EXPORT MYSQL_PLUGIN_EXPORT_C
#define C_MODE_START
#define C_MODE_END
#endif
#ifndef MYSQL_ABI_CHECK
@ -60,11 +61,12 @@
#define MYSQL_CLIENT_MAX_PLUGINS 3
#define mysql_declare_client_plugin(X) \
MYSQL_PLUGIN_EXPORT struct st_mysql_client_plugin_ ## X \
C_MODE_START MYSQL_PLUGIN_EXPORT_C \
struct st_mysql_client_plugin_ ## X \
_mysql_client_plugin_declaration_ = { \
MYSQL_CLIENT_ ## X ## _PLUGIN, \
MYSQL_CLIENT_ ## X ## _PLUGIN_INTERFACE_VERSION,
#define mysql_end_client_plugin }
#define mysql_end_client_plugin }; C_MODE_END
/* generic plugin header structure */
#define MYSQL_CLIENT_PLUGIN_HEADER \

View File

@ -1354,7 +1354,7 @@ unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
{
uchar *pos;
/* fields count may be wrong */
if (field - result >= fields)
if (field - result >= (my_ptrdiff_t)fields)
goto err;
cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7);
@ -1401,7 +1401,7 @@ unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
/* old protocol, for backward compatibility */
for (row=data->data; row ; row = row->next,field++)
{
if (field - result >= fields)
if (field - result >= (my_ptrdiff_t)fields)
goto err;
cli_fetch_lengths(&lengths[0], row->data, default_value ? 6 : 5);
field->org_table= field->table= strdup_root(alloc,(char*) row->data[0]);
@ -1439,7 +1439,7 @@ unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
}
}
#endif /* DELETE_SUPPORT_OF_4_0_PROTOCOL */
if (field - result < fields)
if (field - result < (my_ptrdiff_t)fields)
goto err;
free_rows(data); /* Free old data */
DBUG_RETURN(result);

View File

@ -9593,9 +9593,9 @@ TC_LOG_BINLOG::log_and_order(THD *thd, my_xid xid, bool all,
*/
if (!xid || !need_unlog)
DBUG_RETURN(BINLOG_COOKIE_DUMMY(cache_mngr->delayed_error));
else
DBUG_RETURN(BINLOG_COOKIE_MAKE(cache_mngr->binlog_id,
cache_mngr->delayed_error));
DBUG_RETURN(BINLOG_COOKIE_MAKE(cache_mngr->binlog_id,
cache_mngr->delayed_error));
}
/*

View File

@ -528,7 +528,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
if (!table->table->part_info)
{
my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
goto err2;
thd->resume_subsequent_commits(suspended_wfc);
DBUG_RETURN(TRUE);
}
if (set_part_state(alter_info, table->table->part_info, PART_ADMIN))
{
@ -1159,7 +1160,6 @@ err:
}
close_thread_tables(thd); // Shouldn't be needed
thd->mdl_context.release_transactional_locks();
err2:
thd->resume_subsequent_commits(suspended_wfc);
DBUG_RETURN(TRUE);
}

View File

@ -231,7 +231,7 @@ bool wsrep_sst_wait ()
total_wtime += difftime(end_time, start_time);
WSREP_DEBUG("Waiting for SST to complete. current seqno: %" PRId64 " waited %f secs.", local_seqno, total_wtime);
service_manager_extend_timeout(WSREP_EXTEND_TIMEOUT_INTERVAL,
"WSREP state transfer ongoing, current seqno: %ld waited %f secs", local_seqno, total_wtime);
"WSREP state transfer ongoing, current seqno: %" PRId64 " waited %f secs", local_seqno, total_wtime);
}
}
@ -294,9 +294,8 @@ void wsrep_sst_received (wsrep_t* const wsrep,
}
else if (local_seqno > seqno)
{
WSREP_WARN("SST postion is in the past: %lld, current: %lld. "
"Can't continue.",
(long long)seqno, (long long)local_seqno);
WSREP_WARN("SST postion is in the past: %" PRId64 ", current: %" PRId64
". Can't continue.", seqno, local_seqno);
unireg_abort(1);
}
@ -1416,7 +1415,7 @@ void wsrep_SE_init_wait()
total_wtime += difftime(end_time, start_time);
WSREP_DEBUG("Waiting for SST to complete. current seqno: %" PRId64 " waited %f secs.", local_seqno, total_wtime);
service_manager_extend_timeout(WSREP_EXTEND_TIMEOUT_INTERVAL,
"WSREP state transfer ongoing, current seqno: %ld waited %f secs", local_seqno, total_wtime);
"WSREP state transfer ongoing, current seqno: %" PRId64 " waited %f secs", local_seqno, total_wtime);
}
}

View File

@ -40,6 +40,10 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT )
macro(DISABLE_WARNING W)
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-error=${W}")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-${W}" DEBUG)
endmacro()
#
# OS specific C flags, definitions and source files.
@ -47,14 +51,15 @@ add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT )
IF(UNIX)
MY_CHECK_AND_SET_COMPILER_FLAG("-Wall -Wmissing-declarations")
if(NOT WITH_WARNINGS)
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-function")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-variable")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-value")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-parentheses")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-strict-aliasing")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-misleading-indentation")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-format-truncation")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough")
DISABLE_WARNING("unused-function")
DISABLE_WARNING("unused-variable")
DISABLE_WARNING("unused-value")
DISABLE_WARNING("parentheses")
DISABLE_WARNING("strict-aliasing")
DISABLE_WARNING("misleading-indentation")
DISABLE_WARNING("format-truncation")
DISABLE_WARNING("implicit-fallthrough")
DISABLE_WARNING("type-limits")
endif(NOT WITH_WARNINGS)
add_definitions( -DUNIX -DLINUX -DUBUNTU )

View File

@ -32,6 +32,10 @@
/****************************************************************************/
#include "mycat.h"
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
bool MongoEnabled(void);
#endif // JAVA_SUPPORT || CMGO_SUPPORT
/****************************************************************************/
/* Structures used to pass info between CONNECT and ha_connect. */
/****************************************************************************/

View File

@ -102,10 +102,6 @@
extern "C" HINSTANCE s_hModule; // Saved module handle
#endif // !__WIN__
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
bool MongoEnabled(void);
#endif // JAVA_SUPPORT || CMGO_SUPPORT
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
/***********************************************************************/

View File

@ -145,10 +145,10 @@ btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
time_t now = time(0);
if (now >= last + 30) {
fprintf(stderr,
"WARNING: %s:%u waited " TIMETPF " seconds for"
"WARNING: %s:%u waited %ld seconds for"
" dict_sys lock, space: %lu"
" lock_to_close_table: %d\n",
file, line, now - start, space_id,
file, line, (long)(now - start), space_id,
lock_to_close_table);
last = now;

View File

@ -2453,9 +2453,9 @@ fil_space_crypt_close_tablespace(
if (now >= last + 30) {
ib_logf(IB_LOG_LEVEL_WARN,
"Waited " TIMETPF " seconds to drop space: %s (" ULINTPF
"Waited %ld seconds to drop space: %s (" ULINTPF
") active threads %u flushing=%d.",
now - start, space->name, space->id, cnt, flushing);
(long)(now - start), space->name, space->id, cnt, flushing);
last = now;
}
}

View File

@ -10520,7 +10520,7 @@ wsrep_append_foreign_key(
key_type,
copy);
if (rcode) {
DBUG_PRINT("wsrep", ("row key failed: %zu", rcode));
DBUG_PRINT("wsrep", ("row key failed: %lu", rcode));
WSREP_ERROR("Appending cascaded fk row key failed: %s, %lu",
(wsrep_thd_query(thd)) ?
wsrep_thd_query(thd) : "void", rcode);

View File

@ -454,7 +454,6 @@ macro ULINTPF. */
# define INT64PF "%lld"
# define UINT64PF "%llu"
# define UINT64PFx "%016llx"
# define TIMETPF "%ld"
typedef __int64 ib_int64_t;
typedef unsigned __int64 ib_uint64_t;
typedef unsigned __int32 ib_uint32_t;
@ -464,7 +463,6 @@ typedef unsigned __int32 ib_uint32_t;
# define INT64PF "%" PRId64
# define UINT64PF "%" PRIu64
# define UINT64PFx "%016" PRIx64
# define TIMETPF "%" PRIdFAST32
typedef int64_t ib_int64_t;
typedef uint64_t ib_uint64_t;
typedef uint32_t ib_uint32_t;

View File

@ -5350,7 +5350,7 @@ lock_table(
lock_mutex_enter();
DBUG_EXECUTE_IF("fatal-semaphore-timeout",
{ os_thread_sleep(3600000000); });
{ os_thread_sleep(3600000000U); });
/* We have to check if the new lock is compatible with any locks
other transactions have in the table lock queue. */

View File

@ -6183,7 +6183,7 @@ os_file_trim(
size_t len = slot->len;
size_t trim_len = slot->page_size - len;
os_offset_t off = slot->offset + len;
os_offset_t off __attribute__((unused)) = slot->offset + len;
size_t bsize = slot->file_block_size;
#ifdef UNIV_TRIM_DEBUG

View File

@ -3316,17 +3316,17 @@ fil_wait_crypt_bg_threads(
time_t now = time(0);
if (now >= last + 30) {
fprintf(stderr,
"WARNING: waited " TIMETPF " seconds "
"WARNING: waited %ld seconds "
"for ref-count on table: %s space: %u\n",
now - start, table->name, table->space);
(long)(now - start), table->name, table->space);
last = now;
}
if (now >= start + 300) {
fprintf(stderr,
"WARNING: after " TIMETPF " seconds, gave up waiting "
"WARNING: after %ld seconds, gave up waiting "
"for ref-count on table: %s space: %u\n",
now - start, table->name, table->space);
(long)(now - start), table->name, table->space);
break;
}
}

View File

@ -77,7 +77,7 @@ namespace mrn {
}
private:
static const unsigned int CLEAR_THREATHOLD_IN_SECONDS = 60 * 5;
static const int CLEAR_THREATHOLD_IN_SECONDS = 60 * 5;
mysql_mutex_t *mutex_;
LIST *pool_;

View File

@ -7027,7 +7027,7 @@ int spider_get_sts(
int sts_sync_level,
uint flag
) {
int get_type;
int get_type __attribute__ ((unused));
int error_num = 0;
DBUG_ENTER("spider_get_sts");
@ -7149,7 +7149,7 @@ int spider_get_crd(
#endif
int crd_sync_level
) {
int get_type;
int get_type __attribute__ ((unused));
int error_num = 0;
DBUG_ENTER("spider_get_crd");
@ -8379,7 +8379,7 @@ int spider_discover_table_structure(
#ifdef WITH_PARTITION_STORAGE_ENGINE
partition_info *part_info = thd->work_part_info;
#endif
uint str_len;
uint str_len __attribute__ ((unused));
char buf[MAX_FIELD_WIDTH];
spider_string str(buf, sizeof(buf), system_charset_info);
DBUG_ENTER("spider_discover_table_structure");

View File

@ -145,10 +145,10 @@ btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
time_t now = time(0);
if (now >= last + 30) {
fprintf(stderr,
"WARNING: %s:%u waited " TIMETPF " seconds for"
"WARNING: %s:%u waited %ld seconds for"
" dict_sys lock, space: %lu"
" lock_to_close_table: %d\n",
file, line, now - start, space_id,
file, line, (long)(now - start), space_id,
lock_to_close_table);
last = now;

View File

@ -2453,9 +2453,9 @@ fil_space_crypt_close_tablespace(
if (now >= last + 30) {
ib_logf(IB_LOG_LEVEL_WARN,
"Waited " TIMETPF " seconds to drop space: %s (" ULINTPF
"Waited %ld seconds to drop space: %s (" ULINTPF
") active threads %u flushing=%d.",
now - start, space->name, space->id, cnt, flushing);
(long)(now - start), space->name, space->id, cnt, flushing);
last = now;
}
}

View File

@ -11088,7 +11088,7 @@ wsrep_append_foreign_key(
key_type,
copy);
if (rcode) {
DBUG_PRINT("wsrep", ("row key failed: %zu", rcode));
DBUG_PRINT("wsrep", ("row key failed: %lu", rcode));
WSREP_ERROR("Appending cascaded fk row key failed: %s, %lu",
(wsrep_thd_query(thd)) ?
wsrep_thd_query(thd) : "void", rcode);

View File

@ -471,7 +471,6 @@ macro ULINTPF. */
# define INT64PF "%lld"
# define UINT64PF "%llu"
# define UINT64PFx "%016llx"
# define TIMETPF "%ld"
typedef __int64 ib_int64_t;
typedef unsigned __int64 ib_uint64_t;
typedef unsigned __int32 ib_uint32_t;
@ -481,7 +480,6 @@ typedef unsigned __int32 ib_uint32_t;
# define INT64PF "%" PRId64
# define UINT64PF "%" PRIu64
# define UINT64PFx "%016" PRIx64
# define TIMETPF "%" PRIdFAST32
typedef int64_t ib_int64_t;
typedef uint64_t ib_uint64_t;
typedef uint32_t ib_uint32_t;

View File

@ -5401,7 +5401,7 @@ lock_table(
lock_mutex_enter();
DBUG_EXECUTE_IF("fatal-semaphore-timeout",
{ os_thread_sleep(3600000000); });
{ os_thread_sleep(3600000000U); });
/* We have to check if the new lock is compatible with any locks
other transactions have in the table lock queue. */

View File

@ -3320,17 +3320,17 @@ fil_wait_crypt_bg_threads(
time_t now = time(0);
if (now >= last + 30) {
fprintf(stderr,
"WARNING: waited " TIMETPF " seconds "
"WARNING: waited %ld seconds "
"for ref-count on table: %s space: %u\n",
now - start, table->name, table->space);
(long)(now - start), table->name, table->space);
last = now;
}
if (now >= start + 300) {
fprintf(stderr,
"WARNING: after " TIMETPF " seconds, gave up waiting "
"WARNING: after %ld seconds, gave up waiting "
"for ref-count on table: %s space: %u\n",
now - start, table->name, table->space);
(long)(now - start), table->name, table->space);
break;
}
}

View File

@ -356,7 +356,7 @@ void mdev17133()
// random size 2nd read
res= my_b_read(&info, buf_i + total + MY_MIN(19, curr_read_size),
19 >= curr_read_size ? 0 : curr_read_size - 19);
ok(res == 0, "rest of read %lu", curr_read_size - 19);
ok(res == 0, "rest of read %zu", curr_read_size - 19);
// mark read bytes in the used part of the cache buffer
memset(info.buffer, 0, info.read_pos - info.buffer);