SHA256
1
0
forked from pool/qemu
qemu/0038-hw-usb-dev-mtp-Fix-GCC-9-build-warn.patch

43 lines
1.6 KiB
Diff
Raw Normal View History

From: Alistair Francis <Alistair.Francis@wdc.com>
Date: Sat, 4 May 2019 07:58:55 -0600
Subject: hw/usb/dev-mtp: Fix GCC 9 build warning
Fix this warning with GCC 9 on Fedora 30:
Accepting request 702352 from home:bfrogers:branches:Virtualization - Patch queue updated from git://github.com/openSUSE/qemu.git opensuse-4.0 * Patches renamed: 0036-util-qemu-sockets-Fix-GCC-9-build-w.patch -> 0036-sockets-avoid-string-truncation-war.patch 0039-linux-user-uname-Fix-GCC-9-build-wa.patch -> 0039-linux-user-avoid-string-truncation-.patch - Correct logic of which ipxe patches get included based on suse_version. We were wrongly excluding a gcc9 related patch for example - Switch to now upstreamed version of some patches * Patches renamed: 0036-util-qemu-sockets-Fix-GCC-9-build-w.patch -> 0036-sockets-avoid-string-truncation-war.patch 0039-linux-user-uname-Fix-GCC-9-build-wa.patch -> 0039-linux-user-avoid-string-truncation-.patch - Patch queue updated from git://github.com/openSUSE/qemu.git opensuse-4.0 - Create /usr/share/qemu/firmware and /etc/qemu/firmware directories in support of the firmware descriptor feature now in use as of libvirt v5.2 - Correct logic of which ipxe patches get included based on suse_version. We were wrongly excluding a gcc9 related patch for example - Switch to now upstreamed version of some patches * Patches renamed: 0036-util-qemu-sockets-Fix-GCC-9-build-w.patch -> 0036-sockets-avoid-string-truncation-war.patch 0039-linux-user-uname-Fix-GCC-9-build-wa.patch -> 0039-linux-user-avoid-string-truncation-.patch - Patch queue updated from git://github.com/openSUSE/qemu.git opensuse-4.0 - Create /usr/share/qemu/firmware and /etc/qemu/firmware directories in support of the firmware descriptor feature now in use as of libvirt v5.2 OBS-URL: https://build.opensuse.org/request/show/702352 OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=468
2019-05-11 17:08:13 +02:00
hw/usb/dev-mtp.c:1715:36: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
1715 | dataset->filename);
| ~~~~~~~^~~~~~~~~~
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Bruce Rogers <brogers@suse.com>
---
hw/usb/dev-mtp.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 99548b012d..8233beacab 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1711,9 +1711,22 @@ static void usb_mtp_write_metadata(MTPState *s, uint64_t dlen)
assert(!s->write_pending);
assert(p != NULL);
+/*
+ * We are about to access a packed struct. We are confident that the pointer
+ * address won't be unaligned, so we ignore GCC warnings.
+ */
+#if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) && QEMU_GNUC_PREREQ(9, 0)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
filename = utf16_to_str(MIN(dataset->length, filename_chars),
dataset->filename);
+#if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) && QEMU_GNUC_PREREQ(9, 0)
+#pragma GCC diagnostic pop
+#endif
+
if (strchr(filename, '/')) {
usb_mtp_queue_result(s, RES_PARAMETER_NOT_SUPPORTED, d->trans,
0, 0, 0, 0);