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: 112531 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp609352qgf; Thu, 14 Sep 2017 04:06:40 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5hZbOeXHlDpXVM+9QHHIL9UfPeqb2alND9DwVWDUrcoyB7g9do+TFyqe0aYT9z8mg/LUnd X-Received: by 10.98.35.84 with SMTP id j81mr21410252pfj.79.1505387200636; Thu, 14 Sep 2017 04:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505387200; cv=none; d=google.com; s=arc-20160816; b=J9HJysyvctArO771S3PRvLfl7vgO0nQ/mY+G/TeLLlWFnyvZeT35S68JyDU6ESKAtc X7e8Ty5X9kIA/X8Rmskli4A625kraITMeGpZYBFl/o2LuHjOBNOPRmJi68+Fp9gWyooS JDEPi3LdaYeFEAQEEfb1W7vGag7nTL3U1KBmK6zEtBID1yPS1sKygSVuMsyZ6lD6THPp VLX1ihxxn7tsSYipJWwlCLLBXf1Zyob752eczAx8wbEM9dGrcafaAs3TcGTPEIq2vlUH 9x/OWW/h5QsAspBS3CusgCglhc+Dlwuht3P7yEcIEhvF7GDko2bYd3KAq0k1Oruws4TJ 40Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=RJIO3KX4rLGevVnnb8+JnHy22ya6DqlFVPm7voyiaqI=; b=0Joa7YX71EzaxjtVrvkLpf59fXDX+FtHRtB66bKAOrRkWU5Vk8UgAgSJhYlIkSaHoU LxoZVz7xB24U1i7MBuyWvgK2z1PhzvR//xxPeg+gxe4vs/NbFvpVg3OaRy3ZmF3y7zn3 ISRLqOrDJXTCGatDzJn4bhC2HZ2Z07gUSTbJIEI+HxvGK3FVbFbC0J1yKeffabhSjYBV W7xTq04OPHwsJg+5FVNCsD2IV60SE1v6DWVIBuORYsq+HpznTVW4zROr33nO+K6dYy5g 7Wp54jMl8AJSpgd86Vd7I41uQ+l2KT4kYXnrx+zA4GHzslnaAdHdxe1Fj4/6ZnNtB50I 7R1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8si3613158pli.223.2017.09.14.04.06.40; Thu, 14 Sep 2017 04:06:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752064AbdINLGf (ORCPT + 26 others); Thu, 14 Sep 2017 07:06:35 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.9.0 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;