Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388AbdINMyx (ORCPT ); Thu, 14 Sep 2017 08:54:53 -0400 Received: from mail-he1eur01on0057.outbound.protection.outlook.com ([104.47.0.57]:7446 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751131AbdINMyv (ORCPT ); Thu, 14 Sep 2017 08:54:51 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leonro@mellanox.com; Date: Thu, 14 Sep 2017 15:54:29 +0300 From: Leon Romanovsky To: Arnd Bergmann Cc: Ilan Tayari , Saeed Mahameed , Matan Barak , Boris Pismenny , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net/mlx5: fpga: avoid uninitialized return codes Message-ID: <20170914125429.GZ3405@mtr-leonro.local> References: <20170914110628.3590833-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IpgPcFyQO6wM49Um" Content-Disposition: inline In-Reply-To: <20170914110628.3590833-1-arnd@arndb.de> User-Agent: Mutt/1.9.0 (2017-09-02) X-Originating-IP: [12.145.98.24] X-ClientProxiedBy: MWHPR06CA0032.namprd06.prod.outlook.com (2603:10b6:301:39::45) To HE1PR0501MB1931.eurprd05.prod.outlook.com (2a01:111:e400:7b74::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d550d037-9809-4ede-6d59-08d4fb6fc58b X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:HE1PR0501MB1931; X-Microsoft-Exchange-Diagnostics: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wcPBCTiyMCIEpldnv11g5vDKXnWwA9JYrAZEyY8apBOb64YgEYe25lpAK/5A5t+E/96bzysK4TVzZnferYaNc4gH46FmFkgbxWzra4LT5YeKngDPqwvlyPZhg9e/Z/WWAGXenlFEri+FNmTXEZH2AFzQEnVGvgM8vD7mORhUJgf/z/XuhubHIsdd29QtfGswBWe6htdG2Ly3+pK89yFKhw5W7mRif31VLjAOwB3onhS73zMOIT1JDhdwP3Q67R9HOd6u5kDECSswtY2DmxpPEzPoH3gxvsTaBMHNYpCGBrp0AM1UF7Z4yas/Lg+Ds7El3rsyLdUdE9gvIV5CQlBdtDUtuBUOAbk/7WmgIMmNsQWN4Fw;4:yK+kzhyw3JS/H31/7/5uYvHhEYTdlwGakz/Ve1rXBdy9aCVUxDiMOq5Iqkbcb4yU2IKJsgTe+fMZbeEWWuH/iHsGmmYlfMlb7NTUzuCjFKWvwpzyHPBAOp6YLEs7TUH/u9S2EBkzfx+luh2m2Tp1Tv073I+cghCQmCUyArFfQ6mhKWR2lfw81OJRSzrroUIh7eHYZBGFU2qspFXWpnB6bJ3q5augfD1yE6Byz+P27Z9cx/ompKfJRyeMbdfAgda83CicAPguei4pV+HrrsqFHvT3wWyUkgrd0djBFbYkrddX9WU/z4AZH5gxLdvWetwBYWeULHjvMc3VddjTSQgyLrbSYIJePr0Kp/HrnGwjmis= X-Exchange-Antispam-Report-Test: UriScan:(22074186197030)(9452136761055)(183786458502308); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123560025)(20161123558100)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR0501MB1931;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR0501MB1931; X-Forefront-PRVS: 0430FA5CB7 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(7370300001)(4630300001)(6069001)(6009001)(39860400002)(346002)(376002)(199003)(189002)(24454002)(98436002)(68736007)(66066001)(7736002)(305945005)(5660300001)(86362001)(33656002)(50986999)(229853002)(21480400003)(54356999)(76176999)(8676002)(101416001)(6486002)(81166006)(81156014)(97736004)(4001350100001)(2906002)(2950100002)(6916009)(6666003)(4326008)(76506005)(6116002)(3846002)(1076002)(84326002)(189998001)(83506001)(105586002)(7350300001)(6246003)(110136004)(6496005)(16526017)(16586007)(966005)(54906002)(478600001)(106356001)(6306002)(316002)(25786009)(9686003)(53936002)(18370500001)(2700100001);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0501MB1931;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA1MDFNQjE5MzE7MjM6V2lLTFJnZkM3Tm8wY0Y5YU1UcjB1VUc1?= =?utf-8?B?cElYNTJQSTRIcTRnK2prUHh5WFZJZzJuU2hOS3RwNFBwVHRtS29hbDNybDB0?= =?utf-8?B?YzZpRzYrcEVHb0xDd2EwTEZyTVV3d3hCODc1dnJUZXlQdnBCV0pFWUdrdEhW?= =?utf-8?B?MEVEU1FqaG1pQlU2R0V2cEhvckFaeXc2UlVYVm9RR1NGSnBXRGxLUEdnbXVj?= =?utf-8?B?RTd0QjFWd0d5aDFmWFljSEdPVURoV2Z0Q0hFSTI2Qmt2M0wzSUFwKys5Z2tD?= =?utf-8?B?STlzQy9BMGJkN2ZlTHpzV2hIQjJLeFQxTFJiZGpkYUVsYnZnV3RIbFNUNDly?= =?utf-8?B?QmNmY0wwSHE0M2l0UFh6T21zUDlxemZoUDhaeXF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HSHnZ+fMHiCPOvaxadmiQtHKblu4SHM12/GmyEJep6zqBFSrr38hTPymlheTA==;5:+ZUqCORtT3PaC9bznz2BSuzHFXLW6kgMraj4YazlvC1H83/2AB22oD+9nY8BXl+u4XEkMMSQ+Oj/EcwMTnlsb3VQBN0akkcZHc7nJEqFMHWeVoPIZ04zAbHvzxLHVyhjUlVOMSS/W5Xq/ltdGUjnBw==;24:K8HmWwjEUFGYLyNf+Xbskd6SKUITdL60QtsGMYoPbTsNsPcQ6eX3qDbYYfi5h5FvOrGUAebHmNSbycEpykWVq9AwTYpzVvA/5bobso5YhJ0=;7:ZGCQnYjM9PeoqSKZFNgfR+CaS60ywPZfXZ7glz+0JXD43N44AqC/XF5C4lR3zjKNU/ck5e49uTlodAAx0+hqyfjCKEszFHXQa8e+XZO67H5eiDlof0ojpygvJ/vIHU+5iK7PaP7kMiD2IHewjRbNPK5Rzi8bLk9MUym5mzDuxURlcXK+I4oKYE3XQ7AML4w1qle/KVxoZnr7SeffxPdC+hu5Z1LJmxVEmLnVt6topcI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2017 12:54:43.5273 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB1931 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3982 Lines: 109 --IpgPcFyQO6wM49Um Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 14, 2017 at 01:06:18PM +0200, Arnd Bergmann wrote: > 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: =E2=80= =98err=E2=80=99 may be used uninitialized in this function [-Werror=3Dunini= tialized] > drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c:126:6: error: =E2=80= =98err=E2=80=99 may be used uninitialized in this function [-Werror=3Dunini= tialized] > > 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. I agree with you that size can't be zero and this patch will fix the warning, but if it is possible, I will prefer to have this check is written explicitly and not implicitly. diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c b/drivers/n= et/ethernet/mellanox/mlx5/core/fpga/sdk.c index 3c11d6e2160a..0e85bebe1dad 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c @@ -69,6 +69,9 @@ static int mlx5_fpga_mem_read_i2c(struct mlx5_fpga_device= *fdev, size_t size, if (!fdev->mdev) return -ENOTCONN; + if (!size) + return -EINVAL; + while (bytes_done < size) { actual_size =3D min(max_size, (size - bytes_done)); Thanks > > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D82203 > 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_devi= ce *fdev, size_t size, > size_t max_size =3D MLX5_FPGA_ACCESS_REG_SIZE_MAX; > size_t bytes_done =3D 0; > u8 actual_size; > - int err; > + int err =3D -EINVAL; > > if (!fdev->mdev) > return -ENOTCONN; > @@ -93,7 +93,7 @@ static int mlx5_fpga_mem_write_i2c(struct mlx5_fpga_dev= ice *fdev, size_t size, > size_t max_size =3D MLX5_FPGA_ACCESS_REG_SIZE_MAX; > size_t bytes_done =3D 0; > u8 actual_size; > - int err; > + int err =3D -EINVAL; > > if (!fdev->mdev) > return -ENOTCONN; > -- > 2.9.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --IpgPcFyQO6wM49Um Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEkhr/r4Op1/04yqaB5GN7iDZyWKcFAlm6fAUACgkQ5GN7iDZy WKcggBAA0nppc0PI4rydZ7PPdpYO1q3PsVdQnP3RqW5JMeyPvQ7UHUZ7IY3jNTf7 WvkZ0hFwu0G9lCRDGW10dOiyc1I/JEq14IcvmmSLHqCJkXIHz/WF+i65WgJf5HsM uF8LkaexcmW9RGMGpa73K+TVef+bKXWBkX2ZgnpYDDWwBj6gy2JrXoGqCeuo4U8x Or6SwWMa0Nsrv4IIw+EZ0Y9kgGWfHKdO6T28uM75nG+KSU5x9bMF0RKW1FF+FjoA Ux9SgULYU+p8v8vRYOPfFTn0B0XhOdeBOtaeYF5NiFGdeJCOWCTDpslabKFCd8cN dXb8HYfRSuARkLSvfkDXp7VCvcFEyEbqN2H4KnwnefuRTzCPn842Pf9MBEzAR8xP RR8JpiXxDvBMoP3vmw3ZYCH3LW6s4gtzpoX/FIvN/iYRz5ooxQxUY5tQLg0kNgdP RfyqonywA615pcya1YKHFzJPElaotOy1GODZo8TOI0lnbhYqiq4m/DQPtNUi+6J6 TPMuqfY+hFz8dCnN6ID1QicTr6T1w/LcuQZHb6GTSp6XSG51s0dKvHOCazaw/T7E T+0jvIi93Ms+bCTX4E+5Ekofk8fkeLAiVmjXsRJPCxRJD2wONPIEb4LTKa9aS2I9 Q3WNEPs5P/im5jdUwvFFN5Lxiv4pXsL9eWC9h+XxAw8oVHrDsrU= =cgP6 -----END PGP SIGNATURE----- --IpgPcFyQO6wM49Um--