Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1387,9 +1387,7 @@ int main(int argc,char *argv[])
if (opt_outfile)
end_tee();
mysql_end(0);
#ifndef _lint
DBUG_RETURN(0); // Keep compiler happy
#endif
DBUG_RETURN(0);
}

sig_handler mysql_end(int sig)
Expand Down Expand Up @@ -3499,8 +3497,6 @@ static int com_go(String *buffer, char *)
old_buffer.copy();
}

/* Remove garbage for nicer messages */
LINT_INIT_STRUCT(buff[0]);
remove_cntrl(*buffer);

if (buffer->is_empty())
Expand Down
8 changes: 8 additions & 0 deletions cmake/maintainer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ IF(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS
SET(MY_ERROR_FLAGS ${MY_ERROR_FLAGS} -Wno-error=non-virtual-dtor) # gcc bug 7302
ENDIF()

FOREACH(LANG C CXX)
IF(CMAKE_${LANG}_COMPILER_ID MATCHES "Clang")
MY_CHECK_AND_SET_COMPILER_FLAG(-Werror=uninitialized-explicit-init)
MY_CHECK_AND_SET_COMPILER_FLAG(-Werror=uninitialized-const-reference)
SET(CMAKE_${LANG}_FLAGS "${CMAKE_${LANG}_FLAGS} -Werror=uninitialized")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove SET(CMAKE_${LANG}FLAGS "${CMAKE${LANG}_FLAGS} -Werror=uninitialized")
We already set -Werror, in maintainer mode. We don't need -Werror=unintialized

We should not break the compilation in non maintainer mode just for an uninitialized error like we do not break it for other warnings. We will catch the issue in buildbot if needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked with Serg and he agrees we should not break on errors outside maintainer mode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok to push after the above is fixed

ENDIF()
ENDFOREACH()

IF(MYSQL_MAINTAINER_MODE MATCHES "OFF|WARN")
RETURN()
ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO")
Expand Down
6 changes: 0 additions & 6 deletions include/m_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ extern const char _dig_vec_lower[];

extern char *strmov_overlapp(char *dest, const char *src);

#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
#define LINT_INIT_STRUCT(var) bzero(&var, sizeof(var)) /* No uninitialize-warning */
#else
#define LINT_INIT_STRUCT(var)
#endif

/* Prototypes for string functions */

extern void bmove_upp(uchar *dst,const uchar *src,size_t len);
Expand Down
4 changes: 2 additions & 2 deletions include/my_dbug.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(DBUG_OFF) && !defined(_lint)
#if !defined(DBUG_OFF)

struct _db_stack_frame_ {
const char *func; /* function name of the previous stack frame */
Expand Down Expand Up @@ -210,7 +210,7 @@ extern void (*my_dbug_assert_failed)(const char *assert_expr, const char* file,
#define DBUG_ASSERT(A) do { } while(0)
#define IF_DBUG_ASSERT(A,B) B
#endif /* DBUG_ASSERT_AS_PRINTF */
#endif /* !defined(DBUG_OFF) && !defined(_lint) */
#endif /* !defined(DBUG_OFF) */

#ifdef EXTRA_DEBUG
/**
Expand Down
25 changes: 9 additions & 16 deletions include/my_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ C_MODE_END
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
#endif

#if defined(_lint) && !defined(lint)
#define lint
#endif

#ifndef stdin
#include <stdio.h>
#endif
Expand Down Expand Up @@ -448,22 +444,19 @@ extern "C" int madvise(void *addr, size_t len, int behav);
/*
Suppress uninitialized variable warning without generating code.
*/
#if defined(__GNUC__)
/* GCC specific self-initialization which inhibits the warning. */
#if defined(__GNUC__) && !defined(WITH_UBSAN)
/*
GCC specific self-initialization which inhibits the warning.
clang and static analysis will complain loudly about this
so compile those under WITH_UBSAN.
*/
#define UNINIT_VAR(x) x= x
#elif defined(_lint) || defined(FORCE_INIT_OF_VARS)
#elif defined(FORCE_INIT_OF_VARS)
#define UNINIT_VAR(x) x= 0
#else
#define UNINIT_VAR(x) x
#endif

/* This is only to be used when resetting variables in a class constructor */
#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
#define LINT_INIT(x) x= 0
#else
#define LINT_INIT(x)
#endif

#if !defined(HAVE_UINT)
#undef HAVE_UINT
#define HAVE_UINT
Expand Down Expand Up @@ -505,7 +498,7 @@ C_MODE_END
#endif

/* We might be forced to turn debug off, if not turned off already */
#if (defined(FORCE_DBUG_OFF) || defined(_lint)) && !defined(DBUG_OFF)
#if defined(FORCE_DBUG_OFF) && !defined(DBUG_OFF)
# define DBUG_OFF
# ifdef DBUG_ON
# undef DBUG_ON
Expand All @@ -527,7 +520,7 @@ typedef int my_socket; /* File descriptor for sockets */
#endif
/* Type for functions that handles signals */
#define sig_handler RETSIGTYPE
#if defined(__GNUC__) && !defined(_lint)
#if defined(__GNUC__)
typedef char pchar; /* Mixed prototypes can take char */
typedef char puchar; /* Mixed prototypes can take char */
typedef char pbool; /* Mixed prototypes can take char */
Expand Down
12 changes: 8 additions & 4 deletions sql/item_jsonfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1728,9 +1728,16 @@ bool Item_func_json_contains_path::val_bool()
longlong result;
json_path_t p;
int n_found;
LINT_INIT(n_found);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add back or replace with UNINIT_VAR()
There should not be any GCC version specific changes in the code as this makes code harder to read.
Better to use UNINIT_VAR() here as this will stop the warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but left a comment noting the last observed compiler warning version so one day it can be removed with less back checking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has still to be fixed

int array_sizes[JSON_DEPTH_LIMIT];
uint has_negative_path= 0;
#if defined(FORCE_INIT_OF_VARS)
/*
Initialization force not required after gcc 13.3
where it correctly sees that an uninitialized read
of n_found doesn't occur with mode_one being true.
*/
n_found= 0;
#endif

if ((null_value= args[0]->null_value))
return 0;
Expand Down Expand Up @@ -1770,8 +1777,6 @@ bool Item_func_json_contains_path::val_bool()
bzero(p_found, (arg_count-2) * sizeof(bool));
n_found= arg_count - 2;
}
else
n_found= 0; /* Just to prevent 'uninitialized value' warnings */

result= 0;
while (json_get_path_next(&je, &p) == 0)
Expand Down Expand Up @@ -2644,7 +2649,6 @@ String *Item_func_json_merge::val_str(String *str)
String *js1= args[0]->val_json(&tmp_js1), *js2=NULL;
uint n_arg;
THD *thd= current_thd;
LINT_INIT(js2);

JSON_DO_PAUSE_EXECUTION(thd, 0.0002);

Expand Down
4 changes: 2 additions & 2 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7699,7 +7699,7 @@ bool THD::binlog_for_noop_dml(bool transactional_table)
}


#if defined(DBUG_TRACE) && !defined(_lint)
#if defined(DBUG_TRACE)
static const char *
show_query_type(THD::enum_binlog_query_type qtype)
{
Expand All @@ -7713,7 +7713,7 @@ show_query_type(THD::enum_binlog_query_type qtype)
DBUG_ASSERT(0 <= qtype && qtype < THD::QUERY_TYPE_COUNT);
}
static char buf[64];
sprintf(buf, "UNKNOWN#%d", qtype);
snprintf(buf, sizeof(buf), "UNKNOWN#%d", qtype);
return buf;
}
#endif
Expand Down
2 changes: 0 additions & 2 deletions sql/sql_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,7 @@ class I_List :private base_ilist
inline void move_elements_to(I_List<T>* new_owner) {
base_ilist::move_elements_to(new_owner);
}
#ifndef _lint
friend class I_List_iterator<T>;
#endif
};


