Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752061AbdINLGe (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 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1790 Lines: 45 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; -- 2.9.0