mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
PATCH 1/1 mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
This never evaluates to true.
--- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/mpt2sas/mpt2sas_scsih.c +1 -1
@@ -4363,7 +4363,7 @@ _scsih_sas_device_status_change_event(struct MPT2SAS_ADAPTER *ioc,#endif if (!(event_data->ReasonCode == -MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && +MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET || event_data->ReasonCode ==MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET ))return ;
Moore, Eric
NAKnack
The code beyond this check is intended for either INTERNAL_DEVICE_RESET or CMP_DEVICE_RESET. If the reason code is something else, we will want to return. There are 10 other types of reason codes besides these two. This proposed patch means we return only when the reason code is either INTERNAL_DEVICE_RESET or CMP_INTERNAL_RESET.
Eric Moore
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Roel Kluin
Sent: Wednesday, December 30, 2009 9:59 AM
To: James E.J. Bottomley; [email protected]; Andrew Morton; LKML; Desai, Kashyap
Subject: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
This never evaluates to true.
--- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/mpt2sas/mpt2sas_scsih.c +1 -1
@@ -4363,7 +4363,7 @@ _scsih_sas_device_status_change_event(struct MPT2SAS_ADAPTER *ioc,#endif if (!(event_data->ReasonCode == -MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && +MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET || event_data->ReasonCode ==MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET ))return ;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Eric
nack
The code beyond this check is intended for either
INTERNAL_DEVICE_RESETorCMP_DEVICE_RESET. If the reason code is something else, we will want to return. There are 10 other types of reason codes besides these two. This proposed patch means we return only when the reason code is eitherINTERNAL_DEVICE_RESETorCMP_INTERNAL_RESET.Eric Moore
my patch is correct but my changelog was wrong. Sorry for the confusion. It should have been:
Even if the ReasonCode is not INTERNAL_DEVICE_RESET nor CMP_DEVICE_RESET this still evaluates to true.
you can test this with:
#include <stdio.h>
int main()
{
int d;
for (d=0;d<4;++d)
printf("!(%d == 1 && %d == 2) = %d\n", d, d, !(d == 1
&& d == 2));
for (d=0;d<4;++d)
printf("!(%d == 1 || %d == 2) = %d\n", d, d, !(d == 1
|| d == 2));
return 0;
}Roel
Quoted 5 lines · On Thu, 7 Jan 2010 20:58:10 +0100 roel kluin <[email protected]> wrote:
Quoted 4 lines · Eric
nack
The code beyond this check is intended for either
INTERNAL_DEVICE_RESETorCMP_DEVICE_RESET. __ If the reason code is something else, we will want to return.__Thereare 10 other types of reason codes besides these two. This proposed patch means we return only when the reason code is eitherINTERNAL_DEVICE_RESETorCMP_INTERNAL_RESET.
Quoted 8 lines
Quoted 1 line
Eric Moore
my patch is correct but my changelog was wrong. Sorry for the confusion. It should have been:
Even if the ReasonCode is not
INTERNAL_DEVICE_RESETnorCMP_DEVICE_RESETthis still evaluates to true.
yup, the current code is wrong.
if (!(event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET)) return;
ReasonCode cannot equal two different things at the same time.
This is what we want:
if (event_data->ReasonCode != MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && event_data->ReasonCode != MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET) return;
Eric, the fix needs runtime testing please - it enables code which hasn't been executed in a long time, if ever.
In fact the compiler wasn't even emitting any code for the second half of _scsih_sas_device_status_change_event() because it worked out that there was no path to it.
Yes your patch will work. I just have tested it by sending INTERNAL_DEVICE_RESETS events, and the code is getting executed.
Regards,
Eric
-----Original Message-----
From: Andrew Morton [mailto:[email protected]]
Sent: Tuesday, January 12, 2010 2:54 PM
To: roel kluin
Cc: Moore, Eric; James E.J. Bottomley; [email protected]; LKML; Desai, Kashyap
Subject: Re: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
Quoted 5 lines · On Thu, 7 Jan 2010 20:58:10 +0100 roel kluin <[email protected]> wrote:
Quoted 4 lines · Eric
nack
The code beyond this check is intended for either
INTERNAL_DEVICE_RESETorCMP_DEVICE_RESET. __ If the reason code is something else, we will want to return.__Thereare 10 other types of reason codes besides these two. This proposed patch means we return only when the reason code is eitherINTERNAL_DEVICE_RESETorCMP_INTERNAL_RESET.
Quoted 8 lines
Quoted 1 line
Eric Moore
my patch is correct but my changelog was wrong. Sorry for the confusion. It should have been:
Even if the ReasonCode is not
INTERNAL_DEVICE_RESETnorCMP_DEVICE_RESETthis still evaluates to true.
yup, the current code is wrong.
if (!(event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET)) return;
ReasonCode cannot equal two different things at the same time.
This is what we want:
if (event_data->ReasonCode != MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && event_data->ReasonCode != MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET) return;
Eric, the fix needs runtime testing please - it enables code which hasn't been executed in a long time, if ever.
In fact the compiler wasn't even emitting any code for the second half of _scsih_sas_device_status_change_event() because it worked out that there was no path to it.
Quoted 45 lines · Eric
Quoted 45 lines
-----Original Message-----
From: Andrew Morton [mailto:[email protected]]
Sent: Tuesday, January 12, 2010 2:54 PM
To: roel kluin
Cc: Moore, Eric; James E.J. Bottomley; [email protected]; LKML; Desai, Kashyap
Subject: Re: [PATCH] mpt2sas: Fix &&/|| confusion in_scsih_sas_device_status_change_event()Quoted 5 lines · On Thu, 7 Jan 2010 20:58:10 +0100 roel kluin <[email protected]> wrote:
Quoted 4 lines · Eric
nack
The code beyond this check is intended for either
INTERNAL_DEVICE_RESETorCMP_DEVICE_RESET. __ If the reason code is something else, we will want to return.__Thereare 10 other types of reason codes besides these two. This proposed patch means we return only when the reason code is eitherINTERNAL_DEVICE_RESETorCMP_INTERNAL_RESET.Quoted 8 lines
Quoted 1 line
Eric Moore
my patch is correct but my changelog was wrong. Sorry for the confusion. It should have been:
Even if the ReasonCode is not
INTERNAL_DEVICE_RESETnorCMP_DEVICE_RESETthis still evaluates to true.yup, the current code is wrong.
if (!(event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET)) return;ReasonCode cannot equal two different things at the same time.
This is what we want:
if (event_data->ReasonCode != MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && event_data->ReasonCode != MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET) return;Eric, the fix needs runtime testing please - it enables code which hasn't been executed in a long time, if ever.
Quoted 7 lines
Quoted 4 lines
In fact the compiler wasn't even emitting any code for the second half of
_scsih_sas_device_status_change_event()because it worked out that there was no path to it.Yes your patch will work. I just have tested it by sending
INTERNAL_DEVICE_RESETSevents, and the code is getting executed.
(top-posting and quoting fixed)
Thanks. Was that an ack to merge?
Quoted 3 lines
Quoted 3 lines
Thanks. Was that an ack to merge?
Yes, please merge in the code.
ack