Expand Down
2 changes: 0 additions & 2 deletions sql/sql_plist.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,8 @@ class I_P_List : public C, public I
typedef I_P_List<T, B, C, I> Base;
typedef I_P_List_iterator<T, Base> Iterator;
typedef I_P_List_iterator<const T, Base> Const_Iterator;
#ifndef _lint
friend class I_P_List_iterator<T, Base>;
friend class I_P_List_iterator<const T, Base>;
#endif
};


Expand Down
2 changes: 1 addition & 1 deletion storage/connect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
#
# Definitions that are shared for all OSes
#
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DMARIADB -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT )

macro(DISABLE_WARNING W)
Expand Down
5 changes: 3 additions & 2 deletions storage/connect/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ bool FILTER::Convert(PGLOBAL g, bool having)
case OP_GT:
case OP_GE:
case OP_LT:
case OP_LE: new(this) FILTERCMP(g); break;
case OP_LE: new(this) FILTERCMP(g, Opc); break;
case OP_AND: new(this) FILTERAND; break;
case OP_OR: new(this) FILTEROR; break;
case OP_NOT: new(this) FILTERNOT; break;
Expand Down Expand Up @@ -1589,8 +1589,9 @@ void FILTER::Prints(PGLOBAL g, char *ps, uint z)
/***********************************************************************/
/* FILTERCMP constructor. */
/***********************************************************************/
FILTERCMP::FILTERCMP(PGLOBAL g)
FILTERCMP::FILTERCMP(PGLOBAL g, OPVAL Opc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opc -> Opc_arg

{
this->Opc= Opc;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to Opc= Opc_arg

Bt = OpBmp(g, Opc);
} // end of FILTERCMP constructor

Expand Down
2 changes: 1 addition & 1 deletion storage/connect/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class FILTERX : public FILTER {
class FILTERCMP : public FILTERX {
public:
// Constructor
FILTERCMP(PGLOBAL g);
FILTERCMP(PGLOBAL, OPVAL);

// Methods
bool Eval(PGLOBAL) override;
Expand Down
2 changes: 2 additions & 0 deletions storage/connect/tabxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,9 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode)
if (Tdbp->Xpand)
n = Tdbp->Limit;

auto oLong = Long;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use auto.
Please also add a comment why we have to preserver 'Long' as it is not obvious here
Please also use 'save_Long' instead of 'oLong' as we do in most of the other part of the code

I suggest this patch instead that makes this a bit more clear:

+++ b/storage/connect/tabxml.cpp
@@ -1611,7 +1611,7 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode)
if (Tdbp->Xpand)
n = Tdbp->Limit;

  • new(this) XMULCOL(Value); // Change the class of this column
  • new(this) XMULCOL(Value, Long); // Change the class of this column
    } // endif Inod

