Commit a5cb8880 authored by Markus Elfring's avatar Markus Elfring Committed by Greg Kroah-Hartman
Browse files

staging: lustre: Deletion of unnecessary checks before three function calls

The following functions test whether their argument is NULL and then
return immediately.
* kfree
* ll_file_data_put
* ptlrpc_connection_put

Thus the test around such calls is not needed.

This issue was detected by using the Coccinelle software.

See also a previous update suggestion:
"remove unneeded null test before free" by Julia Lawall
https://lkml.org/lkml/2015/5/1/498
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg878600.html



Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5f37ac93
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -702,7 +702,6 @@ int ll_file_open(struct inode *inode, struct file *file)
out_openerr:
		if (opendir_set != 0)
			ll_stop_statahead(inode, lli->lli_opendir_key);
		if (fd != NULL)
		ll_file_data_put(fd);
	} else {
		ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN, 1);
+1 −1
Original line number Diff line number Diff line
@@ -1114,7 +1114,7 @@ void ll_clear_inode(struct inode *inode)
	if (lli->lli_mds_read_och)
		ll_md_real_close(inode, FMODE_READ);

	if (S_ISLNK(inode->i_mode) && lli->lli_symlink_name) {
	if (S_ISLNK(inode->i_mode)) {
		kfree(lli->lli_symlink_name);
		lli->lli_symlink_name = NULL;
	}
+2 −4
Original line number Diff line number Diff line
@@ -555,13 +555,11 @@ static int import_select_connection(struct obd_import *imp)
	imp_conn->oic_last_attempt = cfs_time_current_64();

	/* switch connection, don't mind if it's same as the current one */
	if (imp->imp_connection)
	ptlrpc_connection_put(imp->imp_connection);
	imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);

	dlmexp = class_conn2export(&imp->imp_dlm_handle);
	LASSERT(dlmexp != NULL);
	if (dlmexp->exp_connection)
	ptlrpc_connection_put(dlmexp->exp_connection);
	dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
	class_export_put(dlmexp);
+1 −3
Original line number Diff line number Diff line
@@ -2826,10 +2826,8 @@ void ptlrpc_hr_fini(void)
	ptlrpc_stop_hr_threads();

	cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
		if (hrp->hrp_thrs != NULL) {
		kfree(hrp->hrp_thrs);
	}
	}

	cfs_percpt_free(ptlrpc_hr.hr_partitions);
	ptlrpc_hr.hr_partitions = NULL;