mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* test of 'good_bytes' in scsi_io_completion is always true (in drivers/scsi/scsi_lib.c)
@ 2005-04-19 22:38 Jesper Juhl
  2005-05-16 16:55 ` Jesper Juhl
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2005-04-19 22:38 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: linux-kernel, Eric Youngdale, linux-scsi


in drivers/scsi/scsi_lib.c::scsi_io_completion() 'good_bytes' is tested 
for being >= 0, but 'good_bytes' is an unsigned int, so that test is 
always true. My *guess* is that what was intended was to test if 
good_bytes is > 0, but I don't know this code well enough to be sure. 
The patch below makes the change to test if it's > 0, but if the code in 
the 'if' really wants to run if it's >= 0, then we might as well just 
remove the 'if'.

In any case, the current code looks fishy.


Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

--- linux-2.6.12-rc2-mm3-orig/drivers/scsi/scsi_lib.c	2005-04-11 21:20:49.000000000 +0200
+++ linux-2.6.12-rc2-mm3/drivers/scsi/scsi_lib.c	2005-04-20 00:29:14.000000000 +0200
@@ -766,7 +766,7 @@ void scsi_io_completion(struct scsi_cmnd
 	 * Next deal with any sectors which we were able to correctly
 	 * handle.
 	 */
-	if (good_bytes >= 0) {
+	if (good_bytes > 0) {
 		SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, %d bytes done.\n",
 					      req->nr_sectors, good_bytes));
 		SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg));




Please keep me on CC:



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

* Re: test of 'good_bytes' in scsi_io_completion is always true (in drivers/scsi/scsi_lib.c)
  2005-04-19 22:38 test of 'good_bytes' in scsi_io_completion is always true (in drivers/scsi/scsi_lib.c) Jesper Juhl
@ 2005-05-16 16:55 ` Jesper Juhl
  2005-05-16 17:03   ` Jesper Juhl
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2005-05-16 16:55 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: linux-kernel, Eric Youngdale, linux-scsi

(please keep me on the CC list when replying)


Hi James,

I never got any response to the mail below, so I'll try again :)
Should we just get rid of the code in the 'if' since it'll never trigger, 
or was the intention actually to test  if (good_bytes > 0)  ?  If so, then 
the patch should make good sense...

Comments ?

-- 
Jesper Juhl


On Wed, 20 Apr 2005, Jesper Juhl wrote:

> 
> in drivers/scsi/scsi_lib.c::scsi_io_completion() 'good_bytes' is tested 
> for being >= 0, but 'good_bytes' is an unsigned int, so that test is 
> always true. My *guess* is that what was intended was to test if 
> good_bytes is > 0, but I don't know this code well enough to be sure. 
> The patch below makes the change to test if it's > 0, but if the code in 
> the 'if' really wants to run if it's >= 0, then we might as well just 
> remove the 'if'.
> 
> In any case, the current code looks fishy.
> 
> 
> Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
> 
> --- linux-2.6.12-rc2-mm3-orig/drivers/scsi/scsi_lib.c	2005-04-11 21:20:49.000000000 +0200
> +++ linux-2.6.12-rc2-mm3/drivers/scsi/scsi_lib.c	2005-04-20 00:29:14.000000000 +0200
> @@ -766,7 +766,7 @@ void scsi_io_completion(struct scsi_cmnd
>  	 * Next deal with any sectors which we were able to correctly
>  	 * handle.
>  	 */
> -	if (good_bytes >= 0) {
> +	if (good_bytes > 0) {
>  		SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, %d bytes done.\n",
>  					      req->nr_sectors, good_bytes));
>  		SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg));
> 
> 
> 
> 
> Please keep me on CC:
> 

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

* Re: test of 'good_bytes' in scsi_io_completion is always true (in drivers/scsi/scsi_lib.c)
  2005-05-16 16:55 ` Jesper Juhl
@ 2005-05-16 17:03   ` Jesper Juhl
  0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2005-05-16 17:03 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: James E.J. Bottomley, linux-kernel, Eric Youngdale, linux-scsi

On Mon, 16 May 2005, Jesper Juhl wrote:

> (please keep me on the CC list when replying)
> 
> 
> Hi James,
> 
> I never got any response to the mail below, so I'll try again :)
> Should we just get rid of the code in the 'if' since it'll never trigger, 

I mean get rid of the "if", not "the code in the if" of course..


> or was the intention actually to test  if (good_bytes > 0)  ?  If so, then 
> the patch should make good sense...
> 
> Comments ?
> 
> -- 
> Jesper Juhl
> 
> 
> On Wed, 20 Apr 2005, Jesper Juhl wrote:
> 
> > 
> > in drivers/scsi/scsi_lib.c::scsi_io_completion() 'good_bytes' is tested 
> > for being >= 0, but 'good_bytes' is an unsigned int, so that test is 
> > always true. My *guess* is that what was intended was to test if 
> > good_bytes is > 0, but I don't know this code well enough to be sure. 
> > The patch below makes the change to test if it's > 0, but if the code in 
> > the 'if' really wants to run if it's >= 0, then we might as well just 
> > remove the 'if'.
> > 
> > In any case, the current code looks fishy.
> > 
> > 
> > Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
> > 
> > --- linux-2.6.12-rc2-mm3-orig/drivers/scsi/scsi_lib.c	2005-04-11 21:20:49.000000000 +0200
> > +++ linux-2.6.12-rc2-mm3/drivers/scsi/scsi_lib.c	2005-04-20 00:29:14.000000000 +0200
> > @@ -766,7 +766,7 @@ void scsi_io_completion(struct scsi_cmnd
> >  	 * Next deal with any sectors which we were able to correctly
> >  	 * handle.
> >  	 */
> > -	if (good_bytes >= 0) {
> > +	if (good_bytes > 0) {
> >  		SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, %d bytes done.\n",
> >  					      req->nr_sectors, good_bytes));
> >  		SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg));
> > 
> > 
> > 
> > 
> > Please keep me on CC:
> > 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

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

end of thread, other threads:[~2005-05-16 17:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-19 22:38 test of 'good_bytes' in scsi_io_completion is always true (in drivers/scsi/scsi_lib.c) Jesper Juhl
2005-05-16 16:55 ` Jesper Juhl
2005-05-16 17:03   ` Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®