Skip to content

Commit

Permalink
Fixed compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
marcizhu committed Mar 2, 2019
1 parent 0ffdb19 commit 40864ca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 0 additions & 2 deletions Cereal/Cereal/src/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ namespace Cereal {
{
data = new byte[count * sizeOf(dataType)];
buffer.copyTo(data, count * sizeOf(dataType));
buffer.addOffset(count * sizeOf(dataType));
}
else
{
Expand All @@ -150,7 +149,6 @@ namespace Cereal {

data = new byte[size];
buffer.copyTo(data, size);
buffer.addOffset(size);
}
}

Expand Down
12 changes: 8 additions & 4 deletions Cereal/Cereal/src/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,16 @@ namespace Cereal {
template<>
bool writeBytes<float>(float data)
{
unsigned int x = *(unsigned int*)&data;
unsigned int x;
*(unsigned int*)&x = *(unsigned int*)&data;
return writeBytes<unsigned int>(x);
}

template<>
bool writeBytes<double>(double data)
{
unsigned long long x = *(unsigned long long*)&data;
unsigned long long x;
*(unsigned long long*)&x = *(unsigned long long*)&data;
return writeBytes<unsigned long long>(x);
}
#endif
Expand Down Expand Up @@ -326,14 +328,16 @@ namespace Cereal {
template<>
inline bool Buffer::writeBytes<float>(float data)
{
unsigned int x = *(unsigned int*)&data;
unsigned int x;
*(unsigned int*)&x = *(unsigned int*)&data;
return writeBytes<unsigned int>(x);
}

template<>
inline bool Buffer::writeBytes<double>(double data)
{
unsigned long long x = *(unsigned long long*)&data;
unsigned long long x;
*(unsigned long long*)&x = *(unsigned long long*)&data;
return writeBytes<unsigned long long>(x);
}
#endif
Expand Down
2 changes: 0 additions & 2 deletions Cereal/Cereal/src/Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ namespace Cereal {
}

float result;

memcpy(&result, &value, sizeof(float));

return result;
Expand Down Expand Up @@ -104,7 +103,6 @@ namespace Cereal {
}

float result;

memcpy(&result, &value, sizeof(float));

return result;
Expand Down
12 changes: 8 additions & 4 deletions Cereal/Cereal/src/Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ namespace Cereal {
template<>
static unsigned int writeBytes<float>(byte* dest, unsigned int pointer, float data)
{
unsigned int x = *(unsigned int*)&data;
unsigned int x;
*(unsigned int*)&x = *(unsigned int*)&data;
return writeBytes<unsigned int>(dest, pointer, x);
}

template<>
static unsigned int writeBytes<double>(byte* dest, unsigned int pointer, double data)
{
unsigned long long x = *(unsigned long long*)&data;
unsigned long long x;
*(unsigned long long*)&x = *(unsigned long long*)&data;
return writeBytes<unsigned long long>(dest, pointer, x);
}
#endif
Expand All @@ -91,14 +93,16 @@ namespace Cereal {
template<>
inline unsigned int Writer::writeBytes<float>(byte* dest, unsigned int pointer, float data)
{
unsigned int x = *(unsigned int*)&data;
unsigned int x;
*(unsigned int*)&x = *(unsigned int*)&data;
return writeBytes<unsigned int>(dest, pointer, x);
}

template<>
inline unsigned int Writer::writeBytes<double>(byte* dest, unsigned int pointer, double data)
{
unsigned long long x = *(unsigned long long*)&data;
unsigned long long x;
*(unsigned long long*)&x = *(unsigned long long*)&data;
return writeBytes<unsigned long long>(dest, pointer, x);
}
#endif
Expand Down

0 comments on commit 40864ca

Please sign in to comment.