All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] [SCSI] be2iscsi: cleanup a min_t() call
@ 2011-09-26  6:23 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-09-26  6:23 UTC (permalink / raw)
  To: Jayamohan Kallickal; +Cc: James E.J. Bottomley, linux-scsi, kernel-janitors

"sense_len" was declared as int type but actually it only stores a
u16 value that comes from hardware.  The cast to u16 in min_t()
confuses static analysis because it truncates the int to u16 so I've
fixed the declaration to reflect that "sense_len" is just a u16.

Also there was a call to cpu_to_be16() which I've changed to
be16_to_cpu().  The functions are equivalent, but obviously the
hardware is big endian and we're doing the min_t() comparison on CPU
endian values.

This whole patch is just a cleanup and doesn't affect how the code
works.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Compile tested only.  Sorry.

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 57fea38..344af8d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1104,7 +1104,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
 	struct be_status_bhs *sts_bhs  				(struct be_status_bhs *)io_task->cmd_bhs;
 	struct iscsi_conn *conn = beiscsi_conn->conn;
-	unsigned int sense_len;
 	unsigned char *sense;
 	u32 resid = 0, exp_cmdsn, max_cmdsn;
 	u8 rsp, status, flags;
@@ -1147,9 +1146,11 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
 	}
 
 	if (status = SAM_STAT_CHECK_CONDITION) {
+		u16 sense_len;
 		unsigned short *slen = (unsigned short *)sts_bhs->sense_info;
+
 		sense = sts_bhs->sense_info + sizeof(unsigned short);
-		sense_len =  cpu_to_be16(*slen);
+		sense_len = be16_to_cpu(*slen);
 		memcpy(task->sc->sense_buffer, sense,
 		       min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE));
 	}

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

* [patch] [SCSI] be2iscsi: cleanup a min_t() call
@ 2011-09-26  6:23 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-09-26  6:23 UTC (permalink / raw)
  To: Jayamohan Kallickal; +Cc: James E.J. Bottomley, linux-scsi, kernel-janitors

"sense_len" was declared as int type but actually it only stores a
u16 value that comes from hardware.  The cast to u16 in min_t()
confuses static analysis because it truncates the int to u16 so I've
fixed the declaration to reflect that "sense_len" is just a u16.

Also there was a call to cpu_to_be16() which I've changed to
be16_to_cpu().  The functions are equivalent, but obviously the
hardware is big endian and we're doing the min_t() comparison on CPU
endian values.

This whole patch is just a cleanup and doesn't affect how the code
works.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Compile tested only.  Sorry.

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 57fea38..344af8d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1104,7 +1104,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
 	struct be_status_bhs *sts_bhs =
 				(struct be_status_bhs *)io_task->cmd_bhs;
 	struct iscsi_conn *conn = beiscsi_conn->conn;
-	unsigned int sense_len;
 	unsigned char *sense;
 	u32 resid = 0, exp_cmdsn, max_cmdsn;
 	u8 rsp, status, flags;
@@ -1147,9 +1146,11 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
 	}
 
 	if (status == SAM_STAT_CHECK_CONDITION) {
+		u16 sense_len;
 		unsigned short *slen = (unsigned short *)sts_bhs->sense_info;
+
 		sense = sts_bhs->sense_info + sizeof(unsigned short);
-		sense_len =  cpu_to_be16(*slen);
+		sense_len = be16_to_cpu(*slen);
 		memcpy(task->sc->sense_buffer, sense,
 		       min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE));
 	}

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

* Re: [patch] [SCSI] be2iscsi: cleanup a min_t() call
  2011-09-26  6:23 ` Dan Carpenter
@ 2011-11-18 14:00   ` Dan Carpenter
  -1 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-11-18 14:00 UTC (permalink / raw)
  To: Jayamohan Kallickal; +Cc: James E.J. Bottomley, linux-scsi, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

On Mon, Sep 26, 2011 at 09:23:37AM +0300, Dan Carpenter wrote:
> "sense_len" was declared as int type but actually it only stores a
> u16 value that comes from hardware.  The cast to u16 in min_t()
> confuses static analysis because it truncates the int to u16 so I've
> fixed the declaration to reflect that "sense_len" is just a u16.
> 
> Also there was a call to cpu_to_be16() which I've changed to
> be16_to_cpu().  The functions are equivalent, but obviously the
> hardware is big endian and we're doing the min_t() comparison on CPU
> endian values.
> 
> This whole patch is just a cleanup and doesn't affect how the code
> works.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Ping.

regards,
dan carpenter


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [patch] [SCSI] be2iscsi: cleanup a min_t() call
@ 2011-11-18 14:00   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-11-18 14:00 UTC (permalink / raw)
  To: Jayamohan Kallickal; +Cc: James E.J. Bottomley, linux-scsi, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

On Mon, Sep 26, 2011 at 09:23:37AM +0300, Dan Carpenter wrote:
> "sense_len" was declared as int type but actually it only stores a
> u16 value that comes from hardware.  The cast to u16 in min_t()
> confuses static analysis because it truncates the int to u16 so I've
> fixed the declaration to reflect that "sense_len" is just a u16.
> 
> Also there was a call to cpu_to_be16() which I've changed to
> be16_to_cpu().  The functions are equivalent, but obviously the
> hardware is big endian and we're doing the min_t() comparison on CPU
> endian values.
> 
> This whole patch is just a cleanup and doesn't affect how the code
> works.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Ping.

