From patchwork Fri Jul 22 19:21:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9244159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AEF7160459 for ; Fri, 22 Jul 2016 19:21:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F43227F54 for ; Fri, 22 Jul 2016 19:21:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91D2727FBC; Fri, 22 Jul 2016 19:21:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 416D027F54 for ; Fri, 22 Jul 2016 19:21:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752606AbcGVTVm (ORCPT ); Fri, 22 Jul 2016 15:21:42 -0400 Received: from mout.web.de ([212.227.15.3]:62509 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbcGVTVl (ORCPT ); Fri, 22 Jul 2016 15:21:41 -0400 Received: from [192.168.1.2] ([77.182.75.73]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0LqlRS-1ameE93tBa-00eLAU; Fri, 22 Jul 2016 21:21:36 +0200 Subject: [PATCH] block: Delete an unnecessary check before the function call "kmem_cache_destroy" To: linux-block@vger.kernel.org, Jens Axboe 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: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <21c3d738-2da9-884d-1703-98cba826e0f0@users.sourceforge.net> Date: Fri, 22 Jul 2016 21:21:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <5317A59D.4@users.sourceforge.net> X-Provags-ID: V03:K0:nlxqSlheCkbkmLtlLN517/PT7ObpGM23kTRFFAtPzGXDJcvMWsy OPUgw+q71OEVPNUubtoapEq3NZfbdDwuVABScOOY4g3ejbkvPZSKvgRFvr70aZBbcOLPEol fZ+s9xPstAXqLzbqdKaZa58/Y+Idq46AY9rD8KqSB52vf1DqVCGr1TB6KSTGKPu0HwgFOpo TA0i5B196A/olA3twr7mg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Wz9FmNgQcpI=:tXCK+JYfm9NfeMN/vrrWgV 49buf/qr2kNizMjzoG9ANTaCqr/L2w1whYHfCc4RJhs4bCum+/V6GEWOdjJY2aHi2rsx5Ame5 Xsw7sRQ8g2F/hoflmz37jN48g5UUl78s+tUJQ88QMs2LdnGoqsk9Yd+36aRbWuydFZZGytkqb Uf2ESISJreMiinoOO6tkwPEUKfMkru2+bukLM+P6+Wbm/1UovJgtigytM4P3HDody/MoXRDi9 n6Whjvz5FHdUli9pwY1fRv9PJtnS13PnNJAIJZzJTpyf1ltwsnIXVh7CUcHSDELiFks+xjKaq cEJVYI0uK7v7gM7UoQ63QzMbxh5Yu/CfjNkhj68bf41vHb+T7EpoITCpDvjnXK5zpW7CXPJwA Gfh0A1TwDj5aAvMqn995oM1Zbeij8LhSa49Y+MVW6otypXxz710qmrJCtdvgrffg3hBVqnFGy 5CrYQB4/iNzAqZSePhJhA8HATC6HbwwQ9zRqXvEWHb2vnvv1w2CT/NXHORfDn9GuX3Eob+Ely A5vhAf7paXTEEA+e4Mje8BYJrNZ1h48FsQpZCES2iff76gdd1kSNfptvrzyEhqjo+5YmImEwW Vi3h7f067vW79O2VdBAWbGyfCqUEtmCes8TD/KtphkE4ynmrqFw1QViH9H2gKcpF75P2qN2UG +ZxKuHvPhlqCBYok4hmcsgJzR5f3CG0iIKx2D410KZ1JXkjQTKPANJlSCAEAMDiYwWdJ8UtPl TGW8BouN6PHYDk2q46MnT1hNtd7CWc7JpHFj0R60guWopuEk4L0dd10uhy/NzwlxgiFNqlghL GGQ1hTm Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Fri, 22 Jul 2016 21:07:37 +0200 The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- block/elevator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index 7096c22..29dc177 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -846,8 +846,7 @@ int elv_register(struct elevator_type *e) spin_lock(&elv_list_lock); if (elevator_find(e->elevator_name)) { spin_unlock(&elv_list_lock); - if (e->icq_cache) - kmem_cache_destroy(e->icq_cache); + kmem_cache_destroy(e->icq_cache); return -EBUSY; } list_add_tail(&e->list, &elv_list);