]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client/Client.cc: fix uninit variables
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 18 Mar 2015 10:12:51 +0000 (11:12 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 15 Apr 2015 10:24:12 +0000 (12:24 +0200)
This is caused by assert(). If assert is disabled we run into use
of uninitialized variables. Return -EINVAL in case assert() is
disabled.

Fix for:

[src/client/Client.cc:7791]: (error) Uninitialized variable: lock_state
[src/client/Client.cc:7829]: (error) Uninitialized variable: lock_type

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/client/Client.cc

index 4262cced200137b734713b97fbf5c0619cc2fe90..01d2a6008481580ae7322e79584c32d640b2165d 100644 (file)
@@ -7799,8 +7799,10 @@ int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep,
        if (!in->flock_locks)
          in->flock_locks = new ceph_lock_state_t(cct);
        lock_state = in->flock_locks;
-      } else
+      } else {
        assert(0);
+       return -EINVAL;
+      }
       _update_lock_state(fl, owner, lock_state);
 
       if (fh) {
@@ -7830,8 +7832,10 @@ int Client::_interrupt_filelock(MetaRequest *req)
     lock_type = CEPH_LOCK_FLOCK_INTR;
   else if (req->head.args.filelock_change.rule == CEPH_LOCK_FCNTL)
     lock_type = CEPH_LOCK_FCNTL_INTR;
-  else
+  else {
     assert(0);
+    return -EINVAL;
+  }
 
   MetaRequest *intr_req = new MetaRequest(CEPH_MDS_OP_SETFILELOCK);
   filepath path;