fix big-endian platforms after 6733401935

The NVMe byte-swap routines for big-endian platforms used memcpy() to
move the unaligned 64-bit value into a temp register to byte swap it.
Instead of introducing a dependency, manually byte-swap the values in
place.

Point hat:	me
This commit is contained in:
Chuck Tuffli 2021-01-08 14:36:37 -08:00
parent a82f07fc2e
commit e83fdf8bb3

View File

@ -2042,16 +2042,20 @@ static inline void
nvme_device_self_test_swapbytes(struct nvme_device_self_test_page *s __unused)
{
#if _BYTE_ORDER != _LITTLE_ENDIAN
uint64_t failing_lba;
uint32_t r;
uint8_t *tmp;
uint32_t r, i;
uint8_t b;
for (r = 0; r < 20; r++) {
s->result[r].poh = le64toh(s->result[r].poh);
s->result[r].nsid = le32toh(s->result[r].nsid);
/* Unaligned 64-bit loads fail on some architectures */
memcpy(&failing_lba, s->result[r].failing_lba, sizeof(failing_lba));
failing_lba = le64toh(failing_lba);
memcpy(s->result[r].failing_lba, &failing_lba, sizeof(failing_lba));
tmp = s->result[r].failing_lba;
for (i = 0; i < 4; i++) {
b = tmp[i];
tmp[i] = tmp[7-i];
tmp[7-i] = b;
}
}
#endif
}