Skip to content

Commit 2d101a4

Browse files
committed
Fix compiler warnings for issue #23.
1 parent 3358036 commit 2d101a4

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

test/TestClass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ class TestClass
828828
msg.Append("time ");
829829
if (m_timed_function_calls > 0)
830830
{
831-
diff_time /= m_timed_function_calls;
831+
diff_time /= static_cast<size_t>(m_timed_function_calls);
832832
privateAppendTime(msg, diff_time, false);
833833
}
834834
else

test/TestMemoryUtility.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct TestMemoryUtility
4444
{
4545
GetCounter().Inc();
4646
SizeType const alloc_size_in_bytes = elements * sizeof(Type);
47-
Type* ptr = static_cast<Type*>(::malloc(alloc_size_in_bytes));
47+
Type* ptr = static_cast<Type*>(::malloc(static_cast<size_t>(alloc_size_in_bytes)));
4848
return ptr;
4949
}
5050

test/TestNumericUtility.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct TestNumericUtility
7474
char* str = NULL;
7575
if (max_chars > 0)
7676
{
77-
TestMemoryUtility<char>::Allocate(str, max_chars + 1);
77+
TestMemoryUtility<char, SizeType>::Allocate(str, max_chars + 1);
7878
if (str != NULL)
7979
{
8080
sprintf(str, fmt, value);

test/TestString.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class TestString
221221
if ((count > 0) && remove)
222222
{
223223
size_type chars_remaining = m_length - sub_str.m_length - start;
224-
::memmove(m_string + start, m_string + start + count, chars_remaining);
224+
::memmove(m_string + start, m_string + start + count, static_cast<size_t>(chars_remaining));
225225
*(m_string + start + chars_remaining) = '\0';
226226
m_length -= count;
227227
if (m_length == 0)
@@ -389,7 +389,7 @@ class TestString
389389
char* start = str;
390390
for (char* str_end = str + count; str < str_end; ++str)
391391
*str = ch;
392-
::memcpy(str, value, value_len);
392+
::memcpy(str, value, static_cast<size_t>(value_len));
393393
*(str + value_len) = '\0';
394394
Append(start, count + value_len);
395395
TestStringUtility::FastFree(start);

test/TestStringUtility.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ struct TestStringUtility
202202
#pragma warning(push)
203203
#pragma warning(disable : 4996)
204204
#endif
205-
return static_cast<CharType*>(::memcpy(dest, src,
206-
(UnsafeLength(src) + 1) * sizeof(CharType)));
205+
size_t copy_size = static_cast<size_t>((UnsafeLength(src) + 1) * sizeof(CharType));
206+
return static_cast<CharType*>(::memcpy(dest, src, copy_size));
207207
#ifdef _MSC_VER
208208
#pragma warning(pop)
209209
#endif
@@ -252,7 +252,7 @@ struct TestStringUtility
252252
template<typename CharType>
253253
static void Allocate(CharType*& dest, size_type dest_len)
254254
{
255-
dest = TestMemoryUtility<CharType>::Allocate(dest_len + 1);
255+
dest = TestMemoryUtility<CharType, size_type>::Allocate(dest_len + 1);
256256
}
257257

258258
template<typename CharType>
@@ -275,7 +275,7 @@ struct TestStringUtility
275275
{
276276
if ((src != NULL) && (src_len > 0))
277277
{
278-
dest = TestMemoryUtility<CharType>::UnsafeAllocateCopy(src, src_len + 1);
278+
dest = TestMemoryUtility<CharType, size_type>::UnsafeAllocateCopy(src, src_len + 1);
279279
if (dest != NULL)
280280
{
281281
dest_len = src_len;
@@ -314,7 +314,7 @@ struct TestStringUtility
314314
CharType const* src,
315315
size_type src_len)
316316
{
317-
dest = TestMemoryUtility<CharType>::UnsafeAllocateCopy(src, src_len + 1);
317+
dest = TestMemoryUtility<CharType, size_type>::UnsafeAllocateCopy(src, src_len + 1);
318318
dest_len = (dest != NULL) ? src_len : static_cast<size_type>(0);
319319
}
320320

@@ -351,7 +351,7 @@ struct TestStringUtility
351351
}
352352
else
353353
{
354-
::memcpy(dest, src, dest_len + 1);
354+
::memcpy(dest, src, static_cast<size_t>(dest_len + 1));
355355
dest_len = len;
356356
}
357357
}
@@ -387,14 +387,14 @@ struct TestStringUtility
387387
if (new_dest != NULL)
388388
{
389389
if ((str1 != NULL) && (str1_len > static_cast<size_type>(0)))
390-
::memcpy(new_dest, str1, str1_len);
390+
::memcpy(new_dest, str1, static_cast<size_t>(str1_len));
391391
else
392392
{
393393
new_len -= str1_len;
394394
str1_len = static_cast<size_type>(0);
395395
}
396396
if ((str2 != NULL) && (str2_len > static_cast<size_type>(0)))
397-
::memcpy(new_dest + str1_len, str2, str2_len);
397+
::memcpy(new_dest + str1_len, str2, static_cast<size_t>(str2_len));
398398
else
399399
new_len -= str2_len;
400400
SetNullChar(*(new_dest + new_len));

test/TestTime.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class TestTime
109109

110110
TestTime& operator /=(size_t div_by) throw()
111111
{
112-
m_nanoseconds /= div_by;
112+
m_nanoseconds /= static_cast<ocl_uint64>(div_by);
113113
return *this;
114114
}
115115

0 commit comments

Comments
 (0)