Fix DCHECKs in IOBufQueue
authorStepan Palamarchuk <stepan@fb.com>
Thu, 7 Dec 2017 15:43:57 +0000 (07:43 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 7 Dec 2017 15:51:22 +0000 (07:51 -0800)
Summary: glog actually tries to pull srtings from these pointers when the checks fail, which obfuscates the error

Reviewed By: yfeldblum

Differential Revision: D6506886

fbshipit-source-id: 0283e02aecaa248b84fca1433d3f29f92c37b2e6

folly/io/IOBufQueue.h

index 5c627bc9f41e72f4bf3f4e51408dd096d4d67ae7..97a690eed17e985ba5be03ef6a3684dbbdbe9e12 100644 (file)
@@ -236,7 +236,8 @@ class IOBufQueue {
 
     void dcheckIntegrity() {
       // Tail start should always be less than tail end.
-      DCHECK_LE(data_.cachedRange.first, data_.cachedRange.second);
+      DCHECK_LE(
+          (void*)data_.cachedRange.first, (void*)data_.cachedRange.second);
       DCHECK(
           data_.cachedRange.first != nullptr ||
           data_.cachedRange.second == nullptr);
@@ -376,7 +377,9 @@ class IOBufQueue {
    */
   void postallocate(uint64_t n) {
     dcheckCacheIntegrity();
-    DCHECK_LE(cachePtr_->cachedRange.first + n, cachePtr_->cachedRange.second);
+    DCHECK_LE(
+        (void*)(cachePtr_->cachedRange.first + n),
+        (void*)cachePtr_->cachedRange.second);
     cachePtr_->cachedRange.first += n;
   }
 
@@ -553,8 +556,10 @@ class IOBufQueue {
 
   void dcheckCacheIntegrity() const {
     // Tail start should always be less than tail end.
-    DCHECK_LE(tailStart_, cachePtr_->cachedRange.first);
-    DCHECK_LE(cachePtr_->cachedRange.first, cachePtr_->cachedRange.second);
+    DCHECK_LE((void*)tailStart_, (void*)cachePtr_->cachedRange.first);
+    DCHECK_LE(
+        (void*)cachePtr_->cachedRange.first,
+        (void*)cachePtr_->cachedRange.second);
     DCHECK(
         cachePtr_->cachedRange.first != nullptr ||
         cachePtr_->cachedRange.second == nullptr);
@@ -606,7 +611,8 @@ class IOBufQueue {
     if (tailStart_ != cachePtr_->cachedRange.first) {
       auto buf = head_->prev();
       DCHECK_EQ(
-          buf->writableTail() + buf->tailroom(), cachePtr_->cachedRange.second);
+          (void*)(buf->writableTail() + buf->tailroom()),
+          (void*)cachePtr_->cachedRange.second);
       auto len = cachePtr_->cachedRange.first - tailStart_;
       buf->append(len);
       chainLength_ += len;