From patchwork Thu Nov 5 08:10:47 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: 7558891 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 B71D69F4F5 for ; Thu, 5 Nov 2015 08:11:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D76782086F for ; Thu, 5 Nov 2015 08:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF732207C1 for ; Thu, 5 Nov 2015 08:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033071AbbKEILT (ORCPT ); Thu, 5 Nov 2015 03:11:19 -0500 Received: from mout.web.de ([212.227.17.11]:64514 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032185AbbKEILQ (ORCPT ); Thu, 5 Nov 2015 03:11:16 -0500 Received: from [192.168.1.2] ([78.49.111.82]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LpO93-1aQ1Xq3IxR-00fAzd; Thu, 05 Nov 2015 09:10:59 +0100 Subject: [PATCH] staging/rdma/hfi1: Delete unnecessary checks before two function calls 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 , Mike Marciniszyn , Sean Hefty , linux-rdma@vger.kernel.org, devel@driverdev.osuosl.org Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring X-Enigmail-Draft-Status: N1110 Message-ID: <563B0F07.3090301@users.sourceforge.net> Date: Thu, 5 Nov 2015 09:10:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <5317A59D.4@users.sourceforge.net> X-Provags-ID: V03:K0:WViYKmKz6rXiuAr/eMdNJFljTm7O2Y8P5Qh4IYB9Jl6EMAM/Ra3 iRN3tNTikKESvqhtcBb03uJJXR8KcA6VbPnHoDeU+63aC5Z8CskXmxZFM/X95C9g+Kz+And fjQA+eL/fjEsuTCS5qMARBM53Lq8NLGzhlVIsdTxdrU71A2Ds/g8S9DMk7AtvLjPK7qk+Vp pLP+vivU/RPyd+Htt5Z6w== X-UI-Out-Filterresults: notjunk:1; V01:K0:zYNdb7rOmVg=:AVzu1pIbwZcj4dQ5qzqXlO xOI0anUxuE9/SsRe6OdpFAfCmjP7tNnjpgUDG9v7UuG1ZwIcuEi6Ji89ShH9goHZDi1+lJVBT bQCmjc0K6CRpczOJGcZNtXf1Cu6ouMFn6mbWqpZfVOf+dTVc+O3mnafxMVbNNy0nY3hAOd7uA E5Uanksw/AGnibAjSyasysDcntymHavZAKL4va7tkWoIhm1WsdYX1wNFqPc6Qq3MmZVdlL7L/ Eqj0xRgcI4ANv0+9HEuNdI4alqw4Uj+PZxrNvIrKinvrKZX37/LejqaF2U2GFJXtCItUQGQ4e U7iY6wNEUfZGCoU1bEDvt0Wcgt5+DVwTil1kyW7VcwYzeJ+Flopzjzqa1FpnOHCV7SXQEQCE4 JR9p6rB2wD5sBIbDS/5ySDOVL9wtOzWLl368k3kHi1z8fgRCHh7b38e4zb48QOFHPh8U8V0h2 LIPBMfrQ6w1lbihTXeKNi/lJtZ/eVDUPgnj5AFhn6YZJbm475RLf1JdrxFamFXEQsFoBVDkwe 0JLcBS+lY021QBQfWarvQEIcUFKnT0Z28Lpp1GDSZScXsI+ksbgWkcwGxw2QiDIqX76or7/US Zl1xGcyTEVLVH+epjcbrUcLcTtCEzkl1mM4aIaNc2CYYi4unorph3h0+I/Q+zJ5btohom0ejr BUYUbaech3O6rRNaIjdDwUBNnNx0b1WBQl0O3GprGpR31mgGHBl2PP+6gdbIHjIME3wCdF6kl O55bzOypeyeA/YTscAudiz6GIa2EZKYnRIuN+b/GBMR5+U/f/qI3DWNeK0TPd9wkxzcgnWNQi xRyapMP Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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: Thu, 5 Nov 2015 08:41:00 +0100 The functions "sc_return_credits" and "vfree" perform also input parameter validation. Thus the tests around their calls are not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/staging/rdma/hfi1/file_ops.c | 2 +- drivers/staging/rdma/hfi1/user_sdma.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rdma/hfi1/file_ops.c b/drivers/staging/rdma/hfi1/file_ops.c index aae9826..204d1d0 100644 --- a/drivers/staging/rdma/hfi1/file_ops.c +++ b/drivers/staging/rdma/hfi1/file_ops.c @@ -313,7 +313,7 @@ static ssize_t hfi1_file_write(struct file *fp, const char __user *data, case HFI1_CMD_SDMA_STATUS_UPD: break; case HFI1_CMD_CREDIT_UPD: - if (uctxt && uctxt->sc) + if (uctxt) sc_return_credits(uctxt->sc); break; case HFI1_CMD_TID_UPDATE: diff --git a/drivers/staging/rdma/hfi1/user_sdma.c b/drivers/staging/rdma/hfi1/user_sdma.c index 36c838d..45f3797 100644 --- a/drivers/staging/rdma/hfi1/user_sdma.c +++ b/drivers/staging/rdma/hfi1/user_sdma.c @@ -473,8 +473,7 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd) fd->pq = NULL; } if (fd->cq) { - if (fd->cq->comps) - vfree(fd->cq->comps); + vfree(fd->cq->comps); kfree(fd->cq); fd->cq = NULL; }