* [PATCH] net: bnxt: Fix a uninitialized variable warning.
@ 2018-09-17 16:31 zhong jiang
2018-09-17 17:36 ` Michael Chan
0 siblings, 1 reply; 3+ messages in thread
From: zhong jiang @ 2018-09-17 16:31 UTC (permalink / raw)
To: davem; +Cc: michael.chan, netdev, linux-kernel
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@huawei.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;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: bnxt: Fix a uninitialized variable warning.
2018-09-17 16:31 [PATCH] net: bnxt: Fix a uninitialized variable warning zhong jiang
@ 2018-09-17 17:36 ` Michael Chan
2018-09-18 2:00 ` zhong jiang
0 siblings, 1 reply; 3+ messages in thread
From: Michael Chan @ 2018-09-17 17:36 UTC (permalink / raw)
To: zhong jiang, Vasundhara Volam; +Cc: David Miller, Netdev, open list
On Mon, Sep 17, 2018 at 9:31 AM, zhong jiang <zhongjiang@huawei.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@huawei.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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: bnxt: Fix a uninitialized variable warning.
2018-09-17 17:36 ` Michael Chan
@ 2018-09-18 2:00 ` zhong jiang
0 siblings, 0 replies; 3+ messages in thread
From: zhong jiang @ 2018-09-18 2:00 UTC (permalink / raw)
To: Michael Chan; +Cc: Vasundhara Volam, David Miller, Netdev, open list
On 2018/9/18 1:36, Michael Chan wrote:
> On Mon, Sep 17, 2018 at 9:31 AM, zhong jiang <zhongjiang@huawei.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@huawei.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.
Will do in v2. Thanks for review.
Sincerely,
zhong jiang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-18 2:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-17 16:31 [PATCH] net: bnxt: Fix a uninitialized variable warning zhong jiang
2018-09-17 17:36 ` Michael Chan
2018-09-18 2:00 ` zhong jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).