1
0
Fork 0

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: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
hifive-unleashed-5.1
Markus Elfring 2015-07-14 09:35:42 +02:00 committed by Greg Kroah-Hartman
parent 5f37ac9343
commit a5cb88804d
4 changed files with 5 additions and 10 deletions

View File

@ -702,8 +702,7 @@ out_och_free:
out_openerr:
if (opendir_set != 0)
ll_stop_statahead(inode, lli->lli_opendir_key);
if (fd != NULL)
ll_file_data_put(fd);
ll_file_data_put(fd);
} else {
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN, 1);
}

View File

@ -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;
}

View File

@ -555,14 +555,12 @@ 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);
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);
ptlrpc_connection_put(dlmexp->exp_connection);
dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
class_export_put(dlmexp);

View File

@ -2826,9 +2826,7 @@ 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);
}
kfree(hrp->hrp_thrs);
}
cfs_percpt_free(ptlrpc_hr.hr_partitions);