From: Andrzej Hajda <hidden> Date: 2016-08-23 06:16:36
Local variable msi_idx defined as unsigned int is always >= 0, thus both
'if' checks are always true. On the other side presence of USING_MSIX flag
suggests the checks should not be trivially true.
The simplest solution is to replace incorrect checks with direct testing
of adap->flags and remove spare variables.
The problem has been detected using semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
Signed-off-by: Andrzej Hajda <redacted>
---
Hi,
I am not familiar with the code, and it is not clear to me, so my solution
can be incorrect, anyway there is an issue here.
Regards
Andrzej
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
On Tuesday, August 08/23/16, 2016 at 08:16:19 +0200, Andrzej Hajda wrote:
Local variable msi_idx defined as unsigned int is always >= 0, thus both
'if' checks are always true. On the other side presence of USING_MSIX flag
suggests the checks should not be trivially true.
The simplest solution is to replace incorrect checks with direct testing
of adap->flags and remove spare variables.
The problem has been detected using semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
The correct fix is to have local variable 'msi_idx' as int instead of unsigned
int. Thanks for reporting the issue. Do you want me to send a V2?
Thanks,
Hari
From: Andrzej Hajda <hidden> Date: 2016-08-23 08:02:16
On 08/23/2016 09:46 AM, Hariprasad Shenai wrote:
On Tuesday, August 08/23/16, 2016 at 08:16:19 +0200, Andrzej Hajda wrote:
quoted
Local variable msi_idx defined as unsigned int is always >= 0, thus both
'if' checks are always true. On the other side presence of USING_MSIX flag
suggests the checks should not be trivially true.
The simplest solution is to replace incorrect checks with direct testing
of adap->flags and remove spare variables.
The problem has been detected using semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
The correct fix is to have local variable 'msi_idx' as int instead of unsigned
int. Thanks for reporting the issue. Do you want me to send a V2?
Thanks,
Hari
If adap->flags is constant during the call I see no point in creating
separate
variable with complicated initialization used only for the same thing as
'adap->flags & USING_MSIX', and even if adap->flags changes during the call
much simpler would be to use local var:
int using_msix = adap->flags & USING_MSIX;
and later use tests:
if (using_msix)
...
Am I correct?
Regards
Andrzej
On Tuesday, August 08/23/16, 2016 at 10:01:59 +0200, Andrzej Hajda wrote:
On 08/23/2016 09:46 AM, Hariprasad Shenai wrote:
quoted
On Tuesday, August 08/23/16, 2016 at 08:16:19 +0200, Andrzej Hajda wrote:
quoted
Local variable msi_idx defined as unsigned int is always >= 0, thus both
'if' checks are always true. On the other side presence of USING_MSIX flag
suggests the checks should not be trivially true.
The simplest solution is to replace incorrect checks with direct testing
of adap->flags and remove spare variables.
The problem has been detected using semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
The correct fix is to have local variable 'msi_idx' as int instead of unsigned
int. Thanks for reporting the issue. Do you want me to send a V2?
Thanks,
Hari
If adap->flags is constant during the call I see no point in creating
separate
variable with complicated initialization used only for the same thing as
'adap->flags & USING_MSIX', and even if adap->flags changes during the call
much simpler would be to use local var:
int using_msix = adap->flags & USING_MSIX;
and later use tests:
if (using_msix)
...
Am I correct?