linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
@ 2009-12-30 16:58 Roel Kluin
  2010-01-07 19:31 ` Moore, Eric
  0 siblings, 1 reply; 7+ messages in thread
From: Roel Kluin @ 2009-12-30 16:58 UTC (permalink / raw)
  To: James E.J. Bottomley, linux-scsi, Andrew Morton, LKML, kashyap.desai

This never evaluates to true.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
 drivers/scsi/mpt2sas/mpt2sas_scsih.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index efabea1..82c5474 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -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;

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
  2009-12-30 16:58 [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event() Roel Kluin
@ 2010-01-07 19:31 ` Moore, Eric
  2010-01-07 19:58   ` roel kluin
  0 siblings, 1 reply; 7+ messages in thread
From: Moore, Eric @ 2010-01-07 19:31 UTC (permalink / raw)
  To: Roel Kluin, James E.J. Bottomley, linux-scsi, Andrew Morton,
	LKML, Desai, Kashyap

nack

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: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Roel Kluin
Sent: Wednesday, December 30, 2009 9:59 AM
To: James E.J. Bottomley; linux-scsi@vger.kernel.org; Andrew Morton; LKML; Desai, Kashyap
Subject: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()

This never evaluates to true.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
 drivers/scsi/mpt2sas/mpt2sas_scsih.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index efabea1..82c5474 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
  2010-01-07 19:31 ` Moore, Eric
@ 2010-01-07 19:58   ` roel kluin
  2010-01-12 21:54     ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: roel kluin @ 2010-01-07 19:58 UTC (permalink / raw)
  To: Moore, Eric
  Cc: James E.J. Bottomley, linux-scsi, Andrew Morton, LKML, Desai, Kashyap

On Thu, Jan 7, 2010 at 8:31 PM, Moore, Eric <Eric.Moore@lsi.com> wrote:
> nack
>
> 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

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
  2010-01-07 19:58   ` roel kluin
@ 2010-01-12 21:54     ` Andrew Morton
  2010-01-13  0:23       ` Moore, Eric
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2010-01-12 21:54 UTC (permalink / raw)
  To: roel kluin
  Cc: Moore, Eric, James E.J. Bottomley, linux-scsi, LKML, Desai, Kashyap

On Thu, 7 Jan 2010 20:58:10 +0100
roel kluin <roel.kluin@gmail.com> wrote:

> On Thu, Jan 7, 2010 at 8:31 PM, Moore, Eric <Eric.Moore@lsi.com> wrote:
> > nack
> >
> > 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
> 
> 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.
> 

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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
  2010-01-12 21:54     ` Andrew Morton
@ 2010-01-13  0:23       ` Moore, Eric
  2010-01-13  0:38         ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Moore, Eric @ 2010-01-13  0:23 UTC (permalink / raw)
  To: Andrew Morton, roel kluin
  Cc: James E.J. Bottomley, linux-scsi, LKML, Desai, Kashyap

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:akpm@linux-foundation.org] 
Sent: Tuesday, January 12, 2010 2:54 PM
To: roel kluin
Cc: Moore, Eric; James E.J. Bottomley; linux-scsi@vger.kernel.org; LKML; Desai, Kashyap
Subject: Re: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()

On Thu, 7 Jan 2010 20:58:10 +0100
roel kluin <roel.kluin@gmail.com> wrote:

> On Thu, Jan 7, 2010 at 8:31 PM, Moore, Eric <Eric.Moore@lsi.com> wrote:
> > nack
> >
> > 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
> 
> 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.
> 

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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
  2010-01-13  0:23       ` Moore, Eric
@ 2010-01-13  0:38         ` Andrew Morton
  2010-01-13  0:42           ` Moore, Eric
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2010-01-13  0:38 UTC (permalink / raw)
  To: Moore, Eric
  Cc: roel kluin, James E.J. Bottomley, linux-scsi, LKML, Desai, Kashyap

On Tue, 12 Jan 2010 17:23:41 -0700
"Moore, Eric" <Eric.Moore@lsi.com> wrote:

> > -----Original Message-----
> > From: Andrew Morton [mailto:akpm@linux-foundation.org] 
> > Sent: Tuesday, January 12, 2010 2:54 PM
> > To: roel kluin
> > Cc: Moore, Eric; James E.J. Bottomley; linux-scsi@vger.kernel.org; LKML; Desai, Kashyap
> > Subject: Re: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
> > 
> > On Thu, 7 Jan 2010 20:58:10 +0100
> > roel kluin <roel.kluin@gmail.com> wrote:
> > 
> > > On Thu, Jan 7, 2010 at 8:31 PM, Moore, Eric <Eric.Moore@lsi.com> wrote:
> > > > nack
> > > >
> > > > 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
> > > 
> > > 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.
> > > 
> > 
> > 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.
> 

(top-posting and quoting fixed)

Thanks.  Was that an ack to merge?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event()
  2010-01-13  0:38         ` Andrew Morton
@ 2010-01-13  0:42           ` Moore, Eric
  0 siblings, 0 replies; 7+ messages in thread
From: Moore, Eric @ 2010-01-13  0:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: roel kluin, James E.J. Bottomley, linux-scsi, LKML, Desai, Kashyap



>> Thanks.  Was that an ack to merge?

Yes, please merge in the code.  

ack

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-01-13  0:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-30 16:58 [PATCH] mpt2sas: Fix &&/|| confusion in _scsih_sas_device_status_change_event() Roel Kluin
2010-01-07 19:31 ` Moore, Eric
2010-01-07 19:58   ` roel kluin
2010-01-12 21:54     ` Andrew Morton
2010-01-13  0:23       ` Moore, Eric
2010-01-13  0:38         ` Andrew Morton
2010-01-13  0:42           ` Moore, Eric

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).