On Thu, 31 Jan 2008, Boaz Harrosh wrote:

> @@ -228,9 +228,14 @@ void usb_stor_set_xfer_buf(unsigned char *buffer,
>  {
>       unsigned int offset = 0;
>       struct scatterlist *sg = NULL;
> +     unsigned int count;
>  
> -     usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset,
> +     count = usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset,
>                       TO_XFER_BUF);
> -     if (buflen < scsi_bufflen(srb))
> -             scsi_set_resid(srb, scsi_bufflen(srb) - buflen);
> +
> +     /* Check for underflow */
> +     if (buflen > scsi_bufflen(srb))
> +             count = buflen;
> +
> +     scsi_set_resid(srb, scsi_bufflen(srb) - count);
>  }

This last "if" statement doesn't look right.  And since you know that
count will never be larger than scsi_bufflen(srb), you don't have to
check for underflow at all.  Just leave out the "if" and call
scsi_set_resid() directly.

Alan Stern

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to