From patchwork Thu Sep 14 11:06:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9952843 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 C0C4A603F3 for ; Thu, 14 Sep 2017 11:06:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C645128E61 for ; Thu, 14 Sep 2017 11:06:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA49A28EAC; Thu, 14 Sep 2017 11:06:38 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 365F128EBE for ; Thu, 14 Sep 2017 11:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751860AbdINLGe (ORCPT ); Thu, 14 Sep 2017 07:06:34 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:54862 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784AbdINLGc (ORCPT ); Thu, 14 Sep 2017 07:06:32 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0M5cGS-1dULVt2ic4-00xesr; Thu, 14 Sep 2017 13:06:29 +0200 From: Arnd Bergmann To: Ilan Tayari , Saeed Mahameed , Matan Barak , Leon Romanovsky Cc: Arnd Bergmann , Boris Pismenny , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/mlx5: fpga: avoid uninitialized return codes Date: Thu, 14 Sep 2017 13:06:18 +0200 Message-Id: <20170914110628.3590833-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:TC46QCQYPE1vjFCy/q+FM2/T7XkrpDu96Wkm+cjWOvt/l7XYjw+ ZXD3uIj60Cu5lmaPDTkHimqVZpe3w3q7lTEMIND8sNCyLA9Cicr/I32aKlBmkB+afaYWjSj qVXhPWf2mbo1ijHxyNCpkVTPtO6gDZimoHSgD7bSZ4QJ/jcha9GQ2tQlSKTuA/o/424hjXr A4PFKy8OkMsHOiFMWzj3g== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZpclZQwxeNU=:fh4fdD0R+rCkMxK0X5Bpai mC2CekBf6E9kJwb4rmWV9mNxsn93W6Hsc9DMXBrqtyL2IuGnvve1aB00iKxWXUGqOQEgylkOV uC3pv1U2kAx3vHs0e3wyLwDFNpnd5EKrElcEWhCOYP2PpQchnDkWaBrKOJl1SxNLHSNWxoMZp dB9ES3b0Y+7vXWZjY3YgmqZrO0pbnu2vUQ3P1J21Y3HVg+hq6/e4nU6didy1SkLkD2L+4/njm L4brdVD+FPvp8nLrs09cc0uen9HkapRTqSYURLKsUxj3roFhyoYzGVCfUtXKOmigor9Wcr6ve /7S6p3ZeVJHhYVIDi+3FJDjGZY50gzbzyTdT5ltPJ4ZVsTkDZiRJQNon8YWjoxaWnwJu9iXmN aC8mwFtCnnvOK+M9Rc4cXw1qI8DTWej2iH+F09n41yY0uaEphiDTNaEUp6yVi7qOOAclngyVE 50pfyZQ2r1CexdQHSyH9kq1Vj2D7uFLX2RDOASDY/ct6gFmM36PbTpbepuCA0wZ3+SNmVcZ/h bCxVhh0JwD7qbYbkhPVrMrQTZ2BUSHdC7ANx9GiiStT+7g3UOXGgv9hI9ZTmldrp7ruulMQj6 hWH43u+bsrnZJfwkvrCcB9IfQALRCGk5GtwqqDFL2XRmeiZLeURb6dSaB8/S/lPriiSBiC0mG coYTUp68J9C+X1Te9IyOYoV0Y2Br+/Ru7GBDct/596uuZJE987EvW8szsw0ScPPaexCUV6nQt XBumxU1WhxMf6oYFmv37J6ILc1IrBRnSfJeIkuS6fUGffR6YFYdp1ZksZiU= 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 calling mlx5_fpga_mem_{read,write}_i2c() with a zero length on older compiler version such as gcc-4.6 results in a warning that the return code is not initialized: drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c:147:6: error: ‘err’ may be used uninitialized in this function [-Werror=uninitialized] drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c:126:6: error: ‘err’ may be used uninitialized in this function [-Werror=uninitialized] On newer compilers, the 'err' variable is optimized away in this code path and assumed to be zero when the loop completes, so we don't get this warning. I'm changing the function here to instead return -EINVAL for the case, under the assumption that it was never meant to be called with a zero length argument. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82203 Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c index 3c11d6e2160a..914fb9d77a1a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c @@ -64,7 +64,7 @@ static int mlx5_fpga_mem_read_i2c(struct mlx5_fpga_device *fdev, size_t size, size_t max_size = MLX5_FPGA_ACCESS_REG_SIZE_MAX; size_t bytes_done = 0; u8 actual_size; - int err; + int err = -EINVAL; if (!fdev->mdev) return -ENOTCONN; @@ -93,7 +93,7 @@ static int mlx5_fpga_mem_write_i2c(struct mlx5_fpga_device *fdev, size_t size, size_t max_size = MLX5_FPGA_ACCESS_REG_SIZE_MAX; size_t bytes_done = 0; u8 actual_size; - int err; + int err = -EINVAL; if (!fdev->mdev) return -ENOTCONN;