From patchwork Wed Feb 8 21:16:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9563469 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 71EBB60146 for ; Wed, 8 Feb 2017 21:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2AF8284D8 for ; Wed, 8 Feb 2017 21:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A48E8284FF; Wed, 8 Feb 2017 21:23:56 +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 56A30284D8 for ; Wed, 8 Feb 2017 21:23:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751193AbdBHVXm (ORCPT ); Wed, 8 Feb 2017 16:23:42 -0500 Received: from mout.web.de ([212.227.15.3]:53565 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbdBHVXk (ORCPT ); Wed, 8 Feb 2017 16:23:40 -0500 Received: from [192.168.1.2] ([77.181.90.255]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LmuMO-1bwkcH1v7E-00h2q6; Wed, 08 Feb 2017 22:16:49 +0100 Subject: [PATCH 06/14] RDMA/cxgb4: Return an error code only as a constant in stag_open() To: linux-rdma@vger.kernel.org, Doug Ledford , Hal Rosenstock , Sean Hefty , Steve Wise References: <0aff92fa-2891-333a-2e1e-ca309db2ec72@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Wed, 8 Feb 2017 22:16:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <0aff92fa-2891-333a-2e1e-ca309db2ec72@users.sourceforge.net> X-Provags-ID: V03:K0:qZrTlEWrx50ZLIVMXQz5z5HNTn96T8XqjP+NNH2xW/qjQVTrWbU yTdlezjfb/oAKRjVZYG88omTIAuA7ByNq5vnDvQd8BtWWuGbCkJ58n+M/4bkVCkxj0W9vGt qdt/9gSLd5A3q3HJ7IsgSZ10xF2NAsELqN9T67nQv8piMijqKlDYNLcTbUcOGgUSKA2+1VS I5mZc7oXA7ADXASYTtXZw== X-UI-Out-Filterresults: notjunk:1; V01:K0:laEqa3kXR9k=:qz02A+aAv53qvbsWUvWgI9 KhNh1r0lXmV168nacOzbj+bWx5uIm6/6VCGAfgbww4CNxrkWJyXJM4/0t/9Yvun6GfsU7PCp8 7gQuEIZZQCkezYtrFO3Z7sivtbQ8Pb3YHCdHL5JYXa8CHhZZaP+kh/jM6VBJwfHwJKwfum639 6nHuohvj0OiUHn327XHwsoKeCY07yZQwVI8t4aRAWGHqQWPA7vBZWCwUz2C9q3GX+5E9ZsOkr 4w3UH6Wuk+fZY6W0ZqEnq9FuxwE1cyp7CDxWFLi3Kc9iijC2SxGVcUze4OgAp0ltuGh4wU2G/ W9R3djM2XK06H5c6hdpiWHneyZMQvy20oSGxMs51jzle+gX5H7dxgZD3JbTeeia/sRLovu69u iwZuFKutSMYLccRCtM/X+gpGiR4F9s3Uj+d3zM4H3KOE6nMtSgtUeOvNxEHnL/uSZIpvfp9s8 6HzW2OsYimvYPKnGx/E0oYhJfKdlzyNtYK6GrTnrev3nXJeaf/gyi8yFdBlPWS2uKvif8Oyi5 qR0v9KaRLewzGYZ8FeEu8VU8cxe/YEB6for9a5YmB9dZJWD+ZkTmoFiWp2109Z4ARrVED2D8K A3OZaRpKV9CZ+ijeFe+if0NJAR3eDTe72Un68wub7CeJQNsuew4RQ+k+rhTcvomt+ASb2Wr+j 0BiOnewyZlvXVC81QXtTgK8f0/jI6Jj+H66AHrd7mEa974umKA21pvcuUN1i6YmVbesPDXomY HOnu6IKSO0loPtqSCFGX4VDGQ1BAlSbDOFaX9a5rR2JON1l8gZRVVELl28fwUGA1UZmUfvvex lL03qa6 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Wed, 8 Feb 2017 16:50:52 +0100 * Return an error code without storing it in an intermediate variable. * Adjust jump targets according to the Linux coding style convention. * Delete the local variable "ret" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/cxgb4/device.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c index 51801a7d4fb3..90fa96abb5bc 100644 --- a/drivers/infiniband/hw/cxgb4/device.c +++ b/drivers/infiniband/hw/cxgb4/device.c @@ -433,14 +433,12 @@ static int stag_release(struct inode *inode, struct file *file) static int stag_open(struct inode *inode, struct file *file) { struct c4iw_debugfs_data *stagd; - int ret = 0; int count = 1; stagd = kmalloc(sizeof *stagd, GFP_KERNEL); - if (!stagd) { - ret = -ENOMEM; - goto out; - } + if (!stagd) + goto failure_indication; + stagd->devp = inode->i_private; stagd->pos = 0; @@ -450,10 +448,8 @@ static int stag_open(struct inode *inode, struct file *file) stagd->bufsize = count * 256; stagd->buf = vmalloc(stagd->bufsize); - if (!stagd->buf) { - ret = -ENOMEM; - goto err1; - } + if (!stagd->buf) + goto free_stagd; spin_lock_irq(&stagd->devp->lock); idr_for_each(&stagd->devp->mmidr, dump_stag, stagd); @@ -461,11 +457,11 @@ static int stag_open(struct inode *inode, struct file *file) stagd->buf[stagd->pos++] = 0; file->private_data = stagd; - goto out; -err1: + return 0; +free_stagd: kfree(stagd); -out: - return ret; +failure_indication: + return -ENOMEM; } static const struct file_operations stag_debugfs_fops = {