Re: scsi.h: please rename the status_byte() macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10-09-15 04:39 PM, Douglas Gilbert wrote:
... to something like:
scsi_status_byte_div2()
or:
scsi_broken_status_byte()

The bug in the bsg driver with its SCSI status byte
brought this to my attention. If memory serves about
10 years ago some of us tried to kill the status_byte()
macro.

But it is still there in the kernel's scsi/scsi.h
ready to trip up another generation of programmers:
#define status_byte(result) (((result) >> 1) & 0x7f)

with no explanation that it does NOT yield the SCSI
status byte but the right shifted (once) equivalent.

The correct macro (or inline function) for obtaining the
SCSI status byte from the 32 bit "result" from a LLD would
be:
#define scsi_status_byte(result) ((result) & 0xff)

[Long ago (20 years) something silly was put in bit 0
 so masking with 0xfe would work as well.]

Another thought, these macros are associated with the
mid-level or a ULD deciding whether a SCSI command has
succeeded; so scsi_cmnd.h would be a more appropriate
header.

Happily the version of scsi.h shown to the user space
(typically /usr/include/scsi/scsi.h) does not include
these defective macros. So any API breakage is limited
to the kernel.

Doug Gilbert


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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux