fix issues when compiling with clang
authorAdam Simpkins <simpkins@fb.com>
Wed, 4 Dec 2013 03:33:47 +0000 (19:33 -0800)
committerJordan DeLong <jdelong@fb.com>
Fri, 20 Dec 2013 21:04:18 +0000 (13:04 -0800)
Summary:
My previous change to re-implement IOBuf's internal storage mechanism
introduced a build failure when compiling with clang.

This fixes the new compilation error in IOBuf.cpp, as well as two
existing build failures in some of the unit tests.

Test Plan: Built the folly/io code with clang.

Reviewed By: andrewjcg@fb.com

FB internal diff: D1082086

folly/io/IOBuf.cpp
folly/io/test/IOBufTest.cpp
folly/io/test/RecordIOTest.cpp

index cf961e7315def377a2a3f7cf89a566884fb2dee2..65f7624deba5eaf5e1fc9bde3da8289e03595ff1 100644 (file)
@@ -123,7 +123,7 @@ void IOBuf::operator delete(void* ptr) {
 }
 
 void IOBuf::releaseStorage(HeapStorage* storage, uint16_t freeFlags) {
 }
 
 void IOBuf::releaseStorage(HeapStorage* storage, uint16_t freeFlags) {
-  CHECK_EQ(storage->prefix.magic, kHeapMagic);
+  CHECK_EQ(storage->prefix.magic, static_cast<uint16_t>(kHeapMagic));
 
   // Use relaxed memory order here.  If we are unlucky and happen to get
   // out-of-date data the compare_exchange_weak() call below will catch
 
   // Use relaxed memory order here.  If we are unlucky and happen to get
   // out-of-date data the compare_exchange_weak() call below will catch
index a9e2ace3fe43b1db37f6bfac24ce010b44736517..5fc86644b7a8f84a7105374074bceec6e85ff8ba 100644 (file)
@@ -749,7 +749,7 @@ TEST(IOBuf, takeOwnershipUniquePtr) {
   destructorCount = 0;
   {
     std::unique_ptr<OwnershipTestClass[], CustomDeleter>
   destructorCount = 0;
   {
     std::unique_ptr<OwnershipTestClass[], CustomDeleter>
-      p(new OwnershipTestClass[2], customDeleteArray);
+      p(new OwnershipTestClass[2], CustomDeleter(customDeleteArray));
     std::unique_ptr<IOBuf> buf(IOBuf::takeOwnership(std::move(p), 2));
     EXPECT_EQ(2 * sizeof(OwnershipTestClass), buf->length());
     EXPECT_EQ(0, destructorCount);
     std::unique_ptr<IOBuf> buf(IOBuf::takeOwnership(std::move(p), 2));
     EXPECT_EQ(2 * sizeof(OwnershipTestClass), buf->length());
     EXPECT_EQ(0, destructorCount);
index 9f4d26992161c97243ce141c84cdf3d5321123e8..4c12f8176213ee37e224e8cefe886e3b2f39d5c5 100644 (file)
@@ -37,7 +37,6 @@ namespace folly { namespace test {
 
 namespace {
 // shortcut
 
 namespace {
 // shortcut
-ByteRange br(StringPiece sp) { return ByteRange(sp); }
 StringPiece sp(ByteRange br) { return StringPiece(br); }
 
 template <class T>
 StringPiece sp(ByteRange br) { return StringPiece(br); }
 
 template <class T>