snapscan-scsi: sense handler logic incorrect; unclear how to fix it
GCC 11 correctly identifies that sense_handler()
in backends/snapscan-scsi.c contains some bugs due to misleading indentation. For example, this line should only get called if the previous if-statement was true, but because of missing braces, it is always called.
However, it appears (to me) that there are larger issues in this function, and it is not clear what the correct behavior should be.
If a "process error" occurs or the device is "not ready" — but the additional sense code asc
is not recognized — then this function returns SANE_STATUS_GOOD
. It will also return this if the sense key sense
is not recognized.
It should probably return something else. Would that be SANE_STATUS_IO_ERROR
? I suppose the backend is learning that the scanner has a problem while performing "device I/O". The list of return codes in SANE is here.
Note the related question in #163 about whether a "hardware error" should be reported as an I/O error.