From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753122AbbEATsS (ORCPT ); Fri, 1 May 2015 15:48:18 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:54341 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752369AbbEATqv (ORCPT ); Fri, 1 May 2015 15:46:51 -0400 X-IronPort-AV: E=Sophos;i="5.13,351,1427752800"; d="scan'208";a="138560674" From: Julia Lawall To: Oleg Drokin Cc: kernel-janitors@vger.kernel.org, Andreas Dilger , Greg Kroah-Hartman , HPDD-discuss@ml01.01.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/20] Staging: lustre: llite: dir: remove unneeded null test before free Date: Fri, 1 May 2015 21:38:02 +0200 Message-Id: <1430509086-22132-17-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1430509086-22132-1-git-send-email-Julia.Lawall@lip6.fr> References: <1430509086-22132-1-git-send-email-Julia.Lawall@lip6.fr> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // This patch additionally simplifies one case where the free, and thus the jump to the end of the function, is not needed. Signed-off-by: Julia Lawall --- drivers/staging/lustre/lustre/llite/dir.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index f17154a..4b0de8d 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -754,10 +754,8 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, char *buf; param = kzalloc(MGS_PARAM_MAXLEN, GFP_NOFS); - if (!param) { - rc = -ENOMEM; - goto end; - } + if (!param) + return -ENOMEM; buf = param; /* Get fsname and assume devname to be -MDT0000. */ @@ -786,8 +784,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param); end: - if (param != NULL) - kfree(param); + kfree(param); } return rc; }