staging: lustre: Deletion of unnecessary checks before three function calls
authorMarkus Elfring <elfring@users.sourceforge.net>
Tue, 14 Jul 2015 07:35:42 +0000 (09:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jul 2015 21:31:33 +0000 (14:31 -0700)
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>
drivers/staging/lustre/lustre/llite/file.c
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/ptlrpc/import.c
drivers/staging/lustre/lustre/ptlrpc/service.c

index e01a47c0b80a1233a8d2e820b5e1b937b956a728..dcd0c6d65efbcb4f475a92458b013c67a6c1d9c1 100644 (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);
        }
index 25139885b5a769eeedab0fd2859986c1c4684d19..ab4839cad93942a15310566f8f2de8cdbe357d0a 100644 (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;
        }
index c9b8481dd38462b51d580b05914fdb9078cc3869..1eae3896c0375ce6f2d7ed0c6856b000f2a487f3 100644 (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);
 
index 56a86317ded73dab19148214b923d97c3bb3497c..cf9477d4749b228d5e25f0da26a6614b135a774b 100644 (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);