Skip to content

Commit 477a1bc

Browse files
committed
Windows : fix compile warnings C4267, on 32bit first
1 parent db28f0f commit 477a1bc

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

cmake/os/Windows.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ IF(MSVC)
140140

141141
#TODO: update the code and remove the disabled warnings
142142
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4805 /wd4996 /we4700 /we4311 /we4477 /we4302 /we4090")
143-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4805 /wd4996 /wd4291 /wd4577 /we4099 /we4700 /we4311 /we4477 /we4302 /we4090 /wd4267")
144-
143+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4805 /wd4291 /wd4996 /we4099 /we4700 /we4311 /we4477 /we4302 /we4090")
144+
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
145+
# Temporarily disable size_t warnings, due to their amount
146+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
147+
ENDIF()
145148
IF(MYSQL_MAINTAINER_MODE MATCHES "ERR")
146149
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
147150
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")

sql/create_options.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ uchar *engine_option_value::frm_image(uchar *buff)
613613
{
614614
if (value.str)
615615
{
616-
*buff++= name.length;
616+
DBUG_ASSERT(name.length <= 0xff);
617+
*buff++= (uchar)name.length;
617618
memcpy(buff, name.str, name.length);
618619
buff+= name.length;
619620
int2store(buff, value.length | (quoted_value ? FRM_QUOTED_VALUE : 0));

sql/log_event.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11791,7 +11791,8 @@ int Table_map_log_event::rewrite_db(const char* new_db, size_t new_len,
1179111791
cnt += header_len;
1179211792

1179311793
// Write new db name length and new name
11794-
*ptr++ = new_len;
11794+
DBUG_ASSERT(new_len < 0xff);
11795+
*ptr++ = (char)new_len;
1179511796
memcpy(ptr, new_db, new_len + 1);
1179611797
ptr += new_len + 1;
1179711798
cnt += m_dblen + 2;

sql/sql_acl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3007,7 +3007,8 @@ ulong acl_get(const char *host, const char *ip,
30073007
(entry= (acl_entry*) malloc(sizeof(acl_entry)+key_length)))
30083008
{
30093009
entry->access=(db_access & host_access);
3010-
entry->length=key_length;
3010+
DBUG_ASSERT(key_length < 0xffff);
3011+
entry->length=(uint16)key_length;
30113012
memcpy((uchar*) entry->key,key,key_length);
30123013
acl_cache->add(entry);
30133014
}

storage/connect/odbconn.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,10 +2250,10 @@ class SQLQualifiedName
22502250
return (SQLCHAR *) (m_part[i].length ? m_part[i].str : NULL);
22512251
} // end of ptr
22522252

2253-
size_t length(uint i)
2253+
SQLSMALLINT length(uint i)
22542254
{
22552255
DBUG_ASSERT(i < max_parts);
2256-
return m_part[i].length;
2256+
return (SQLSMALLINT)m_part[i].length;
22572257
} // end of length
22582258

22592259
}; // end of class SQLQualifiedName

0 commit comments

Comments
 (0)