linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: qla2xxxx: avoid type mismatch in comparison
@ 2016-01-20 10:47 Arnd Bergmann
  2016-01-20 11:04 ` Nicholas A. Bellinger
  2016-01-20 16:10 ` Bart Van Assche
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-01-20 10:47 UTC (permalink / raw)
  To: Nicholas Bellinger
  Cc: qla2xxx-upstream, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi, linux-kernel, linux-arm-kernel, Alexei Potashnik,
	Quinn Tran, Himanshu Madhani, Hannes Reinecke

A recent bug fix added code that does

        bool logged_out = (status & 0xFFFF);
        if (logged_out == CTIO_PORT_LOGGED_OUT)
		...

This looks wrong because we are comparing a boolean with an
integer constant, ang gcc warns about it accordingly:

drivers/scsi/qla2xxx/qla_target.c: In function 'qlt_do_ctio_completion':
drivers/scsi/qla2xxx/qla_target.c:3587:20: warning: comparison of constant '41' with boolean expression is always false [-Wbool-compare]
        (logged_out == CTIO_PORT_LOGGED_OUT) ?

The correct fix is presumably to make that variable an 'int'.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 71cdc0796465 ("qla2xxx: Delete session if initiator is gone from FW")
---
The patch introducing this is currenly in linux-next through the target-updates/for-next
branch.

diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index c7ab9e69c881..8075a4cdb45c 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -3580,7 +3580,7 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha, uint32_t handle,
 		case CTIO_PORT_LOGGED_OUT:
 		case CTIO_PORT_UNAVAILABLE:
 		{
-			bool logged_out = (status & 0xFFFF);
+			int logged_out = (status & 0xFFFF);
 			ql_dbg(ql_dbg_tgt_mgt, vha, 0xf059,
 			    "qla_target(%d): CTIO with %s status %x "
 			    "received (state %x, se_cmd %p)\n", vha->vp_idx,

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

* Re: [PATCH] scsi: qla2xxxx: avoid type mismatch in comparison
  2016-01-20 10:47 [PATCH] scsi: qla2xxxx: avoid type mismatch in comparison Arnd Bergmann
@ 2016-01-20 11:04 ` Nicholas A. Bellinger
  2016-01-20 16:10 ` Bart Van Assche
  1 sibling, 0 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2016-01-20 11:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: qla2xxx-upstream, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi, linux-kernel, linux-arm-kernel, Alexei Potashnik,
	Quinn Tran, Himanshu Madhani, Hannes Reinecke

On Wed, 2016-01-20 at 11:47 +0100, Arnd Bergmann wrote:
> A recent bug fix added code that does
> 
>         bool logged_out = (status & 0xFFFF);
>         if (logged_out == CTIO_PORT_LOGGED_OUT)
> 		...
> 
> This looks wrong because we are comparing a boolean with an
> integer constant, ang gcc warns about it accordingly:
> 
> drivers/scsi/qla2xxx/qla_target.c: In function 'qlt_do_ctio_completion':
> drivers/scsi/qla2xxx/qla_target.c:3587:20: warning: comparison of constant '41' with boolean expression is always false [-Wbool-compare]
>         (logged_out == CTIO_PORT_LOGGED_OUT) ?
> 
> The correct fix is presumably to make that variable an 'int'.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 71cdc0796465 ("qla2xxx: Delete session if initiator is gone from FW")
> ---
> The patch introducing this is currenly in linux-next through the target-updates/for-next
> branch.
> 
> diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
> index c7ab9e69c881..8075a4cdb45c 100644
> --- a/drivers/scsi/qla2xxx/qla_target.c
> +++ b/drivers/scsi/qla2xxx/qla_target.c
> @@ -3580,7 +3580,7 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha, uint32_t handle,
>  		case CTIO_PORT_LOGGED_OUT:
>  		case CTIO_PORT_UNAVAILABLE:
>  		{
> -			bool logged_out = (status & 0xFFFF);
> +			int logged_out = (status & 0xFFFF);
>  			ql_dbg(ql_dbg_tgt_mgt, vha, 0xf059,
>  			    "qla_target(%d): CTIO with %s status %x "
>  			    "received (state %x, se_cmd %p)\n", vha->vp_idx,
> 

Applied to target-pending/for-next.

Thanks Arnd.

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

* Re: [PATCH] scsi: qla2xxxx: avoid type mismatch in comparison
  2016-01-20 10:47 [PATCH] scsi: qla2xxxx: avoid type mismatch in comparison Arnd Bergmann
  2016-01-20 11:04 ` Nicholas A. Bellinger
@ 2016-01-20 16:10 ` Bart Van Assche
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2016-01-20 16:10 UTC (permalink / raw)
  To: Arnd Bergmann, Nicholas Bellinger
  Cc: qla2xxx-upstream, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi, linux-kernel, linux-arm-kernel, Alexei Potashnik,
	Quinn Tran, Himanshu Madhani, Hannes Reinecke

On 01/20/2016 02:47 AM, Arnd Bergmann wrote:
> A recent bug fix added code that does
>
>          bool logged_out = (status & 0xFFFF);
>          if (logged_out == CTIO_PORT_LOGGED_OUT)
> 		...
>
> This looks wrong because we are comparing a boolean with an
> integer constant, ang gcc warns about it accordingly:
>
> drivers/scsi/qla2xxx/qla_target.c: In function 'qlt_do_ctio_completion':
> drivers/scsi/qla2xxx/qla_target.c:3587:20: warning: comparison of constant '41' with boolean expression is always false [-Wbool-compare]
>          (logged_out == CTIO_PORT_LOGGED_OUT) ?
>
> The correct fix is presumably to make that variable an 'int'.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 71cdc0796465 ("qla2xxx: Delete session if initiator is gone from FW")
> ---
> The patch introducing this is currenly in linux-next through the target-updates/for-next
> branch.
>
> diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
> index c7ab9e69c881..8075a4cdb45c 100644
> --- a/drivers/scsi/qla2xxx/qla_target.c
> +++ b/drivers/scsi/qla2xxx/qla_target.c
> @@ -3580,7 +3580,7 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha, uint32_t handle,
>   		case CTIO_PORT_LOGGED_OUT:
>   		case CTIO_PORT_UNAVAILABLE:
>   		{
> -			bool logged_out = (status & 0xFFFF);
> +			int logged_out = (status & 0xFFFF);
>   			ql_dbg(ql_dbg_tgt_mgt, vha, 0xf059,
>   			    "qla_target(%d): CTIO with %s status %x "
>   			    "received (state %x, se_cmd %p)\n", vha->vp_idx,
>

Hello Arnd,

Please read the e-mail thread that is available at 
http://thread.gmane.org/gmane.linux.scsi/108899/focus=108943. That 
thread namely makes it clear that the above patch is not the proper way 
to fix that code.

Thanks,

Bart.

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

end of thread, other threads:[~2016-01-20 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-20 10:47 [PATCH] scsi: qla2xxxx: avoid type mismatch in comparison Arnd Bergmann
2016-01-20 11:04 ` Nicholas A. Bellinger
2016-01-20 16:10 ` Bart Van Assche

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