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

abel deuring adeuring at gmx.net
Sat Oct 6 20:38:43 BST 2001


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
-------------- next part --------------
--- 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;
                }


More information about the sane-devel mailing list