From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752971AbbGNHgE (ORCPT ); Tue, 14 Jul 2015 03:36:04 -0400 Received: from mout.web.de ([212.227.15.14]:51556 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751738AbbGNHgB (ORCPT ); Tue, 14 Jul 2015 03:36:01 -0400 Subject: [PATCH resent] staging: lustre: Deletion of unnecessary checks before three function calls To: Greg Kroah-Hartman References: <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> <558DC2D1.7030408@users.sourceforge.net> <20150714023945.GB11616@kroah.com> Cc: Andreas Dilger , Oleg Drokin , HPDD-discuss@ml01.01.org, devel@driverdev.osuosl.org, LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <55A4BBCE.9020502@users.sourceforge.net> Date: Tue, 14 Jul 2015 09:35:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <20150714023945.GB11616@kroah.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:GJbMV8LfF5pJooJHDHRt9WrHoQzWwaaIcCxqfA99uyMzAPl4l4w 8KP83cnr/OawC/AP5JptHGZd1tzjgbP2q347rX3jX4gXK6qH4IEPj1/g8rVohZDPLwdl+KR cQvw7+nGalEYXZDD1mi+YKI5eZyiX3uKzBuecyg680DeEV5xJw7bEPuc3ZX2HYGrsKOj8Le zZ2CS1ULLD00K/14Dxomg== X-UI-Out-Filterresults: notjunk:1;V01:K0:OuDyAniBK+E=:OKZ5DDryUF2VfxDhy0lwWM lZE6lFGhi8Vt4NxtQQw8GP5wJvfPRWq5E47sEXFNA+p1F4s7z88AW1zUAHACiPB8yoLfSRi1W Pi8fvPk2jrMpMzPDUrspC+ZH9GQaR7VoN+pwYLk9ZwRpsLM+iDRIiB7aaF4u9c+MLFVWUZ0ZP +9z6Dbhf0Z/OwWeMUZ7/D57noZm+l0HcbPKay6l+i+yjN+cAVRZ7eH5ay9zRFt7Pbtkf3G2IB zDDxFiSdLIt7aH+mjN1NnrQvOsfP+VMSxRdH8pXp6U97Ovsw308wnoYBPkTqB6AAQrGArdcvk 5vAsWmmv6rtyiJb/5z6WGTN11pXTGWyyQ6mSOoQR6yT73KfpFkdB81HfO1LyecLkQkCTJDrwC nEnveG3onrsrI/sBchvj0ni5NGKmkleiF91huLtEUJJAr7B0dWpJBJXCRlw20VqGRcVJDZ3Rk CVBhh+msh16+XDQnetBXMc/5zSFEeg31xLkh6pwYaMHoaNoL+9MySydisTakSzmmc338PNozb bsqNSp7re3JlD2oHvzmXz/rLyG/+r3WumuBIxqQj9l7qs0AZDCTrHScLRL3ykEAh4EJTVhAZE QH/QylMY/4wqPcfcOozfBoxFkPt74RtugG+sn18oSLQZ9bnzZhR9uTvvJr1Wsbi/oR0tFnPNw PauT5g7h69kp8IXAne3V8aqchLtg27GhK0C9SwLPdgl66n5HtymT1eMBurmEcqjHeBoQ= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring 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