Fix compiler warnings on Fedora 35 / CLang
cover Fix compiler warnings on Fedora 35 / CLang
Current QEMU git master caused compiler warnings on Fedora 35 when using CLang. It is expected to affect any distro with CLang >= 13.0.0
Since QEMU builds with -Werror by default we should fix these warnings before release, as this version of QEMU will increasing trigger the warnings as more distros pull in CLang >= 13.0.0
The spice patch was from John's series at
https://lists.gnu.org/archive/html/qemu-devel/2021-11/msg01056.html
I pulled out this patch on its own as the above series isn't likely suitable for merging as a whole during freeze.
The clipboard patch is an alternative impl to what John posted.
Daniel P. Berrangé (1):
ui: avoid compiler warnings from unused clipboard info variable
John Snow (1):
spice: Update QXLInterface for spice >= 0.15.0
hw/display/qxl.c | 14 +++++++++++++- include/ui/qemu-spice.h | 6 ++++++ ui/clipboard.c | 3 +-- ui/spice-display.c | 11 +++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-)
Signature · 1 line
2.33.1
PATCH 2/2 spice: Update QXLInterface for spice >= 0.15.0
From: John Snow <[email protected]>
spice updated the spelling (and arguments) of "attache_worker" in 0.15.0. Update QEMU to match, preventing -Wdeprecated-declarations compilations from reporting build errors.
See also:
https://gitlab.freedesktop.org/spice/spice/-/commit/974692bda1e77af92b71ed43b022439448492cb9
--- hw/display/qxl.c | 14 +++++++++++++- include/ui/qemu-spice.h | 6 ++++++ ui/spice-display.c | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)
hw/display/qxl.c +13 -1
@@ -517,13 +517,20 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)/* spice display interface callbacks */ -static void interface_attach_worker (QXLInstance *sin,QXLWorker *qxl_worker) +static void interface_attached_worker (QXLInstance *sin) {PCIQXLDevice *qxl =container_of (sin, PCIQXLDevice, ssd.qxl);trace_qxl_interface_attach_worker (qxl->id); } +#if !(SPICE_HAS_ATTACHED_WORKER ) +static void interface_attach_worker (QXLInstance *sin,QXLWorker *qxl_worker) +{ +interface_attached_worker (sin); +} +#endif +static void interface_set_compression_level (QXLInstance *sin,int level) {PCIQXLDevice *qxl =container_of (sin, PCIQXLDevice, ssd.qxl);
@@ -1131,7 +1138,12 @@ static const QXLInterface qxl_interface = { .base.major_version = SPICE_INTERFACE_QXL_MAJOR, .base.minor_version =SPICE_INTERFACE_QXL_MINOR , +#if SPICE_HAS_ATTACHED_WORKER + .attached_worker = interface_attached_worker, +#else .attache_worker = interface_attach_worker, +#endif + .set_compression_level = interface_set_compression_level, #if SPICE_NEEDS_SET_MM_TIME .set_mm_time = interface_set_mm_time,
include/ui/qemu-spice.h +6 -0
@@ -40,6 +40,12 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,#define SPICE_NEEDS_SET_MM_TIME 0#endif +#if defined(SPICE_SERVER_VERSION ) && (SPICE_SERVER_VERSION >=0x000f00 ) +#define SPICE_HAS_ATTACHED_WORKER 1 +#else +#define SPICE_HAS_ATTACHED_WORKER 0 +#endif +#else /* CONFIG_SPICE */ #include "qemu/error-report.h"
ui/spice-display.c +11 -0
@@ -500,10 +500,17 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)/* spice display interface callbacks */ +#if SPICE_HAS_ATTACHED_WORKER +static void interface_attached_worker (QXLInstance *sin) +{ +/* nothing to do */ +} +#else static void interface_attach_worker (QXLInstance *sin,QXLWorker *qxl_worker) {/* nothing to do */ } +#endif static void interface_set_compression_level (QXLInstance *sin,int level) {
@@ -702,7 +709,11 @@ static const QXLInterface dpy_interface = { .base.major_version = SPICE_INTERFACE_QXL_MAJOR, .base.minor_version =SPICE_INTERFACE_QXL_MINOR , +#if SPICE_HAS_ATTACHED_WORKER + .attached_worker = interface_attached_worker, +#else .attache_worker = interface_attach_worker, +#endif .set_compression_level = interface_set_compression_level, #if SPICE_NEEDS_SET_MM_TIME .set_mm_time = interface_set_mm_time,
Signature · 1 line
2.33.1
PATCH 1/2 ui: avoid compiler warnings from unused clipboard info variable
In reply to Daniel P. BerrangéWith latest clang 13.0.0 we get
../ui/clipboard.c:47:34: error: variable 'old' set but not used [-Werror,-Wunused-but-set-variable]
g_autoptr(QemuClipboardInfo) old = NULL;
^The compiler can't tell that we only declared this variable in order to get the side effect of free'ing it when out of scope.
This pattern is a little dubious for a use of g_autoptr, so rewrite the code to avoid it.
--- ui/clipboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
ui/clipboard.c +1 -2
@@ -44,12 +44,11 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *peer,void qemu_clipboard_update (QemuClipboardInfo *info) { -g_autoptr (QemuClipboardInfo) old =NULL ;assert (info->selection <QEMU_CLIPBOARD_SELECTION__COUNT );notifier_list_notify (&clipboard_notifiers, info); - old = cbinfo[info->selection]; +qemu_clipboard_info_unref (cbinfo[info->selection]); cbinfo[info->selection] =qemu_clipboard_info_ref (info); }
Signature · 1 line
2.33.1
Re: [PATCH 2/2] spice: Update QXLInterface for spice >= 0.15.0
In reply to Daniel P. BerrangéQuoted 9 lines · Daniel P. Berrangé
From: John Snow <[email protected]>
spice updated the spelling (and arguments) of "
attache_worker" in 0.15.0. Update QEMU to match, preventing -Wdeprecated-declarations compilations from reporting build errors.See also:
https://gitlab.freedesktop.org/spice/spice/-/commit/974692bda1e77af92b71ed43b022439448492cb9
Quoted 6 lines
Signed-off-by John Snow <[email protected]>--- hw/display/qxl.c | 14 +++++++++++++- include/ui/qemu-spice.h | 6 ++++++ ui/spice-display.c | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)
r~
Re: [PATCH 1/2] ui: avoid compiler warnings from unused clipboard info variable
In reply to Daniel P. BerrangéQuoted 9 lines · Daniel P. Berrangé
With latest clang 13.0.0 we get
../ui/clipboard.c:47:34: error: variable 'old' set but not used [-Werror,-Wunused-but-set-variable]g_autoptr(QemuClipboardInfo) old = NULL; ^The compiler can't tell that we only declared this variable in order to get the side effect of free'ing it when out of scope.
Quoted 7 lines
This pattern is a little dubious for a use of
g_autoptr, so rewrite the code to avoid it.Signed-off-by Daniel P. Berrangé <[email protected]>--- ui/clipboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
r~
Quoted 20 lines
ui/clipboard.c +1
-2@@ -44,12 +44,11 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *peer,void qemu_clipboard_update (QemuClipboardInfo *info) { -g_autoptr (QemuClipboardInfo) old =NULL ;assert (info->selection <QEMU_CLIPBOARD_SELECTION__COUNT );notifier_list_notify (&clipboard_notifiers, info); - old = cbinfo[info->selection]; +qemu_clipboard_info_unref (cbinfo[info->selection]); cbinfo[info->selection] =qemu_clipboard_info_ref (info); }
Re: [PATCH 1/2] ui: avoid compiler warnings from unused clipboard info variable
In reply to Daniel P. BerrangéQuoted 9 lines · Daniel P. Berrangé
With latest clang 13.0.0 we get
../ui/clipboard.c:47:34: error: variable 'old' set but not used [-Werror,-Wunused-but-set-variable]g_autoptr(QemuClipboardInfo) old = NULL; ^The compiler can't tell that we only declared this variable in order to get the side effect of free'ing it when out of scope.
Quoted 7 lines
This pattern is a little dubious for a use of
g_autoptr, so rewrite the code to avoid it.Signed-off-by Daniel P. Berrangé <[email protected]>--- ui/clipboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Re: [PATCH 1/2] ui: avoid compiler warnings from unused clipboard info variable
In reply to Daniel P. BerrangéQuoted 9 lines · Daniel P. Berrangé
With latest clang 13.0.0 we get
../ui/clipboard.c:47:34: error: variable 'old' set but not used [-Werror,-Wunused-but-set-variable]g_autoptr(QemuClipboardInfo) old = NULL; ^The compiler can't tell that we only declared this variable in order to get the side effect of free'ing it when out of scope.
Quoted 7 lines
This pattern is a little dubious for a use of
g_autoptr, so rewrite the code to avoid it.Signed-off-by Daniel P. Berrangé <[email protected]>--- ui/clipboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Re: [PATCH 2/2] spice: Update QXLInterface for spice >= 0.15.0
In reply to Daniel P. BerrangéQuoted 10 lines · Daniel P. Berrangé
From: John Snow <[email protected]>
spice updated the spelling (and arguments) of "
attache_worker" in 0.15.0. Update QEMU to match, preventing -Wdeprecated-declarations compilations from reporting build errors.See also:
https://gitlab.freedesktop.org/spice/spice/-/commit/974692bda1e77af92b71ed43b022439448492cb9Signed-off-by John Snow <[email protected]>
?Signed-off-by: Daniel P. Berrangé <[email protected]>?
Quoted 5 lines
--- hw/display/qxl.c | 14 +++++++++++++- include/ui/qemu-spice.h | 6 ++++++ ui/spice-display.c | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)