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 <redacted>
---
drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--
2.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Leon Romanovsky <hidden> Date: 2017-09-14 12:54:53
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: ‘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.
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.
2.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Sep 14, 2017 at 5:54 AM, Leon Romanovsky [off-list ref] wrote:
On Thu, Sep 14, 2017 at 01:06:18PM +0200, Arnd Bergmann wrote:
quoted
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.
Thanks Arnd, Looks good.
quoted hunk
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.
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