summaryrefslogtreecommitdiff
path: root/src/class/msc
diff options
context:
space:
mode:
authorMengsk <[email protected]>2020-06-16 14:13:30 +0200
committerMengsk <[email protected]>2020-06-17 10:08:33 +0200
commit57b553e023ccac4c623bd7f57a7370fb43411ec1 (patch)
treef1aaa316a03c38ae5e59b69f6272494b529a3a54 /src/class/msc
parent8a67f81397245f6f54045e82273847ac5f48c1a7 (diff)
Fix IAR warnings.
Pa039 : use of address of unaligned structure member. Pe188: enumerated type mixed with another type.
Diffstat (limited to 'src/class/msc')
-rw-r--r--src/class/msc/msc_device.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index b038d00f7..3ddcd4e49 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -80,7 +80,8 @@ static inline uint32_t rdwr10_get_lba(uint8_t const command[])
// copy first to prevent mis-aligned access
uint32_t lba;
- memcpy(&lba, &p_rdwr10->lba, 4);
+ // use offsetof to avoid pointer to the odd/misaligned address
+ memcpy(&lba, (uint8_t*) p_rdwr10 + offsetof(scsi_write10_t, lba), 4);
// lba is in Big Endian format
return tu_ntohl(lba);
@@ -93,7 +94,8 @@ static inline uint16_t rdwr10_get_blockcount(uint8_t const command[])
// copy first to prevent mis-aligned access
uint16_t block_count;
- memcpy(&block_count, &p_rdwr10->block_count, 2);
+ // use offsetof to avoid pointer to the odd/misaligned address
+ memcpy(&block_count, (uint8_t*) p_rdwr10 + offsetof(scsi_write10_t, block_count), 2);
return tu_ntohs(block_count);
}