diff mbox series

scsi: qla2xxx: Simplify if condition evaluation

Message ID Y78HoiOWkc3RrEgN@ubun2204.myguest.virtualbox.org (mailing list archive)
State Superseded
Headers show
Series scsi: qla2xxx: Simplify if condition evaluation | expand

Commit Message

Deepak R Varma Jan. 11, 2023, 7:01 p.m. UTC
A logical evaluation of type (!A || A && B) can be simplified as
(!A || B).
Improvement by suggested by excluded_middle.cocci Coccinelel semantic
patch.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
Please note: Change is compile tested only.

 drivers/scsi/qla2xxx/qla_target.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Lee Duncan Jan. 12, 2023, 3:26 a.m. UTC | #1
On 1/11/23 11:01, Deepak R Varma wrote:
> A logical evaluation of type (!A || A && B) can be simplified as
> (!A || B).
> Improvement by suggested by excluded_middle.cocci Coccinelel semantic
> patch.
> 
> Signed-off-by: Deepak R Varma <drv@mailo.com>
> ---
> Please note: Change is compile tested only.
> 
>   drivers/scsi/qla2xxx/qla_target.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
> index 548f22705ddc..bf6aacf4dbd1 100644
> --- a/drivers/scsi/qla2xxx/qla_target.c
> +++ b/drivers/scsi/qla2xxx/qla_target.c
> @@ -1028,8 +1028,7 @@ void qlt_free_session_done(struct work_struct *work)
>   		}
>   
>   		if (ha->flags.edif_enabled &&
> -		    (!own || (own &&
> -			      own->iocb.u.isp24.status_subcode == ELS_PLOGI))) {
> +				(own && own->iocb.u.isp24.status_subcode == ELS_PLOGI)) {
>   			sess->edif.authok = 0;
>   			if (!ha->flags.host_shutting_down) {
>   				ql_dbg(ql_dbg_edif, vha, 0x911e,

It seems like you missed something in the translation. You left of the 
"!own" in your replacement. You are translating (!A || A && B) as (A && B).

--
Lee Duncan
Deepak R Varma Jan. 12, 2023, 4:26 a.m. UTC | #2
On Wed, Jan 11, 2023 at 07:26:32PM -0800, Lee Duncan wrote:
> On 1/11/23 11:01, Deepak R Varma wrote:
> > A logical evaluation of type (!A || A && B) can be simplified as
> > (!A || B).
> > Improvement by suggested by excluded_middle.cocci Coccinelel semantic
> > patch.
> > 
> > Signed-off-by: Deepak R Varma <drv@mailo.com>
> > ---
> > Please note: Change is compile tested only.
> > 
> >   drivers/scsi/qla2xxx/qla_target.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
> > index 548f22705ddc..bf6aacf4dbd1 100644
> > --- a/drivers/scsi/qla2xxx/qla_target.c
> > +++ b/drivers/scsi/qla2xxx/qla_target.c
> > @@ -1028,8 +1028,7 @@ void qlt_free_session_done(struct work_struct *work)
> >   		}
> >   		if (ha->flags.edif_enabled &&
> > -		    (!own || (own &&
> > -			      own->iocb.u.isp24.status_subcode == ELS_PLOGI))) {
> > +				(own && own->iocb.u.isp24.status_subcode == ELS_PLOGI)) {
> >   			sess->edif.authok = 0;
> >   			if (!ha->flags.host_shutting_down) {
> >   				ql_dbg(ql_dbg_edif, vha, 0x911e,
> 
> It seems like you missed something in the translation. You left of the
> "!own" in your replacement. You are translating (!A || A && B) as (A && B).

Thanks for catching that. My bad. I will correct and send in v2.

Regards,
./drv

> 
> --
> Lee Duncan
>
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 548f22705ddc..bf6aacf4dbd1 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -1028,8 +1028,7 @@  void qlt_free_session_done(struct work_struct *work)
 		}
 
 		if (ha->flags.edif_enabled &&
-		    (!own || (own &&
-			      own->iocb.u.isp24.status_subcode == ELS_PLOGI))) {
+				(own && own->iocb.u.isp24.status_subcode == ELS_PLOGI)) {
 			sess->edif.authok = 0;
 			if (!ha->flags.host_shutting_down) {
 				ql_dbg(ql_dbg_edif, vha, 0x911e,