2018-08-02 02:59:21

by zhong jiang

[permalink] [raw]
Subject: [PATCH 0/2] remove double test condition


zhong jiang (2):
scsi:qla1280: remove unnessary same condition check
scsi:qlogicfas408: remove the same check in qlogicfas408_detect

drivers/scsi/qla1280.c | 1 -
drivers/scsi/qlogicfas408.c | 3 +--
2 files changed, 1 insertion(+), 3 deletions(-)

--
1.7.12.4



2018-08-02 02:57:57

by zhong jiang

[permalink] [raw]
Subject: [PATCH 1/2] scsi:qla1280: remove unnessary same condition check

doulbe test in a expression is redundant. so just remove one of
them.

Signed-off-by: zhong jiang <[email protected]>
---
drivers/scsi/qla1280.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 390775d..8e6f156 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -1504,7 +1504,6 @@ static void qla1280_mailbox_timeout(struct timer_list *t)
/* Issue SCSI reset, if we can't reset twice then bus is dead */
for (bus = 0; bus < ha->ports; bus++) {
if (!ha->bus_settings[bus].disable_scsi_reset &&
- qla1280_bus_reset(ha, bus) &&
qla1280_bus_reset(ha, bus))
ha->bus_settings[bus].scsi_bus_dead = 1;
}
--
1.7.12.4


2018-08-02 02:59:01

by zhong jiang

[permalink] [raw]
Subject: [PATCH 2/2] scsi:qlogicfas408: remove the same check in qlogicfas408_detect

we should not use same check in a expression. just remove one
of them.

