From 8077b5232d2d5c090bb08de22e7b844cd39f0fce Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Wed, 18 Mar 2015 11:12:51 +0100 Subject: [PATCH] client/Client.cc: fix uninit variables 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 --- src/client/Client.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 4262cced200..01d2a600848 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; -- 2.47.3