diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2018-10-16 18:09:38 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-11-05 15:09:54 +0100 |
commit | 1229e46d3cfe61ee0b11f08fbbc7530af1578637 (patch) | |
tree | b28c252d9bb6bd1715cc3f7be68f275d792b5ad3 /block/vhdx.h | |
parent | c317b646d752e97f64e97ba2145d8dfc55589c92 (diff) | |
download | qemu-1229e46d3cfe61ee0b11f08fbbc7530af1578637.zip qemu-1229e46d3cfe61ee0b11f08fbbc7530af1578637.tar.gz qemu-1229e46d3cfe61ee0b11f08fbbc7530af1578637.tar.bz2 |
block/vhdx: Don't take address of fields in packed structs
Taking the address of a field in a packed struct is a bad idea, because
it might not be actually aligned enough for that pointer type (and
thus cause a crash on dereference on some host architectures). Newer
versions of clang warn about this. Avoid the bug by not using the
"modify in place" byte swapping functions.
There are a few places where the in-place swap function is
used on something other than a packed struct field; we convert
those anyway, for consistency.
Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/vhdx.h')
-rw-r--r-- | block/vhdx.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/block/vhdx.h b/block/vhdx.h index 7003ab7..3a5f529 100644 --- a/block/vhdx.h +++ b/block/vhdx.h @@ -420,16 +420,16 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, static inline void leguid_to_cpus(MSGUID *guid) { - le32_to_cpus(&guid->data1); - le16_to_cpus(&guid->data2); - le16_to_cpus(&guid->data3); + guid->data1 = le32_to_cpu(guid->data1); + guid->data2 = le16_to_cpu(guid->data2); + guid->data3 = le16_to_cpu(guid->data3); } static inline void cpu_to_leguids(MSGUID *guid) { - cpu_to_le32s(&guid->data1); - cpu_to_le16s(&guid->data2); - cpu_to_le16s(&guid->data3); + guid->data1 = cpu_to_le32(guid->data1); + guid->data2 = cpu_to_le16(guid->data2); + guid->data3 = cpu_to_le16(guid->data3); } void vhdx_header_le_import(VHDXHeader *h); |