Re: [PATCH v2] net: bnxt: Fix a uninitialized variable warning.

From: Michael Chan
Date: Tue Sep 18 2018 - 03:02:10 EST


On Mon, Sep 17, 2018 at 9:55 PM, zhong jiang <zhongjiang@xxxxxxxxxx> wrote:
> Fix the following compile warning:
>
> drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c:49:5: warning: ânvm_param.dir_typeâ may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (nvm_param.dir_type == BNXT_NVM_PORT_CFG)
>
> Signed-off-by: zhong jiang <zhongjiang@xxxxxxxxxx>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> index f3b9fbc..1ae56fc 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> @@ -46,6 +46,9 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
> }
> }
>
> + if (i == ARRAY_SIZE(nvm_params))
> + return -EINVAL;
> +

-EOPNOTSUPP might be a better return code. Other than that, it looks
good to me. Thanks.

> if (nvm_param.dir_type == BNXT_NVM_PORT_CFG)
> idx = bp->pf.port_id;
> else if (nvm_param.dir_type == BNXT_NVM_FUNC_CFG)
> --
> 1.7.12.4
>