Signed-off-by: zhong jiang <[email protected]>
---
drivers/scsi/qlogicfas408.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index 8b471a9..1409ac1 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -567,8 +567,7 @@ void qlogicfas408_setup(int qbase, int id, int int_type)
int qlogicfas408_detect(int qbase, int int_type)
{
REG1;
- return (((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7) &&
- ((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7));
+ return (inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7;
}

/*
--
1.7.12.4


2018-08-02 03:23:42

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH 2/2] scsi:qlogicfas408: remove the same check in qlogicfas408_detect

On Thu, 2018-08-02 at 10:45 +-0800, zhong jiang wrote:
+AD4- we should not use same check in a expression. just remove one
+AD4- of them.
+AD4-
+AD4- Signed-off-by: zhong jiang +ADw-zhongjiang+AEA-huawei.com+AD4-
+AD4- ---
+AD4- drivers/scsi/qlogicfas408.c +AHw- 3 +---
+AD4- 1 file changed, 1 insertion(+-), 2 deletions(-)
+AD4-
+AD4- diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
+AD4- index 8b471a9..1409ac1 100644
+AD4- --- a/drivers/scsi/qlogicfas408.c
+AD4- +-+-+- b/drivers/scsi/qlogicfas408.c
+AD4- +AEAAQA- -567,8 +-567,7 +AEAAQA- void qlogicfas408+AF8-setup(int qbase, int id, int int+AF8-type)
+AD4- int qlogicfas408+AF8-detect(int qbase, int int+AF8-type)
+AD4- +AHs-
+AD4- REG1+ADs-
+AD4- - return (((inb(qbase +- 0xe) +AF4- inb(qbase +- 0xe)) +AD0APQ- 7) +ACYAJg-
+AD4- - ((inb(qbase +- 0xe) +AF4- inb(qbase +- 0xe)) +AD0APQ- 7))+ADs-
+AD4- +- return (inb(qbase +- 0xe) +AF4- inb(qbase +- 0xe)) +AD0APQ- 7+ADs-
+AD4- +AH0-

Does inb() have any side effects?

Bart.


2018-08-02 03:24:01

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH 1/2] scsi:qla1280: remove unnessary same condition check

On Thu, 2018-08-02 at 10:45 +-0800, zhong jiang wrote:
+AD4- doulbe test in a expression is redundant. so just remove one of
+AD4- them.
+AD4-
+AD4- Signed-off-by: zhong jiang +ADw-zhongjiang+AEA-huawei.com+AD4-
+AD4- ---
+AD4- drivers/scsi/qla1280.c +AHw- 1 -
+AD4- 1 file changed, 1 deletion(-)
+AD4-
+AD4- diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
+AD4- index 390775d..8e6f156 100644
+AD4- --- a/drivers/scsi/qla1280.c
+AD4- +-+-+- b/drivers/scsi/qla1280.c
+AD4- +AEAAQA- -1504,7 +-1504,6 +AEAAQA- static void qla1280+AF8-mailbox+AF8-timeout(struct timer+AF8-list +ACo-t)
+AD4- /+ACo- Issue SCSI reset, if we can't reset twice then bus is dead +ACo-/
+AD4- for (bus +AD0- 0+ADs- bus +ADw- ha-+AD4-ports+ADs- bus+-+-) +AHs-
+AD4- if (+ACE-ha-+AD4-bus+AF8-settings+AFs-bus+AF0-.disable+AF8-scsi+AF8-reset +ACYAJg-
+AD4- - qla1280+AF8-bus+AF8-reset(ha, bus) +ACYAJg-
+AD4- qla1280+AF8-bus+AF8-reset(ha, bus))
+AD4- ha-+AD4-bus+AF8-settings+AFs-bus+AF0-.scsi+AF8-bus+AF8-dead +AD0- 1+ADs-
+AD4- +AH0-

Same question here: does qla1280+AF8-bus+AF8-reset() have any side effects?

Bart.


2018-08-02 03:31:11

by zhong jiang

[permalink] [raw]
Subject: Re: [PATCH 2/2] scsi:qlogicfas408: remove the same check in qlogicfas408_detect

On 2018/8/2 11:21, Bart Van Assche wrote:
> On Thu, 2018-08-02 at 10:45 +ACs-0800, zhong jiang wrote:
>> we should not use same check in a expression. just remove one
>> of them.
>>
>> Signed-off-by: zhong jiang <zhongjiang+AEA-huawei.com>
>> ---
>> drivers/scsi/qlogicfas408.c +AHw- 3 +ACs---
>> 1 file changed, 1 insertion(+ACs-), 2 deletions(-)
>>
>> diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
>> index 8b471a9..1409ac1 100644
>> --- a/drivers/scsi/qlogicfas408.c
>> +ACsAKwAr- b/drivers/scsi/qlogicfas408.c
>> +AEAAQA- -567,8 +ACs-567,7 +AEAAQA- void qlogicfas408+AF8-setup(int qbase, int id, int int+AF8-type)
>> int qlogicfas408+AF8-detect(int qbase, int int+AF8-type)
>> +AHs-
>> REG1;
>> - return (((inb(qbase +ACs- 0xe) +AF4- inb(qbase +ACs- 0xe)) == 7) +ACYAJg-
>> - ((inb(qbase +ACs- 0xe) +AF4- inb(qbase +ACs- 0xe)) == 7));
>> +ACs- return (inb(qbase +ACs- 0xe) +AF4- inb(qbase +ACs- 0xe)) == 7;
>> +AH0-
> Does inb() have any side effects?
just redundant. is it necessary for this . Maybe I miss something.

Thanks,
zhong jiang
> Bart.
>
>
>



2018-08-02 03:53:24

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH 2/2] scsi:qlogicfas408: remove the same check in qlogicfas408_detect

On Thu, 2018-08-02 at 11:29 +-0800, zhong jiang wrote:
+AD4- On 2018/8/2 11:21, Bart Van Assche wrote:
+AD4- +AD4- On Thu, 2018-08-02 at 10:45 +-0800, zhong jiang wrote:
+AD4- +AD4- +AD4- we should not use same check in a expression. just remove one
+AD4- +AD4- +AD4- of them.
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4- Signed-off-by: zhong jiang +ADw-zhongjiang+AEA-huawei.com+AD4-
+AD4- +AD4- +AD4- ---
+AD4- +AD4- +AD4- drivers/scsi/qlogicfas408.c +AHw- 3 +---
+AD4- +AD4- +AD4- 1 file changed, 1 insertion(+-), 2 deletions(-)
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4- diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
+AD4- +AD4- +AD4- index 8b471a9..1409ac1 100644
+AD4- +AD4- +AD4- --- a/drivers/scsi/qlogicfas408.c
+AD4- +AD4- +AD4- +-+-+- b/drivers/scsi/qlogicfas408.c
+AD4- +AD4- +AD4- +AEAAQA- -567,8 +-567,7 +AEAAQA- void qlogicfas408+AF8-setup(int qbase, int id, int int+AF8-type)
+AD4- +AD4- +AD4- int qlogicfas408+AF8-detect(int qbase, int int+AF8-type)
+AD4- +AD4- +AD4- +AHs-
+AD4- +AD4- +AD4- REG1+ADs-
+AD4- +AD4- +AD4- - return (((inb(qbase +- 0xe) +AF4- inb(qbase +- 0xe)) +AD0APQ- 7) +ACYAJg-
+AD4- +AD4- +AD4- - ((inb(qbase +- 0xe) +AF4- inb(qbase +- 0xe)) +AD0APQ- 7))+ADs-
+AD4- +AD4- +AD4- +- return (inb(qbase +- 0xe) +AF4- inb(qbase +- 0xe)) +AD0APQ- 7+ADs-
+AD4- +AD4- +AD4- +AH0-
+AD4- +AD4-
+AD4- +AD4- Does inb() have any side effects?
+AD4-
+AD4- just redundant. is it necessary for this . Maybe I miss something.

If doubletest.cocci came up with this patch, I think that script is
wrong and needs a thorough review.

Bart.


2018-08-02 04:03:12

by zhong jiang

[permalink] [raw]
Subject: Re: [PATCH 2/2] scsi:qlogicfas408: remove the same check in qlogicfas408_detect

On 2018/8/2 11:52, Bart Van Assche wrote:
> On Thu, 2018-08-02 at 11:29 +ACs-0800, zhong jiang wrote:
>> On 2018/8/2 11:21, Bart Van Assche wrote:
>>> On Thu, 2018-08-02 at 10:45 +ACs-0800, zhong jiang wrote:
>>>> we should not use same check in a expression. just remove one
>>>> of them.
>>>>
>>>> Signed-off-by: zhong jiang <zhongjiang+AEA-huawei.com>
>>>> ---
>>>> drivers/scsi/qlogicfas408.c +AHw- 3 +ACs---
>>>> 1 file changed, 1 insertion(+ACs-), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
>>>> index 8b471a9..1409ac1 100644
>>>> --- a/drivers/scsi/qlogicfas408.c
>>>> +ACsAKwAr- b/drivers/scsi/qlogicfas408.c
>>>> +AEAAQA- -567,8 +ACs-567,7 +AEAAQA- void qlogicfas408+AF8-setup(int qbase, int id, int int+AF8-type)
>>>> int qlogicfas408+AF8-detect(int qbase, int int+AF8-type)
>>>> +AHs-
>>>> REG1;
>>>> - return (((inb(qbase +ACs- 0xe) +AF4- inb(qbase +ACs- 0xe)) == 7) +ACYAJg-
>>>> - ((inb(qbase +ACs- 0xe) +AF4- inb(qbase +ACs- 0xe)) == 7));
>>>> +ACs- return (inb(qbase +ACs- 0xe) +AF4- inb(qbase +ACs- 0xe)) == 7;
>>>> +AH0-
>>> Does inb() have any side effects?
>> just redundant. is it necessary for this . Maybe I miss something.
> If doubletest.cocci came up with this patch, I think that script is
> wrong and needs a thorough review.
>
> Bart.
>
Ok, Maybe I am wrong with this issue. Thank you for clarification.

Sincerely,
zhong jiang
>