From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752804AbbFZVXv (ORCPT ); Fri, 26 Jun 2015 17:23:51 -0400 Received: from mout.web.de ([212.227.17.12]:65509 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752434AbbFZVXp (ORCPT ); Fri, 26 Jun 2015 17:23:45 -0400 Message-ID: <558DC2D1.7030408@users.sourceforge.net> Date: Fri, 26 Jun 2015 23:23:29 +0200 From: SF Markus Elfring User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Andreas Dilger , Greg Kroah-Hartman , Oleg Drokin , HPDD-discuss@ml01.01.org, devel@driverdev.osuosl.org CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: [PATCH] staging: lustre: Deletion of unnecessary checks before three function calls References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> In-Reply-To: <5317A59D.4@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:cjBhefpIuqPBZqbzeS0IDsA2Mx5R0JLrObKJN9fzLqM/fe6vjVx EA/Mnu+oafn77IOFB6nZQ/bxofJv0QRSnpeZ9moSkaVc62Y5tug3LHyQlJT+wUYbmMVrgHC dUqjtQPlyOfB03Je4rbuyRpLnIPmSPCzNCR0WhjU3MwfUrHlhjzu75VYCnYf54XnQwcMIq5 M1qMCli+Mr6H0CHaB33IA== X-UI-Out-Filterresults: notjunk:1;V01:K0:MM4B8gUqvn8=:mGSzMPseLsOcyBoFaz1IuM AFEZEHzGFJlBGMl8ZvoxpvamKqDHZANzMxMdd4D/QTQpSFpNgd4XPdjMdgWS53wu9lMJ2xfbr eGP3bcEtbVCVo3h4V01DxpwoYHlDxxpXazL6/72h2GXHSB/APniwCvAPAe4b6snM/bGuwAWvh fdzx28Rx5ItWX3U81qMbWt5/3W7Zgpiq2s1DpFIqw622I+YOkewKViRHqE2aEnL5LoWeuyWH+ ocNsnSAkE48YlDoYggonz9CzqKblBq9CojgNbNvoNjBcZHBcd3S+Q/ohKCwkFhxxmczm4106I I+MCBV7jxuTo+kPdvQsRglJwFS5eL7gGiIFB5M0cUX6lR1xHu+gStUT/RafY3dCO9g6uWXA4i QfioCVOXiFloMIt7Ei7jez4egmApeQb7NekpGucbM1ljDLdVc7oxeIJgWnXX76oMjh4p/IwCr NNDTIhVVnOdwl0uzt6S9dbz7EfKEFdk9V/7zbLNSxP+0BUDVe7Pi5cwIvLmFJkopuvCSPZOfY lzhdxo4IFjL0E9LhNX2bsDVqd8zb/9f2kZqdrP4br96VWAKEFw13CdhUleBVOjtBqohXE4XyZ o5ETGEUuAICwUtsSVy5hyHaQRHp8+aVaiqF0IgSLSllcEo3x+QSI3ka2GGEkTON1E5wY8j3sW doRncV+Dbuh0f4XHvlv+ItNUIC8o4tvyGtVae1ur0zjF7MVd8S+QlWqm4FVWQvVLUMHk= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Fri, 26 Jun 2015 23:10:42 +0200 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 --- drivers/staging/lustre/lustre/llite/file.c | 3 +-- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 6 ++---- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 +--- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 3075db2..1a85c41 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -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); } diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 2513988..ab4839c 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -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; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index c9b8481..1eae389 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -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); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 9117f1c..b9ae0b7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -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); -- 2.4.4