Skip to content

Commit

Permalink
[SC-308] MSVC Warnings (2) (CUBRID#158)
Browse files Browse the repository at this point in the history
* [SC-328] MSVC Warnings. remove unused labels & variables (CUBRID#116)

https://arniadb.atlassian.net/browse/SC-328

NOTE: some whitespace changes after merging from develop + indent&astyle

* remove unused labels & variables
* fix: max_process_size
* [SC-329] MSVC Warnings. signed/unsigned mismatch (CUBRID#117)
https://arniadb.atlassian.net/browse/SC-329
* remove warning C4018: '<': signed/unsigned mismatch
* style: spaces between function name and arg list
* [SC-330] MSVC Warning. size_t to [const] [unsigned] int (CUBRID#118)
https://arniadb.atlassian.net/browse/SC-330
* remove warning: size_t to [const] [unsigned] int
* style: space between function name & arg list
* [SC-331] MSVC Warnings. SOCKET to int (CUBRID#119)
https://arniadb.atlassian.net/browse/SC-331
fix build warning: SOCKET to int
* remove unused labels & variables
* remove warning C4018: '<': signed/unsigned mismatch
* remove warning: size_t to [const] [unsigned] int
* remove warning: SOCKET to int
* remove external file (.vscode/settings.json) commited by mistake
* use STATIC_CAST instead static_cast<> in .c files
* [SC-332] MSVC Warning. _Rep to int (CUBRID#120)
https://arniadb.atlassian.net/browse/SC-332
fix build warning: cast _Rep to int
* remove unused labels & variables
* remove warning C4018: '<': signed/unsigned mismatch
* remove warning: size_t to [const] [unsigned] int
* remove warning: SOCKET to int
* fix warning: cast _Rep to int
* remove external file (.vscode/settings.json) commited by mistake
* use STATIC_CAST instead static_cast in .c files
* [SC-333] MSVC Warnings. unsafe mix of types (CUBRID#121)
https://arniadb.atlassian.net/browse/SC-333
fix warning C4805: '!=': unsafe mix of type 'char' and type 'bool' in operation
* use STATIC_CAST instead static_cast in .c files
* [SC-334] MSVC Warnings. double to (u)int(64) (CUBRID#122)
https://arniadb.atlassian.net/browse/SC-334
fix warning C4244: '=': conversion from 'double' to 'int', possible loss of data
* use STATIC_CAST instead static_cast in .c files
* [SC-338] MSVC Warnings. int64 to int
https://arniadb.atlassian.net/browse/SC-338
fix warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
* [SC-339] MSVC Warnings. cast float to int (CUBRID#126)
https://arniadb.atlassian.net/browse/SC-339
* fix warning: float to int
* [SC-340] MSVC Warnings. cast time_t to int (CUBRID#127)
https://arniadb.atlassian.net/browse/SC-340
fix warning C4244: '=': conversion from 'time_t' to 'int', possible loss of data
* fix warning C4244: '=': conversion from 'time_t' to 'int', possible loss of data
* fix gcc err: DWORD->unsigned
* [SC-341] MSVC Warnings.  sprintf format (CUBRID#128)
https://arniadb.atlassian.net/browse/SC-341
fix warning C4477: 'sprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'CString'
* fix warning C4477: 'sprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'CString'
* use format macro PRId64 to printf std::chrono::milliseconds on both platforms
* [SC-342] MSVC Warnings. switch no case (CUBRID#129)
https://arniadb.atlassian.net/browse/SC-342
fix warning C4065: switch statement contains 'default' but no 'case' labels
* fix warning C4065: switch statement contains 'default' but no 'case' labels
* [SC-343] MSVC Warnings. getpid (CUBRID#130)
https://arniadb.atlassian.net/browse/SC-343
warning C4005: 'getpid': macro redefinition
* fix warning C4005: 'getpid': macro redefinition
* [SC-350] MSVC Warnings. remove deprecated flg -Og- CUBRID#136
https://arniadb.atlassian.net/browse/SC-350
remove deprecated compiler warning -Og-
* [SC-351] MSVC Warnings. fix warning C4309: '=': truncation of constant value (CUBRID#137)
https://arniadb.atlassian.net/browse/SC-351
warning C4309: '=': truncation of constant value
* fix warning C4309: '=': truncation of constant value
* fix Windows/Linux builds
* use IS_INVALID_SOCKET() on both platforms
* CLOSE_SOCKET()
* cleanup
* [SC-355] MSVC Warnings. streampos to int (CUBRID#141)
https://arniadb.atlassian.net/browse/SC-355
warning C4244: 'return': conversion from 'std::streamoff' to 'int', possible loss of data
* fix warning C4244: 'return': conversion from 'std::streamoff' to 'int', possible loss of data
* revert changes in cubrid_opt.h
* [SC-344] is_bind_with_size(): fix buffer overflow when len==sizeof(size) CUBRID#154
https://arniadb.atlassian.net/browse/SC-344
* [SC-336] cubreplication::master_node::new_slave|add_ctrl_chn(int->SOCKET) (CUBRID#161)
https://arniadb.atlassian.net/browse/SC-336
both new_slave() and add_ctrl_ch() receive a SOCKET parameter => makes sense to the same type without any cast
WINDOWS:
need to include WinSock2.h but this indirectly defines min() & max() macros and collide with std::numeric_limits::min&max used in heart_beat_cluster.hpp (where I included the necessary header)
solution was to add compiler definition to inhibit min&max definition (NOMINMAX)
NOMINMAX was already defined in CMakeLists.txt but as an environment variable without effect on preprocessing headers; it doesn't look like it is needed => removed it
LINUX:
SOCKET used as type alias in replication_master_node.hpp
a proper solution would be a platform independent Socket wrapper (C++, RAII, automatic casts, etc)
* cubreplication::master_node::new_slave(int->SOCKET)
* fix SOCKET on Linux?
a platform independent socket wrapper needed!
* CMakeLists.txt: remove "set(NOMINMAX 1)" because it was replaced with a proper compiler definition
* remove unnecesary changes
* remove unrelated change
* [SC-335] use size_t in or_pack_string_with_length(), or_packed_string_length() CUBRID#155
https://arniadb.atlassian.net/browse/SC-335
request to use size_t was only for or_pack_string_with_length() but I extended it also to or_packed_string_length() because the 1st one uses the output parameters from the 2nd one
  • Loading branch information
bSoloArnia committed May 4, 2020
1 parent 43908ac commit a111504
Show file tree
Hide file tree
Showing 25 changed files with 313 additions and 271 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Expand Up @@ -570,10 +570,6 @@ check_function_exists(open_memstream HAVE_OPEN_MEMSTREAM)
check_function_exists(strdup HAVE_STRDUP)
check_function_exists(strlcpy HAVE_STRLCPY)

if(WIN32)
set(NOMINMAX 1)
endif(WIN32)

include(CheckIncludeFile)
check_include_file(err.h HAVE_ERR_H)
check_include_file(getopt.h HAVE_GETOPT_H)
Expand Down Expand Up @@ -736,6 +732,7 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "AIX")
endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DWIN -DWINDOWS -D_CRT_SECURE_NO_WARNINGS /wd4274 /wd4996)
add_compile_definitions(NOMINMAX) #disable min&max definitions in Windows headers (it conflicts with std::numeric_limits::min&max)
if(TARGET_PLATFORM_BITS EQUAL 64)
string(REPLACE "/DWIN32" "/D_WIN64" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif(TARGET_PLATFORM_BITS EQUAL 64)
Expand Down
14 changes: 7 additions & 7 deletions src/base/object_representation.h
Expand Up @@ -1145,7 +1145,7 @@ extern char *or_pack_short (char *ptr, short number);
extern char *or_pack_string_with_null_padding (char *ptr, const char *stream, size_t len);
extern char *or_pack_stream (char *ptr, const char *stream, size_t len);
extern char *or_pack_string (char *ptr, const char *string);
extern char *or_pack_string_with_length (char *ptr, const char *string, int length);
extern char *or_pack_string_with_length (char *ptr, const char *string, size_t length);
extern char *or_pack_errcode (char *ptr, int error);
extern char *or_pack_oid (char *ptr, const OID * oid);
extern char *or_pack_oid_array (char *ptr, int n, const OID * oids);
Expand Down Expand Up @@ -1217,13 +1217,13 @@ extern char *or_unpack_elo (char *ptr, void **elo_ptr);
extern char *or_pack_ptr (char *ptr, UINTPTR ptrval);
extern char *or_unpack_ptr (char *ptr, UINTPTR * ptrval);

extern char *or_pack_bool_array (char *ptr, const bool * bools, int size);
extern char *or_unpack_bool_array (char *ptr, bool ** bools);
extern int or_packed_bool_array_length (const bool * bools, int size);
extern char *or_pack_bool_array (char *ptr, const bool *bools, int size);
extern char *or_unpack_bool_array (char *ptr, bool **bools);
extern int or_packed_bool_array_length (const bool *bools, int size);

/* pack/unpack support functions */
extern int or_packed_stream_length (size_t len);
extern int or_packed_string_length (const char *string, int *strlen);
extern int or_packed_string_length (const char *string, size_t *strlen);
#if defined(ENABLE_UNUSED_FUNCTION)
extern int or_align_length (int length);
#endif /* ENABLE_UNUSED_FUNCTION */
Expand Down Expand Up @@ -1387,10 +1387,10 @@ extern char *or_unpack_mvccid (char *ptr, MVCCID * mvccid);
extern char *or_pack_sha1 (char *ptr, const SHA1Hash * sha1);
extern char *or_unpack_sha1 (char *ptr, SHA1Hash * sha1);

STATIC_INLINE int or_get_string_size_byte (OR_BUF * buf, int *error) __attribute__ ((ALWAYS_INLINE));
STATIC_INLINE int or_get_string_size_byte (OR_BUF * buf, int *error) __attribute__((ALWAYS_INLINE));
/* Get the compressed and the decompressed lengths of a string stored in buffer */
STATIC_INLINE int or_get_varchar_compression_lengths (OR_BUF * buf, int *compressed_size, int *decompressed_size)
__attribute__ ((ALWAYS_INLINE));
__attribute__((ALWAYS_INLINE));

extern int or_packed_spacedb_size (const SPACEDB_ALL * all, const SPACEDB_ONEVOL * vols, const SPACEDB_FILES * files);
extern char *or_pack_spacedb (char *ptr, const SPACEDB_ALL * all, const SPACEDB_ONEVOL * vols,
Expand Down
2 changes: 1 addition & 1 deletion src/broker/broker_log_util.c
Expand Up @@ -217,7 +217,7 @@ is_bind_with_size (char *buf, int *tot_val_size, int *info_size)
if (tot_val_size)
{
size_t len = size_end - size_begin;
if (len > sizeof (size))
if (len >= sizeof (size))
{
goto error_on_val_size;
}
Expand Down
6 changes: 2 additions & 4 deletions src/communication/network_cl.c
Expand Up @@ -1912,7 +1912,6 @@ net_client_request_with_callback (int request, char *argbuf, int argsize, char *
char user_response_buffer[FILEIO_MAX_USER_RESPONSE_SIZE + 1];
char *user_response_ptr = user_response_buffer;
int pr_status = ER_FAILED;
int pr_len = 0;
bool response_needed = false;
bool retry_in = true;
int x;
Expand Down Expand Up @@ -1968,7 +1967,6 @@ net_client_request_with_callback (int request, char *argbuf, int argsize, char *
/* Display prompt, then get user's input. */
fprintf (stdout, display_string);
pr_status = ER_FAILED;
pr_len = 0;
retry_in = false;

if (prompt_id != FILEIO_PROMPT_DISPLAY_ONLY)
Expand Down Expand Up @@ -2078,7 +2076,7 @@ net_client_request_with_callback (int request, char *argbuf, int argsize, char *
* or whatever is necessary and provide indication of local errors (pr_status), as well as provide
* a string in user_response. We send back to the server an int (status) followed by a string. */
/* check for overflow, could be dangerous */
pr_len = (int) strlen (user_response_buffer);
size_t pr_len = strlen (user_response_buffer);
if (pr_len > FILEIO_MAX_USER_RESPONSE_SIZE)
{
error = ER_NET_DATA_TRUNCATED;
Expand Down Expand Up @@ -3776,7 +3774,7 @@ net_client_ping_server_with_handshake (int client_type, bool check_capabilities,
char *reply = OR_ALIGNED_BUF_START (a_reply), *reply_ptr;
int reply_size = OR_ALIGNED_BUF_SIZE (a_reply);
int eid, request_size, server_capabilities, server_bit_platform;
int strlen1, strlen2;
size_t strlen1, strlen2;
REL_COMPATIBILITY compat;

if (net_Server_host[0] == '\0' || net_Server_name[0] == '\0')
Expand Down

0 comments on commit a111504

Please sign in to comment.