USBHost: Silence narrowing warning in USBHostMSD::inquiry

I changed the following initialization from:
    uint8_t cmd[6] = {0x12, (lun << 5) | evpd, page_code, 0, 36, 0};
to:
    uint8_t cmd[6] = {0x12, uint8_t((lun << 5) | evpd), page_code, 0, 36, 0};
This makes it clear to the compiler that we are Ok with the 32-bit
integer result from the shift and logical OR operation (after integral
promotions) being truncated down to a 8-bit unsigned value.  This is
safe as long as lun only has a value of 7 or lower.
pull/67/head
Adam Green 2013-08-29 21:16:45 -07:00
parent fb769b1566
commit c0d7c3fb39
1 changed files with 1 additions and 1 deletions

View File

@ -154,7 +154,7 @@ int USBHostMSD::SCSIRequestSense() {
int USBHostMSD::inquiry(uint8_t lun, uint8_t page_code) {
USB_DBG("Inquiry");
uint8_t evpd = (page_code == 0) ? 0 : 1;
uint8_t cmd[6] = {0x12, (lun << 5) | evpd, page_code, 0, 36, 0};
uint8_t cmd[6] = {0x12, uint8_t((lun << 5) | evpd), page_code, 0, 36, 0};
uint8_t result[36];
int status = SCSITransfer(cmd, 6, DEVICE_TO_HOST, result, 36);
if (status == 0) {