]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Add asserts for coverity bugs
authorSam Lang <sam.lang@inktank.com>
Wed, 26 Sep 2012 02:03:49 +0000 (19:03 -0700)
committerSage Weil <sage@inktank.com>
Wed, 26 Sep 2012 23:44:47 +0000 (16:44 -0700)
Coverity 716907-716909 [FORWARD_NULL} doesn't like using a pointer
that might be null.  Assertions check that pointers are valid
before dereferencing.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/client/Client.cc

index 80cbee8a05fad6c107893d989564a1b8bbae4988..7f4def01b4a937ba5553ddf2c8f4cb9a187af792 100644 (file)
@@ -772,8 +772,10 @@ Inode* Client::insert_trace(MetaRequest *request, int mds)
   p = reply->get_extra_bl().begin();
   if (!p.end()) {
     // snapdir?
-    if (request->head.op == CEPH_MDS_OP_LSSNAP)
+    if (request->head.op == CEPH_MDS_OP_LSSNAP) {
+      assert(in);
       in = open_snapdir(in);
+    }
 
     // only open dir if we're actually adding stuff to it!
     Dir *dir = in->open_dir();
@@ -1264,6 +1266,7 @@ void Client::handle_client_session(MClientSession *m)
     break;
 
   case CEPH_SESSION_STALE:
+    assert(mds_session);
     mds_session->was_stale = true;
     renew_caps(from);
     break;
@@ -4289,6 +4292,9 @@ void Client::_readdir_drop_dirp_buffer(dir_result_t *dirp)
 
 int Client::_readdir_get_frag(dir_result_t *dirp)
 {
+  assert(dirp);
+  assert(dirp->inode);
+
   // get the current frag.
   frag_t fg = dirp->frag();