提交 ed2da627 编写于 作者: A Arnd Bergmann 提交者: David S. Miller

mlxsw: spectrum_kvdl: avoid uninitialized variable warning

gcc warns that 'resource_id' is not initialized if we don't come though
any of the three 'case' statements before:

drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c: In function 'mlxsw_sp_kvdl_part_init':
drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:275:8: error: 'resource_id' may be used uninitialized in this function [-Werror=maybe-uninitialized]

In the current code, that won't happen, but it's more robust to explicitly
handle this by returning a failure from mlxsw_sp_kvdl_part_init.

Fixes: 887839e6 ("mlxsw: spectrum_kvdl: Add support for dynamic partition set")
Signed-off-by: NArnd Bergmann <arnd@arndb.de>
Acked-by: NArkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b89c7695
......@@ -270,6 +270,8 @@ static int mlxsw_sp_kvdl_part_init(struct mlxsw_sp *mlxsw_sp,
case MLXSW_SP_KVDL_PART_LARGE_CHUNKS:
resource_id = MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS;
break;
default:
return -EINVAL;
}
err = devlink_resource_size_get(devlink, resource_id, &resource_size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册