Valbuf = (char*)PlugSubAlloc(g, NULL, n * (Long + 1));
diff --git a/storage/connect/tabxml.h b/storage/connect/tabxml.h
index 252d2f74d85..9248db58b9b 100644
--- a/storage/connect/tabxml.h
+++ b/storage/connect/tabxml.h
@@ -231,7 +231,7 @@ class XMULCOL : public XMLCOLX {
public:
// The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL

  • XMULCOL(PVAL valp) {Value = valp; Mul = true;}
  • XMULCOL(PVAL valp, int buffer_length) {Value = valp; Long= buffer_length ; Mul = true;}

    // Methods
    void ReadColumn(PGLOBAL g) override;

new(this) XMULCOL(Value); // Change the class of this column
Long = oLong;
} // endif Inod

Valbuf = (char*)PlugSubAlloc(g, NULL, n * (Long + 1));
Expand Down
3 changes: 0 additions & 3 deletions storage/maria/aria_chk.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ int main(int argc, char **argv)
}
maria_end();
my_exit(error);
#ifndef _lint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the return 0;
(This was an #ifndef _lint, which means the code should be there for normal builds)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a no-return my_exit function the return 0 is just dead code. Compilers and static analysers rightly complain about after that, normal build or not.

return 0; /* No compiler warning */
#endif
} /* main */

enum options_mc {
Expand Down
4 changes: 1 addition & 3 deletions storage/maria/aria_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,9 @@ int main(int argc, char **argv)
maria_end();
my_end(verbose ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
exit(error ? 2 : 0);
#ifndef _lint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the return 0;

return 0; /* No compiler warning */
#endif
}

ATTRIBUTE_NORETURN
static void my_exit(int error)
{
free_defaults(default_argv);
Expand Down
2 changes: 0 additions & 2 deletions storage/maria/ma_delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ my_bool _ma_ck_delete(MARIA_HA *info, MARIA_KEY *key)
MARIA_KEY org_key;
DBUG_ENTER("_ma_ck_delete");

LINT_INIT_STRUCT(org_key);

alloc_on_stack(*info->stack_end_ptr, key_buff, buff_alloced,
key->keyinfo->max_store_length);
if (!key_buff)
Expand Down
2 changes: 0 additions & 2 deletions storage/maria/ma_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ static my_bool _ma_ck_write_btree_with_log(MARIA_HA *info, MARIA_KEY *key,
my_bool transactional= share->now_transactional;
DBUG_ENTER("_ma_ck_write_btree_with_log");

LINT_INIT_STRUCT(org_key);

if (transactional)
{
/* Save original value as the key may change */
Expand Down
2 changes: 1 addition & 1 deletion storage/mroonga/ha_mroonga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ static int mrn_change_encoding(grn_ctx *ctx, const CHARSET_INFO *charset)
return mrn::encoding::set(ctx, charset);
}

#if defined DBUG_TRACE && !defined(_lint)
#if defined DBUG_TRACE
static const char *mrn_inspect_thr_lock_type(enum thr_lock_type lock_type)
{
const char *inspected = "<unknown>";
Expand Down
2 changes: 1 addition & 1 deletion storage/mroonga/mrn_mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

#define MRN_DBUG_ENTER_FUNCTION() DBUG_ENTER(__FUNCTION__)

#if !defined(DBUG_OFF) && !defined(_lint)
#if !defined(DBUG_OFF)
# define MRN_DBUG_ENTER_METHOD() \
char method_name[MRN_MESSAGE_BUFFER_SIZE]; \
method_name[0] = '\0'; \
Expand Down
3 changes: 0 additions & 3 deletions storage/myisam/myisamchk.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ int main(int argc, char **argv)
my_end(check_param.testflag & T_INFO ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
rc= (uchar) error;
exit(rc);
#ifndef _lint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the return 0;

return 0; /* No compiler warning */
#endif
} /* main */

enum options_mc {
Expand Down
3 changes: 0 additions & 3 deletions storage/myisam/myisampack.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@ int main(int argc, char **argv)
free_defaults(default_argv);
my_end(verbose ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
exit(error ? 2 : 0);
#ifndef _lint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the return 0;

return 0; /* No compiler warning */
#endif
}

enum options_mp {OPT_CHARSETS_DIR_MP=256};
Expand Down