[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/25] virtio-scsi: Fix build with gcc 9
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 09/25] virtio-scsi: Fix build with gcc 9 |
Date: |
Sat, 9 Mar 2019 08:48:02 +0100 |
From: Greg Kurz <address@hidden>
Build fails with gcc 9:
CC ppc64-softmmu/hw/scsi/virtio-scsi.o
hw/scsi/virtio-scsi.c: In function ‘virtio_scsi_do_tmf’:
hw/scsi/virtio-scsi.c:265:39: error: taking address of packed member of
‘struct virtio_scsi_ctrl_tmf_req’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
265 | virtio_tswap32s(VIRTIO_DEVICE(s), &req->req.tmf.subtype);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
All the fields in struct virtio_scsi_ctrl_tmf_req are naturally aligned,
so we could in theory drop QEMU_PACKED. Unfortunately, the header file
is imported from linux which already has the packed attribute. Trying to
fix that in the update-linux-headers.sh script is likely to produce
ugliness. Turn the call to virtio_tswap32s() into an assignment instead.
Signed-off-by: Greg Kurz <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/virtio-scsi.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index ce99d28..839f120 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -262,7 +262,13 @@ static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq
*req)
/* Here VIRTIO_SCSI_S_OK means "FUNCTION COMPLETE". */
req->resp.tmf.response = VIRTIO_SCSI_S_OK;
- virtio_tswap32s(VIRTIO_DEVICE(s), &req->req.tmf.subtype);
+ /*
+ * req->req.tmf has the QEMU_PACKED attribute. Don't use virtio_tswap32s()
+ * to avoid compiler errors.
+ */
+ req->req.tmf.subtype =
+ virtio_tswap32(VIRTIO_DEVICE(s), req->req.tmf.subtype);
+
switch (req->req.tmf.subtype) {
case VIRTIO_SCSI_T_TMF_ABORT_TASK:
case VIRTIO_SCSI_T_TMF_QUERY_TASK:
--
1.8.3.1
- [Qemu-devel] [PULL 11/25] lsi: check if SIGP bit is already set in Wait reselect, (continued)
- [Qemu-devel] [PULL 11/25] lsi: check if SIGP bit is already set in Wait reselect, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 20/25] lsi: use ldn_le_p()/stn_le_p(), Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 17/25] oslib-posix: Ignore fcntl("/dev/null", F_SETFL, O_NONBLOCK) failure, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 16/25] accel: Allow to build QEMU without TCG or KVM support, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 24/25] lsi: return dfifo value, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 10/25] lsi: implement basic SBCL functionality, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 06/25] configure: Enable werror for git worktrees, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 18/25] configure: Disable W^X on OpenBSD, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 25/25] exec: streamline flatview_add_to_dispatch, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 22/25] lsi: use enum type for s->msg_action, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 09/25] virtio-scsi: Fix build with gcc 9,
Paolo Bonzini <=
- [Qemu-devel] [PULL 23/25] lsi: use SCSI phase names instead of numbers in trace, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 05/25] contrib/elf2dmp: add kernel start address checking, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 13/25] build: get rid of target-obj-y, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 15/25] build: clean trace/generated-helpers.c, Paolo Bonzini, 2019/03/09
- [Qemu-devel] [PULL 21/25] lsi: use enum type for s->waiting, Paolo Bonzini, 2019/03/09
- Re: [Qemu-devel] [PULL 00/25] Misc patches for QEMU 4.0 soft freeze, Peter Maydell, 2019/03/10