Skip to content

Commit c0d7c3f

Browse files
committed
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.
1 parent fb769b1 commit c0d7c3f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libraries/USBHost/USBHostMSD/USBHostMSD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ int USBHostMSD::SCSIRequestSense() {
154154
int USBHostMSD::inquiry(uint8_t lun, uint8_t page_code) {
155155
USB_DBG("Inquiry");
156156
uint8_t evpd = (page_code == 0) ? 0 : 1;
157-
uint8_t cmd[6] = {0x12, (lun << 5) | evpd, page_code, 0, 36, 0};
157+
uint8_t cmd[6] = {0x12, uint8_t((lun << 5) | evpd), page_code, 0, 36, 0};
158158
uint8_t result[36];
159159
int status = SCSITransfer(cmd, 6, DEVICE_TO_HOST, result, 36);
160160
if (status == 0) {

0 commit comments

Comments
 (0)