Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: import/cross/memory_stream_test.cc

Issue 194061: This fixes some warnings in the Linux release build. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/cross/math_utilities.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: import/cross/memory_stream_test.cc
===================================================================
--- import/cross/memory_stream_test.cc (revision 25801)
+++ import/cross/memory_stream_test.cc (working copy)
@@ -239,16 +239,19 @@
uint8 *p8 = reinterpret_cast<uint8*>(p);
MemoryWriteStream write_stream(p8, sizeof(int32) * 2);
- float value = 3.14159f;
- write_stream.WriteLittleEndianFloat32(value);
- write_stream.WriteBigEndianFloat32(value);
+ union {
+ int32 ivalue;
+ float fvalue;
+ } value;
+ value.fvalue = 3.14159f;
+ write_stream.WriteLittleEndianFloat32(value.fvalue);
+ write_stream.WriteBigEndianFloat32(value.fvalue);
// Verify that the bytes are in the correct order
- int32 ivalue = *reinterpret_cast<int32*>(&value); // interpret float as int32
- uint8 byte1 = ivalue & 0xff;
- uint8 byte2 = (ivalue >> 8) & 0xff;
- uint8 byte3 = (ivalue >> 16) & 0xff;
- uint8 byte4 = (ivalue >> 24) & 0xff;
+ uint8 byte1 = value.ivalue & 0xff;
+ uint8 byte2 = (value.ivalue >> 8) & 0xff;
+ uint8 byte3 = (value.ivalue >> 16) & 0xff;
+ uint8 byte4 = (value.ivalue >> 24) & 0xff;
// validate little-endian
EXPECT_EQ(byte1, p8[0]);
« no previous file with comments | « core/cross/math_utilities.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698