浏览代码

ceph, rbd: delete unnecessary checks before two function calls

The functions ceph_put_snap_context() and iput() test whether their
argument is NULL and then return immediately. Thus the test around the
call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
[idryomov@redhat.com: squashed rbd.c hunk, changelog]
Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
SF Markus Elfring 11 年之前
父节点
当前提交
e96a650a81
共有 4 个文件被更改,包括 7 次插入14 次删除
  1. 1 2
      drivers/block/rbd.c
  2. 1 2
      fs/ceph/caps.c
  3. 2 4
      fs/ceph/mds_client.c
  4. 3 6
      fs/ceph/snap.c

+ 1 - 2
drivers/block/rbd.c

@@ -3405,8 +3405,7 @@ err_rq:
 	if (result)
 	if (result)
 		rbd_warn(rbd_dev, "%s %llx at %llx result %d",
 		rbd_warn(rbd_dev, "%s %llx at %llx result %d",
 			 obj_op_name(op_type), length, offset, result);
 			 obj_op_name(op_type), length, offset, result);
-	if (snapc)
-		ceph_put_snap_context(snapc);
+	ceph_put_snap_context(snapc);
 	blk_end_request_all(rq, result);
 	blk_end_request_all(rq, result);
 }
 }
 
 

+ 1 - 2
fs/ceph/caps.c

@@ -3137,8 +3137,7 @@ flush_cap_releases:
 done:
 done:
 	mutex_unlock(&session->s_mutex);
 	mutex_unlock(&session->s_mutex);
 done_unlocked:
 done_unlocked:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return;
 	return;
 
 
 bad:
 bad:

+ 2 - 4
fs/ceph/mds_client.c

@@ -524,8 +524,7 @@ void ceph_mdsc_release_request(struct kref *kref)
 	}
 	}
 	if (req->r_locked_dir)
 	if (req->r_locked_dir)
 		ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
 		ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
-	if (req->r_target_inode)
-		iput(req->r_target_inode);
+	iput(req->r_target_inode);
 	if (req->r_dentry)
 	if (req->r_dentry)
 		dput(req->r_dentry);
 		dput(req->r_dentry);
 	if (req->r_old_dentry)
 	if (req->r_old_dentry)
@@ -1066,8 +1065,7 @@ out:
 	session->s_cap_iterator = NULL;
 	session->s_cap_iterator = NULL;
 	spin_unlock(&session->s_cap_lock);
 	spin_unlock(&session->s_cap_lock);
 
 
-	if (last_inode)
-		iput(last_inode);
+	iput(last_inode);
 	if (old_cap)
 	if (old_cap)
 		ceph_put_cap(session->s_mdsc, old_cap);
 		ceph_put_cap(session->s_mdsc, old_cap);
 
 

+ 3 - 6
fs/ceph/snap.c

@@ -365,8 +365,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
 	     realm->ino, realm, snapc, snapc->seq,
 	     realm->ino, realm, snapc, snapc->seq,
 	     (unsigned int) snapc->num_snaps);
 	     (unsigned int) snapc->num_snaps);
 
 
-	if (realm->cached_context)
-		ceph_put_snap_context(realm->cached_context);
+	ceph_put_snap_context(realm->cached_context);
 	realm->cached_context = snapc;
 	realm->cached_context = snapc;
 	return 0;
 	return 0;
 
 
@@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm *realm)
 		if (!inode)
 		if (!inode)
 			continue;
 			continue;
 		spin_unlock(&realm->inodes_with_caps_lock);
 		spin_unlock(&realm->inodes_with_caps_lock);
-		if (lastinode)
-			iput(lastinode);
+		iput(lastinode);
 		lastinode = inode;
 		lastinode = inode;
 		ceph_queue_cap_snap(ci);
 		ceph_queue_cap_snap(ci);
 		spin_lock(&realm->inodes_with_caps_lock);
 		spin_lock(&realm->inodes_with_caps_lock);
 	}
 	}
 	spin_unlock(&realm->inodes_with_caps_lock);
 	spin_unlock(&realm->inodes_with_caps_lock);
-	if (lastinode)
-		iput(lastinode);
+	iput(lastinode);
 
 
 	list_for_each_entry(child, &realm->children, child_item) {
 	list_for_each_entry(child, &realm->children, child_item) {
 		dout("queue_realm_cap_snaps %p %llx queue child %p %llx\n",
 		dout("queue_realm_cap_snaps %p %llx queue child %p %llx\n",