]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libc++: fix null pointer comparison 1064/head
authorNoah Watkins <noahwatkins@gmail.com>
Fri, 20 Dec 2013 15:56:58 +0000 (09:56 -0600)
committerNoah Watkins <noahwatkins@gmail.com>
Sat, 18 Jan 2014 22:03:58 +0000 (14:03 -0800)
This error is thrown when comparing a shared_ptr to NULL. To resolve
this we just use shared_ptr::operator bool that checks if the stored
pointer is null.

In C++11 the shared_ptr can be compared to nullptr, but as of yet I have
not come up with a good compatibility fix.

Details:

os/MemStore.cc:259:30: error: use of overloaded operator '!=' is ambiguous (with operand types 'ObjectRef' (aka 'shared_ptr<MemStore::Object>') and 'long')
  return (c->get_object(oid) != __null);
          ~~~~~~~~~~~~~~~~~~ ^  ~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:4787:1: note: candidate function [with _Tp = MemStore::Object]
operator!=(const shared_ptr<_Tp>& __x, nullptr_t) throw()
^
os/MemStore.cc:259:30: note: built-in candidate operator!=(int, long)
  return (c->get_object(oid) != __null);
                             ^
os/MemStore.cc:259:30: note: built-in candidate operator!=(unsigned __int128, long)
os/MemStore.cc:259:30: note: built-in candidate operator!=(unsigned long long, long)
    .....
1 error generated.
make[3]: *** [os/MemStore.lo] Error 1

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
src/os/MemStore.cc

index 4bcd93f406a9b5e8c145f9812df5638ba008885c..fd6a7d5a90c20107b31e72f31402ec7ca933902b 100644 (file)
@@ -256,7 +256,9 @@ bool MemStore::exists(coll_t cid, const ghobject_t& oid)
     return false;
   RWLock::RLocker l(c->lock);
 
-  return (c->get_object(oid) != NULL);
+  // Perform equivalent of c->get_object_(oid) != NULL. In C++11 the
+  // shared_ptr needs to be compared to nullptr.
+  return (bool)c->get_object(oid);
 }
 
 int MemStore::stat(