2014-06-01 12:33:24

by Rickard Strandqvist

[permalink] [raw]
Subject: [PATCH] net: ethernet: chelsio: cxgb4: t4_hw.c: Cleaning up uninitialized variables

There is a risk that the variable will be used without being initialized.

This was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <[email protected]>
---
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index bba6768..326c005 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -571,7 +571,7 @@ int t4_seeprom_wp(struct adapter *adapter, bool enable)
*/
int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
{
- u32 cclk_param, cclk_val;
+ u32 cclk_param, cclk_val = 0;
int i, ret, addr;
int ec, sn, pn;
u8 *vpd, csum;
--
1.7.10.4


2014-06-01 19:36:59

by Rickard Strandqvist

[permalink] [raw]
Subject: Re: [PATCH] net: ethernet: chelsio: cxgb4: t4_hw.c: Cleaning up uninitialized variables

Hi Dimitrios!

Okay sorry, I see what you mean...

Best regards
Rickard Strandqvist


2014-06-01 21:11 GMT+02:00 Dimitrios Michailidis <[email protected]>:
> Rickard Strandqvist wrote:
>> There is a risk that the variable will be used without being initialized.
>
> There isn't actual risk here, this variable is not used uninitialized AFAICS.
>
>> This was largely found by using a static code analysis program called cppcheck.
>
> It seems this is a false inference by the tool. I think the preferred method to suppress false tool warnings is to use uninitialized_var.
>
>> Signed-off-by: Rickard Strandqvist <[email protected]>
>> ---
>> drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
>> b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
>> index bba6768..326c005 100644
>> --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
>> +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
>> @@ -571,7 +571,7 @@ int t4_seeprom_wp(struct adapter *adapter, bool
>> enable)
>> */
>> int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
>> {
>> - u32 cclk_param, cclk_val;
>> + u32 cclk_param, cclk_val = 0;
>> int i, ret, addr;
>> int ec, sn, pn;
>> u8 *vpd, csum;
>> --
>> 1.7.10.4
>

2014-06-01 19:55:24

by Dimitrios Michailidis

[permalink] [raw]
Subject: RE: [PATCH] net: ethernet: chelsio: cxgb4: t4_hw.c: Cleaning up uninitialized variables

Rickard Strandqvist wrote:
> There is a risk that the variable will be used without being initialized.

There isn't actual risk here, this variable is not used uninitialized AFAICS.

> This was largely found by using a static code analysis program called cppcheck.

It seems this is a false inference by the tool. I think the preferred method to suppress false tool warnings is to use uninitialized_var.

> Signed-off-by: Rickard Strandqvist <[email protected]>
> ---
> drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> index bba6768..326c005 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> @@ -571,7 +571,7 @@ int t4_seeprom_wp(struct adapter *adapter, bool
> enable)
> */
> int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
> {
> - u32 cclk_param, cclk_val;
> + u32 cclk_param, cclk_val = 0;
> int i, ret, addr;
> int ec, sn, pn;
> u8 *vpd, csum;
> --
> 1.7.10.4