regards,
dan carpenter


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [patch] [SCSI] be2iscsi: cleanup a min_t() call
  2011-09-26  6:23 ` Dan Carpenter
@ 2011-11-18 19:28   ` Mike Christie
  -1 siblings, 0 replies; 8+ messages in thread
From: Mike Christie @ 2011-11-18 19:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jayamohan Kallickal, James E.J. Bottomley, linux-scsi, kernel-janitors

On 09/26/2011 01:23 AM, Dan Carpenter wrote:
> "sense_len" was declared as int type but actually it only stores a
> u16 value that comes from hardware.  The cast to u16 in min_t()
> confuses static analysis because it truncates the int to u16 so I've
> fixed the declaration to reflect that "sense_len" is just a u16.
> 
> Also there was a call to cpu_to_be16() which I've changed to
> be16_to_cpu().  The functions are equivalent, but obviously the
> hardware is big endian and we're doing the min_t() comparison on CPU
> endian values.
> 
> This whole patch is just a cleanup and doesn't affect how the code
> works.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Compile tested only.  Sorry.
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 57fea38..344af8d 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -1104,7 +1104,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
>  	struct be_status_bhs *sts_bhs >  				(struct be_status_bhs *)io_task->cmd_bhs;
>  	struct iscsi_conn *conn = beiscsi_conn->conn;
> -	unsigned int sense_len;
>  	unsigned char *sense;
>  	u32 resid = 0, exp_cmdsn, max_cmdsn;
>  	u8 rsp, status, flags;
> @@ -1147,9 +1146,11 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
>  	}
>  
>  	if (status = SAM_STAT_CHECK_CONDITION) {
> +		u16 sense_len;
>  		unsigned short *slen = (unsigned short *)sts_bhs->sense_info;
> +
>  		sense = sts_bhs->sense_info + sizeof(unsigned short);
> -		sense_len =  cpu_to_be16(*slen);
> +		sense_len = be16_to_cpu(*slen);
>  		memcpy(task->sc->sense_buffer, sense,
>  		       min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE));

Looks ok to me.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>


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

* Re: [patch] [SCSI] be2iscsi: cleanup a min_t() call
@ 2011-11-18 19:28   ` Mike Christie
  0 siblings, 0 replies; 8+ messages in thread
From: Mike Christie @ 2011-11-18 19:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jayamohan Kallickal, James E.J. Bottomley, linux-scsi, kernel-janitors

On 09/26/2011 01:23 AM, Dan Carpenter wrote:
> "sense_len" was declared as int type but actually it only stores a
> u16 value that comes from hardware.  The cast to u16 in min_t()
> confuses static analysis because it truncates the int to u16 so I've
> fixed the declaration to reflect that "sense_len" is just a u16.
> 
> Also there was a call to cpu_to_be16() which I've changed to
> be16_to_cpu().  The functions are equivalent, but obviously the
> hardware is big endian and we're doing the min_t() comparison on CPU
> endian values.
> 
> This whole patch is just a cleanup and doesn't affect how the code
> works.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Compile tested only.  Sorry.
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 57fea38..344af8d 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -1104,7 +1104,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
>  	struct be_status_bhs *sts_bhs =
>  				(struct be_status_bhs *)io_task->cmd_bhs;
>  	struct iscsi_conn *conn = beiscsi_conn->conn;
> -	unsigned int sense_len;
>  	unsigned char *sense;
>  	u32 resid = 0, exp_cmdsn, max_cmdsn;
>  	u8 rsp, status, flags;
> @@ -1147,9 +1146,11 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
>  	}
>  
>  	if (status == SAM_STAT_CHECK_CONDITION) {
> +		u16 sense_len;
>  		unsigned short *slen = (unsigned short *)sts_bhs->sense_info;
> +
>  		sense = sts_bhs->sense_info + sizeof(unsigned short);
> -		sense_len =  cpu_to_be16(*slen);
> +		sense_len = be16_to_cpu(*slen);
>  		memcpy(task->sc->sense_buffer, sense,
>  		       min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE));

Looks ok to me.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>


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

* RE: [patch] [SCSI] be2iscsi: cleanup a min_t() call
  2011-11-18 19:28   ` Mike Christie
