[sane-devel] Problem with empty sense buffer in sanei_scsi (linux+hpusbscsi+vuescan)?

abel deuring a.deuring@satzbau-gmbh.de
Sat, 06 Oct 2001 21:38:43 +0200


This is a multi-part message in MIME format.
--------------3DEFD1F82CDA0B4DF50DE9E9
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

abel deuring wrote:
> The attached
> patch to sanei_scsi.c should avoid this call. 

... and as usual I forgot to hit the "attach" button. So, here is the
diff output.

Abel
--------------3DEFD1F82CDA0B4DF50DE9E9
Content-Type: text/plain; charset=us-ascii;
 name="sanei_scsi.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="sanei_scsi.c.diff"

--- sanei_scsi.c.orig	Sat Oct  6 18:31:44 2001
+++ sanei_scsi.c	Sat Oct  6 20:33:06 2001
@@ -2168,10 +2168,22 @@
                      || req->sgdata.sg3.hdr.host_status == SG_ERR_DID_TIME_OUT
                      || req->sgdata.sg3.hdr.driver_status == DRIVER_BUSY)
                    status = SANE_STATUS_DEVICE_BUSY;
-                 else if (handler)
+                 else if (handler && req->sgdata.sg3.hdr.sb_len_wr)
                    /* sense handler should return SANE_STATUS_GOOD if it
                       decided all was ok afterall */
                    status = (*handler) (req->fd, req->sgdata.sg3.sense_buffer, arg);
+                 else if (handler && req->sgdata.sg3.hdr.sb_len_wr)
+                   /* sense handler should return SANE_STATUS_GOOD if it
+                      decided all was ok afterall */
+                   status = (*handler) (req->fd, req->sgdata.sg3.sense_buffer, arg);
+  
+                 /* status bits INTERMEDIATE and CONDITION MET should not
+                    result in an error; neither should reserved bits
+                 */
+                 else if (   ((req->sgdata.sg3.hdr.status & 0x2a) == 0)
+                          && (req->sgdata.sg3.hdr.host_status == SG_ERR_DID_OK)
+                          && (req->sgdata.sg3.hdr.driver_status == SG_ERR_DRIVER_OK))
+                   status = SANE_STATUS_GOOD;
                  else
                    status = SANE_STATUS_IO_ERROR;
                }

--------------3DEFD1F82CDA0B4DF50DE9E9--