From patchwork Tue Nov 17 08:10:05 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: 7633761 Return-Path: X-Original-To: patchwork-linux-scsi@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 BFA829F65E for ; Tue, 17 Nov 2015 08:10:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0409220426 for ; Tue, 17 Nov 2015 08:10:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D8F620437 for ; Tue, 17 Nov 2015 08:10:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752399AbbKQIKO (ORCPT ); Tue, 17 Nov 2015 03:10:14 -0500 Received: from mout.web.de ([212.227.17.11]:65088 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750913AbbKQIKM (ORCPT ); Tue, 17 Nov 2015 03:10:12 -0500 Received: from [192.168.1.3] ([77.182.159.196]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MWj6V-1ZreVR0p6x-00XuTk; Tue, 17 Nov 2015 09:10:06 +0100 Subject: [PATCH] scsi_lib: Delete unnecessary checks before two function calls To: linux-scsi@vger.kernel.org, "James E. J. Bottomley" 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> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <564AE0DD.6000300@users.sourceforge.net> Date: Tue, 17 Nov 2015 09:10:05 +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:Zhcw0YLNLYfA+E3Q+f9ZL7wI1f9krBBStNBfG9N8B/YIGeBadWs OtRvXJanbOtSgKHZyH+QijBHMN2v79PaxHkcYxfS/XNNPmAv+9jJ7dhpk+bz2KCKOdj/ORD uTVTMOcwKykBTeos7VmUjmOiOlh98RS4jHru0J4UFzcu95ULAa5g+S3WsTOBRNadCp8XSG4 cx7MEkZFAfyEEwU3vXcTg== X-UI-Out-Filterresults: notjunk:1; V01:K0:7c5CheJDvBE=:VxNiRoYGf9Ks2uNpTn3Ujc AnN5satWbKo9aqjNOcqixwYqFzStgUS9K+q3HzOVD5Kd+z0gG90WS4ZNQeBZolLPyhYZ6Ck0o S1WT2FXbehzICI05uPOc4ehfnDkI9c5h7wJz/JVFCu6afYqiV94ArZVSh9+LdcvtnppxMpGJt Vmw6akjwHJjXpJl4LGuks4Rn1CNLa+kOpMsl7SU3Dnyqlgi3I6i5OnHD8yjG6+vVBdqoXRUFs d7mApFH4fKNI5jYjklbfYxbhfvMBx87F8jgy7Lz+zP0LaADNF8/orMq/7AGy8fmcJ9IUN87SZ DhPqvY6m/Ib7ka25W59qbw8Bh/eaR10YsRzUSEG11xz3TYHtK3txmJ0bQYiYwFLpJy7tqyvBn CZ8a9fMtAT10ICw2ABjVmTCqH7rEj/4t99OD744RYxhuokWlUqsBVmjEFOVBxFkn1fXKUdHKP DArRDoRPXVRWYk8DXUoinhnWuSb/YXRss4JyWyfhMnSuiyY6NFulJTjZFtR/5h6qU2NjBpwgp PjdVDxODRIhSDcvN2rY/hs+5cH4kJUMOMxgNCbLqI/Qm78f/U3ktb6SohKaSfFxnzNf+QVGFW 761SMOkxsOKVEGVaQQD4nQXY7hUWDkcxxLazOfKIFjbMfcjyU2MtqbY5WAaJjwrynOjIjP0S1 9wafbd1eTE8iSNo5foTCX8WDCUws33LKsfn750a0VZRqPNjChzqeixiOWpvvDcCSe4Ysgf/sx p0t6mbzcKU9bpltO7Mp2ps75N/hasa55hiU5QAxrKZKtrKYz/RL/L6IllOxFI66PO1lgZCXpV elojVxd Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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=ham 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: Tue, 17 Nov 2015 09:00:31 +0100 The functions kmem_cache_destroy() and mempool_destroy() test whether their argument is NULL and then return immediately. Thus the tests around their calls are not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/scsi/scsi_lib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index dd8ad2a..13973a3 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2298,10 +2298,8 @@ int __init scsi_init_queue(void) cleanup_sdb: for (i = 0; i < SG_MEMPOOL_NR; i++) { struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; - if (sgp->pool) - mempool_destroy(sgp->pool); - if (sgp->slab) - kmem_cache_destroy(sgp->slab); + mempool_destroy(sgp->pool); + kmem_cache_destroy(sgp->slab); } kmem_cache_destroy(scsi_sdb_cache);