@ 2011-11-29 20:55     ` Jayamohan.Kallickal
  -1 siblings, 0 replies; 8+ messages in thread
From: Jayamohan.Kallickal @ 2011-11-29 20:55 UTC (permalink / raw)
  To: michaelc, dan.carpenter; +Cc: JBottomley, linux-scsi, kernel-janitors

Looks good.

Acked-by: Jayamohan Kallickal <Jayamohan.kallickal@emulex.com>

Thanks
Jay

-----Original Message-----
From: Mike Christie [mailto:michaelc@cs.wisc.edu] 
Sent: Friday, November 18, 2011 11:28 AM
To: Dan Carpenter
Cc: Kallickal, Jayamohan; James E.J. Bottomley; linux-scsi@vger.kernel.org; kernel-janitors@vger.kernel.org
Subject: Re: [patch] [SCSI] be2iscsi: cleanup a min_t() call

On 09/26/2011 01:23 AM, Dan Carpenter wrote:
> "sense_len" was declared as int type but actually it only stores a
> u16 value that comes from hardware.  The cast to u16 in min_t()
> confuses static analysis because it truncates the int to u16 so I've
> fixed the declaration to reflect that "sense_len" is just a u16.
> 
> Also there was a call to cpu_to_be16() which I've changed to
> be16_to_cpu().  The functions are equivalent, but obviously the
> hardware is big endian and we're doing the min_t() comparison on CPU
> endian values.
> 
> This whole patch is just a cleanup and doesn't affect how the code
> works.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Compile tested only.  Sorry.
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 57fea38..344af8d 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -1104,7 +1104,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
>  	struct be_status_bhs *sts_bhs >  				(struct be_status_bhs *)io_task->cmd_bhs;
>  	struct iscsi_conn *conn = beiscsi_conn->conn;
> -	unsigned int sense_len;
>  	unsigned char *sense;
>  	u32 resid = 0, exp_cmdsn, max_cmdsn;
>  	u8 rsp, status, flags;
> @@ -1147,9 +1146,11 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
>  	}
>  
>  	if (status = SAM_STAT_CHECK_CONDITION) {
> +		u16 sense_len;
>  		unsigned short *slen = (unsigned short *)sts_bhs->sense_info;
> +
>  		sense = sts_bhs->sense_info + sizeof(unsigned short);
> -		sense_len =  cpu_to_be16(*slen);
> +		sense_len = be16_to_cpu(*slen);
>  		memcpy(task->sc->sense_buffer, sense,
>  		       min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE));

Looks ok to me.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>


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

* RE: [patch] [SCSI] be2iscsi: cleanup a min_t() call
@ 2011-11-29 20:55     ` Jayamohan.Kallickal
  0 siblings, 0 replies; 8+ messages in thread
From: Jayamohan.Kallickal @ 2011-11-29 20:55 UTC (permalink / raw)
  To: michaelc, dan.carpenter; +Cc: JBottomley, linux-scsi, kernel-janitors

Looks good.

Acked-by: Jayamohan Kallickal <Jayamohan.kallickal@emulex.com>

Thanks
Jay

-----Original Message-----
From: Mike Christie [mailto:michaelc@cs.wisc.edu] 
Sent: Friday, November 18, 2011 11:28 AM
To: Dan Carpenter
Cc: Kallickal, Jayamohan; James E.J. Bottomley; linux-scsi@vger.kernel.org; kernel-janitors@vger.kernel.org
Subject: Re: [patch] [SCSI] be2iscsi: cleanup a min_t() call

On 09/26/2011 01:23 AM, Dan Carpenter wrote:
> "sense_len" was declared as int type but actually it only stores a
> u16 value that comes from hardware.  The cast to u16 in min_t()
> confuses static analysis because it truncates the int to u16 so I've
> fixed the declaration to reflect that "sense_len" is just a u16.
> 
> Also there was a call to cpu_to_be16() which I've changed to
> be16_to_cpu().  The functions are equivalent, but obviously the
> hardware is big endian and we're doing the min_t() comparison on CPU
> endian values.
> 
> This whole patch is just a cleanup and doesn't affect how the code
> works.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Compile tested only.  Sorry.
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 57fea38..344af8d 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -1104,7 +1104,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
>  	struct be_status_bhs *sts_bhs =
>  				(struct be_status_bhs *)io_task->cmd_bhs;
>  	struct iscsi_conn *conn = beiscsi_conn->conn;
> -	unsigned int sense_len;
>  	unsigned char *sense;
>  	u32 resid = 0, exp_cmdsn, max_cmdsn;
>  	u8 rsp, status, flags;
> @@ -1147,9 +1146,11 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
>  	}
>  
>  	if (status == SAM_STAT_CHECK_CONDITION) {
> +		u16 sense_len;
>  		unsigned short *slen = (unsigned short *)sts_bhs->sense_info;
> +
>  		sense = sts_bhs->sense_info + sizeof(unsigned short);
> -		sense_len =  cpu_to_be16(*slen);
> +		sense_len = be16_to_cpu(*slen);
>  		memcpy(task->sc->sense_buffer, sense,
>  		       min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE));

Looks ok to me.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>


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

end of thread, other threads:[~2011-11-29 21:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-26  6:23 [patch] [SCSI] be2iscsi: cleanup a min_t() call Dan Carpenter
2011-09-26  6:23 ` Dan Carpenter
2011-11-18 14:00 ` Dan Carpenter
2011-11-18 14:00   ` Dan Carpenter
2011-11-18 19:28 ` Mike Christie
2011-11-18 19:28   ` Mike Christie
2011-11-29 20:55   ` Jayamohan.Kallickal
2011-11-29 20:55     ` Jayamohan.Kallickal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.