[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACKFLineQuBTUGaBLgRqSTEcVzyZaZAnzy0jOHREKdtCqmy6pQ@mail.gmail.com>
Date: Mon, 17 Sep 2018 10:36:44 -0700
From: Michael Chan <michael.chan@...adcom.com>
To: zhong jiang <zhongjiang@...wei.com>,
Vasundhara Volam <vasundhara-v.volam@...adcom.com>
Cc: David Miller <davem@...emloft.net>,
Netdev <netdev@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net: bnxt: Fix a uninitialized variable warning.
On Mon, Sep 17, 2018 at 9:31 AM, zhong jiang <zhongjiang@...wei.com> 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@...wei.com>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> index f3b9fbc..ab88217 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
> @@ -31,7 +31,7 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
> {
> struct hwrm_nvm_get_variable_input *req = msg;
> void *data_addr = NULL, *buf = NULL;
> - struct bnxt_dl_nvm_param nvm_param;
> + struct bnxt_dl_nvm_param nvm_param = {0};
> int bytesize, idx = 0, rc, i;
> dma_addr_t data_dma_addr;
>
I think it is better to return error if there is no param_id match
after the for loop. The for loop will initialize nvm_param if there
is param_id match.
Powered by blists - more mailing lists