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

Unified Diff: webrtc/modules/rtp_rtcp/source/byte_io_unittest.cc

Issue 1739753002: Fix ubsan warning in byteio_unittest (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/rtp_rtcp/source/byte_io_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/byte_io_unittest.cc b/webrtc/modules/rtp_rtcp/source/byte_io_unittest.cc
index fbc6bf8469f3c7c3d26b1988da4df4c9bae6c0ed..80a6800258c9002636cd73b1e29c2f8dfcc859f8 100644
--- a/webrtc/modules/rtp_rtcp/source/byte_io_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/byte_io_unittest.cc
@@ -31,7 +31,12 @@ class ByteIoTest : public ::testing::Test {
val = (val << 8) + (negative ? (0xFF - i) : (i + 1));
}
if (negative && std::numeric_limits<T>::is_signed) {
- val |= static_cast<T>(-1) << (8 * num_bytes);
+ T mask = static_cast<T>(-1);
+ const T neg_byte = static_cast<T>(0xFF);
+ for (int i = 0; i < num_bytes; ++i) {
+ mask &= ~(neg_byte << i);
+ }
stefan-webrtc 2016/02/26 09:30:34 Add a comment about what the mask you are construc
sprang_webrtc 2016/02/26 10:08:25 Done.
+ val |= mask;
}
return val;
}
@@ -140,26 +145,14 @@ TEST_F(ByteIoTest, Test24SBitBigEndian) {
TestWrite<int32_t, ByteWriter<int32_t, 3>::WriteBigEndian, 3>(true);
}
-// Disabled for UBSan: https://bugs.chromium.org/p/webrtc/issues/detail?id=5490
-#ifdef UNDEFINED_SANITIZER
-#define MAYBE_Test32SBitBigEndian DISABLED_Test32SBitBigEndian
-#else
-#define MAYBE_Test32SBitBigEndian Test32SBitBigEndian
-#endif
-TEST_F(ByteIoTest, MAYBE_Test32SBitBigEndian) {
+TEST_F(ByteIoTest, Test32SBitBigEndian) {
TestRead<int32_t, ByteReader<int32_t>::ReadBigEndian,
sizeof(int32_t)>(true);
TestWrite<int32_t, ByteWriter<int32_t>::WriteBigEndian,
sizeof(int32_t)>(true);
}
-// Disabled for UBSan: https://bugs.chromium.org/p/webrtc/issues/detail?id=5490
-#ifdef UNDEFINED_SANITIZER
-#define MAYBE_Test64SBitBigEndian DISABLED_Test64SBitBigEndian
-#else
-#define MAYBE_Test64SBitBigEndian Test64SBitBigEndian
-#endif
-TEST_F(ByteIoTest, MAYBE_Test64SBitBigEndian) {
+TEST_F(ByteIoTest, Test64SBitBigEndian) {
TestRead<int64_t, ByteReader<int64_t>::ReadBigEndian,
sizeof(int64_t)>(true);
TestWrite<int64_t, ByteWriter<int64_t>::WriteBigEndian,
@@ -204,26 +197,14 @@ TEST_F(ByteIoTest, Test24SBitLittleEndian) {
TestWrite<int32_t, ByteWriter<int32_t, 3>::WriteLittleEndian, 3>(false);
}
-// Disabled for UBSan: https://bugs.chromium.org/p/webrtc/issues/detail?id=5490
-#ifdef UNDEFINED_SANITIZER
-#define MAYBE_Test32SBitLittleEndian DISABLED_Test32SBitLittleEndian
-#else
-#define MAYBE_Test32SBitLittleEndian Test32SBitLittleEndian
-#endif
-TEST_F(ByteIoTest, MAYBE_Test32SBitLittleEndian) {
+TEST_F(ByteIoTest, Test32SBitLittleEndian) {
TestRead<int32_t, ByteReader<int32_t>::ReadLittleEndian,
sizeof(int32_t)>(false);
TestWrite<int32_t, ByteWriter<int32_t>::WriteLittleEndian,
sizeof(int32_t)>(false);
}
-// Disabled for UBSan: https://bugs.chromium.org/p/webrtc/issues/detail?id=5490
-#ifdef UNDEFINED_SANITIZER
-#define MAYBE_Test64SBitLittleEndian DISABLED_Test64SBitLittleEndian
-#else
-#define MAYBE_Test64SBitLittleEndian Test64SBitLittleEndian
-#endif
-TEST_F(ByteIoTest, MAYBE_Test64SBitLittleEndian) {
+TEST_F(ByteIoTest, Test64SBitLittleEndian) {
TestRead<int64_t, ByteReader<int64_t>::ReadLittleEndian,
sizeof(int64_t)>(false);
TestWrite<int64_t, ByteWriter<int64_t>::WriteLittleEndian,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698