Skip to content

Commit ce37ce0

Browse files
committed
Addendum to the fix for bug #34828882: Enable MSVC Code Analysis for C/C++
1. Extended the scope of the checks. 2. Fixed a couple of obvious warnings Change-Id: If5e5677b90ac8cb25f0ec8fa6a453180837ec927
1 parent d854b82 commit ce37ce0

File tree

22 files changed

+27
-6
lines changed

22 files changed

+27
-6
lines changed

client/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

2323
ADD_WSHADOW_WARNING()
24+
MSVC_CPPCHECK()
2425

2526
# We are not interesting in profiling clients.
2627
DISABLE_MISSING_PROFILE_WARNING()

client/mysql.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ inline int get_command_index(char cmd_char) {
12211221
All client-specific commands are in the first part of commands array
12221222
and have a function to implement it.
12231223
*/
1224-
for (uint i = 0; *commands[i].func != nullptr; i++)
1224+
for (uint i = 0; commands[i].func != nullptr; i++)
12251225
if (commands[i].cmd_char == cmd_char) return i;
12261226
return -1;
12271227
}

client/mysqlslap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ static long int timedif(struct timeval a, struct timeval b) {
311311

312312
#ifdef _WIN32
313313
static int gettimeofday(struct timeval *tp, void *) {
314-
unsigned int ticks;
315-
ticks = GetTickCount();
314+
ULONGLONG ticks;
315+
ticks = GetTickCount64();
316316
tp->tv_usec = ticks * 1000;
317317
tp->tv_sec = ticks / 1000;
318318

cmake/msvc_cppcheck.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ ENDMACRO()
147147

148148
MACRO(MSVC_CPPCHECK_ADD_ANALYZE)
149149
IF (MSVC AND MSVC_CPPCHECK)
150-
MESSAGE(STATUS "MSVC Code analysis (MSVC_CPPCHECK) turned ON")
151-
152150
STRING_APPEND(CMAKE_C_FLAGS " /analyze /analyze:external- /analyze:pluginEspXEngine.dll")
153151
STRING_APPEND(CMAKE_CXX_FLAGS " /analyze /analyze:external- /analyze:pluginEspXEngine.dll")
154152
ENDIF()

components/audit_api_message_emit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

2323
DISABLE_MISSING_PROFILE_WARNING()
24+
MSVC_CPPCHECK()
2425

2526
MYSQL_ADD_COMPONENT(audit_api_message_emit
2627
audit_api_message_emit.cc

components/example/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# along with this program; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

23+
MSVC_CPPCHECK()
2324
MYSQL_ADD_COMPONENT(example_component1
2425
english_greeting_service_imp.cc
2526
example_component1.cc

components/libminchassis/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# along with this program; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

23+
MSVC_CPPCHECK()
2324
SET(LIBMINCHASSIS_SOURCES
2425
component_common.cc
2526
dynamic_loader.cc

components/mysqlbackup/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
DISABLE_MISSING_PROFILE_WARNING()
2424

25+
MSVC_CPPCHECK()
2526
MYSQL_ADD_COMPONENT(mysqlbackup
2627
mysqlbackup.cc
2728
backup_page_tracker.cc

components/pfs_component/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

2323
DISABLE_MISSING_PROFILE_WARNING()
24+
MSVC_CPPCHECK()
2425

2526
MYSQL_ADD_COMPONENT(pfs_example_component_population
2627
pfs_example_component_population.cc

components/pfs_example/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

2323
DISABLE_MISSING_PROFILE_WARNING()
24+
MSVC_CPPCHECK()
2425

2526
MYSQL_ADD_COMPONENT(pfs_example
2627
pfs_example.cc

components/query_attributes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# along with this program; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

23+
MSVC_CPPCHECK()
2324
MYSQL_ADD_COMPONENT(query_attributes
2425
query_attributes.cc
2526
MODULE_ONLY

components/reference_cache/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# along with this program; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

23+
MSVC_CPPCHECK()
2324
MYSQL_ADD_COMPONENT(reference_cache
2425
component.cc
2526
channel.cc

components/validate_password/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# along with this program; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

23+
MSVC_CPPCHECK()
2324
MYSQL_ADD_COMPONENT(validate_password
2425
validate_password_imp.cc
2526
MODULE_ONLY

libbinlogevents/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
ADD_WSHADOW_WARNING()
2525

26+
MSVC_CPPCHECK()
27+
2628
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libbinlogevents/include)
2729

2830
CONFIGURE_FILE(binlog_config.h.cmake

libbinlogstandalone/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#
2323

2424
ADD_WSHADOW_WARNING()
25+
MSVC_CPPCHECK()
2526
DISABLE_MISSING_PROFILE_WARNING()
2627

2728
ADD_DEFINITIONS(-DSTANDALONE_BINLOG)

libchangestreams/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ OPTION(WITH_CS_PROTOBUF
2424
"Compile change streams library with protobuf based functionality" OFF)
2525

2626
ADD_WSHADOW_WARNING()
27+
MSVC_CPPCHECK()
2728
DISABLE_MISSING_PROFILE_WARNING()
2829

2930
SET(CS_BASE_SRC_DIR ${CMAKE_SOURCE_DIR}/libchangestreams/src)

libmysql/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
ADD_WSHADOW_WARNING()
2424

25+
MSVC_CPPCHECK()
26+
2527
SET(CLIENT_API_FUNCTIONS
2628
mysql_affected_rows
2729
mysql_autocommit

libservices/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ IF(WITHOUT_SERVER)
2525
RETURN()
2626
ENDIF()
2727

28+
MSVC_CPPCHECK()
2829
ADD_WSHADOW_WARNING()
2930

3031
SET(MYSQLSERVICES_SOURCES

mysys/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ SET(MY_TIME_SOURCES my_time.cc my_systime.cc)
2727
ADD_CONVENIENCE_LIBRARY(mytime ${MY_TIME_SOURCES})
2828

2929
MSVC_CPPCHECK()
30+
IF (MSVC AND MSVC_CPPCHECK)
31+
MESSAGE(STATUS "MSVC Code analysis (MSVC_CPPCHECK) turned ON")
32+
ENDIF()
3033

3134
SET(MYSYS_SOURCES
3235
array.cc

testclients/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

2323
ADD_WSHADOW_WARNING()
24+
MSVC_CPPCHECK()
2425

2526
MYSQL_ADD_EXECUTABLE(mysql_client_test mysql_client_test.cc COMPONENT Test)
2627
TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient)

testclients/mysql_client_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20518,7 +20518,7 @@ static void test_skip_metadata() {
2051820518
}
2051920519

2052020520
/* Check CLIENT_OPTIONAL_RESULTSET_METADATA flag. */
20521-
DIE_UNLESS(mysql->client_flag | CLIENT_OPTIONAL_RESULTSET_METADATA);
20521+
DIE_UNLESS(mysql1->client_flag & CLIENT_OPTIONAL_RESULTSET_METADATA);
2052220522

2052320523
/* Check MYSQL_OPT_OPTIONAL_RESULTSET_METADATA option. */
2052420524
mysql_get_option(mysql1, MYSQL_OPT_OPTIONAL_RESULTSET_METADATA,

vio/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
ADD_WSHADOW_WARNING()
2424

25+
MSVC_CPPCHECK()
26+
2527
SET(VIO_SOURCES
2628
vio.cc
2729
viosocket.cc

0 commit comments

Comments
 (0)