From patchwork Sun Nov 15 21:08:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 7620051 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C03D09F1D3 for ; Sun, 15 Nov 2015 21:09:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D20D520569 for ; Sun, 15 Nov 2015 21:09:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3D662056C for ; Sun, 15 Nov 2015 21:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751473AbbKOVIx (ORCPT ); Sun, 15 Nov 2015 16:08:53 -0500 Received: from mout.web.de ([212.227.17.12]:50131 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751109AbbKOVIw (ORCPT ); Sun, 15 Nov 2015 16:08:52 -0500 Received: from [192.168.1.3] ([77.182.168.43]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MK24P-1ZzRaA2FvB-001QBy; Sun, 15 Nov 2015 22:08:35 +0100 Subject: [PATCH] staging-EHCA: Delete unnecessary checks before the function call "kmem_cache_destroy" 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> To: Doug Ledford , Greg Kroah-Hartman , Hal Rosenstock , Sean Hefty , linux-rdma@vger.kernel.org, devel@driverdev.osuosl.org Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <5648F450.3050004@users.sourceforge.net> Date: Sun, 15 Nov 2015 22:08:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <5317A59D.4@users.sourceforge.net> X-Provags-ID: V03:K0:NivdkLJA7QzZwwg3g6JYINnFFJEA1N/ADQAl/Ry+zkiFzGYBnGN WJa3OAb7LnW5SKitHuQWgcCduCpzhExRDh8c9fa/H26zm+XDzS0LpDp8YaPxaXBqMQ65ZLN HeeR8mZotfo577oO2UxDRZPy0+Gsi/oJpdgmIM8PFZx5bfoWJ8tYQOd2NZm3NqKPnX9CspL GncIL3F6+qNPzg98yyatA== X-UI-Out-Filterresults: notjunk:1; V01:K0:XW6mrMTc8aA=:JFStX3lixBorhDaqPDtAOz Z2ZbmyfyqGqZ8P9b9c2Md7GYQbCuoJbhfnuqHXfz0fnxEFbrHp8rOl2qS6Qq6U+aAj/1GCWtx Udw3h9lvSy60sVeSeHbe6ChbwggG8JgLqelJ+iJhqbZFGoBfVTt+ZkTrN3rjZVzC5r6JRt8r2 idBqLU9sdiRZGWUllQAjCRQtkA9TtkFZLv142YQ3fCLKUJ0HCDjTR1lfWNk1wkGdZSarnur1r MXH0klXN6DBCFw9rVzXWdUhVy8z7oB5PC1ir+T2bnIrip3V4SrNPPnYcaBlrPd2lBg4SYbCmT RjvRvvxodXDft33NytW8x/n7IfmrWzDsPYEa/lUQf313t2VAL/8wUUBauaE1UWnDvUn2AH6qp K7EwN5YxsLEw+RLQYA/gYAueXcKIcyRkUz5pCra6JeiNeP8o4INGYCmCUHK7d3Ld/dOtDnKyO uX+721I6qWas3+K9Yybv5OeWTEYQnUMAq3fQu1wpEe7WbsxM+fHSeAH/bmNk9BWcsiv8ugSTc i+p7qkcID8dyspmBh4xIkiKDRzkS3J0pI0NJ8HSclRFghzIL+/dQ45u49f7DmBYiQWpAIyBff V7nFqlUPHOduwsCO7i7+KdX8qowORwoOzkfxPf+tDpF45YuoFg+49z9KNZh3L2mIDrvErzYA3 iyGRoJ039LRcs19svXbQ4HegtPSkCcr/Z2BJ192dnOpYVEeJtGnbDMD6wCaQfHPE8ZU1wZYZU T+tSpJRQmCORS3rHeLKM2vRSnVBvuvL0OEP9CRwh3d9nXgen4JWUNSZ2xjaM4NpCiPdgqPQch Amk/Bcr Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 15 Nov 2015 21:58:45 +0100 The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/staging/rdma/ehca/ehca_av.c | 3 +-- drivers/staging/rdma/ehca/ehca_cq.c | 3 +-- drivers/staging/rdma/ehca/ehca_main.c | 3 +-- drivers/staging/rdma/ehca/ehca_mrmw.c | 6 ++---- drivers/staging/rdma/ehca/ehca_pd.c | 3 +-- drivers/staging/rdma/ehca/ehca_qp.c | 3 +-- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rdma/ehca/ehca_av.c b/drivers/staging/rdma/ehca/ehca_av.c index 4659263..04b9398 100644 --- a/drivers/staging/rdma/ehca/ehca_av.c +++ b/drivers/staging/rdma/ehca/ehca_av.c @@ -272,6 +272,5 @@ int ehca_init_av_cache(void) void ehca_cleanup_av_cache(void) { - if (av_cache) - kmem_cache_destroy(av_cache); + kmem_cache_destroy(av_cache); } diff --git a/drivers/staging/rdma/ehca/ehca_cq.c b/drivers/staging/rdma/ehca/ehca_cq.c index ea1b5c1..1aa7931 100644 --- a/drivers/staging/rdma/ehca/ehca_cq.c +++ b/drivers/staging/rdma/ehca/ehca_cq.c @@ -393,6 +393,5 @@ int ehca_init_cq_cache(void) void ehca_cleanup_cq_cache(void) { - if (cq_cache) - kmem_cache_destroy(cq_cache); + kmem_cache_destroy(cq_cache); } diff --git a/drivers/staging/rdma/ehca/ehca_main.c b/drivers/staging/rdma/ehca/ehca_main.c index 8246418..860b974 100644 --- a/drivers/staging/rdma/ehca/ehca_main.c +++ b/drivers/staging/rdma/ehca/ehca_main.c @@ -245,8 +245,7 @@ static void ehca_destroy_slab_caches(void) ehca_cleanup_cq_cache(); ehca_cleanup_pd_cache(); #ifdef CONFIG_PPC_64K_PAGES - if (ctblk_cache) - kmem_cache_destroy(ctblk_cache); + kmem_cache_destroy(ctblk_cache); #endif } diff --git a/drivers/staging/rdma/ehca/ehca_mrmw.c b/drivers/staging/rdma/ehca/ehca_mrmw.c index f914b30..553e883 100644 --- a/drivers/staging/rdma/ehca/ehca_mrmw.c +++ b/drivers/staging/rdma/ehca/ehca_mrmw.c @@ -2251,10 +2251,8 @@ int ehca_init_mrmw_cache(void) void ehca_cleanup_mrmw_cache(void) { - if (mr_cache) - kmem_cache_destroy(mr_cache); - if (mw_cache) - kmem_cache_destroy(mw_cache); + kmem_cache_destroy(mr_cache); + kmem_cache_destroy(mw_cache); } static inline int ehca_init_top_bmap(struct ehca_top_bmap *ehca_top_bmap, diff --git a/drivers/staging/rdma/ehca/ehca_pd.c b/drivers/staging/rdma/ehca/ehca_pd.c index 351577a..2a8aae4 100644 --- a/drivers/staging/rdma/ehca/ehca_pd.c +++ b/drivers/staging/rdma/ehca/ehca_pd.c @@ -119,6 +119,5 @@ int ehca_init_pd_cache(void) void ehca_cleanup_pd_cache(void) { - if (pd_cache) - kmem_cache_destroy(pd_cache); + kmem_cache_destroy(pd_cache); } diff --git a/drivers/staging/rdma/ehca/ehca_qp.c b/drivers/staging/rdma/ehca/ehca_qp.c index 2e89356..896c01f 100644 --- a/drivers/staging/rdma/ehca/ehca_qp.c +++ b/drivers/staging/rdma/ehca/ehca_qp.c @@ -2252,6 +2252,5 @@ int ehca_init_qp_cache(void) void ehca_cleanup_qp_cache(void) { - if (qp_cache) - kmem_cache_destroy(qp_cache); + kmem_cache_destroy(qp_cache); }