From 70a54b01693eda3c61814b05d699aba41015ac48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 5 Jan 2022 13:49:36 +0000 Subject: [PATCH] ui: avoid compiler warnings from unused clipboard info variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé [AJB: fix merge conflict] Signed-off-by: Alex Bennée Message-Id: <20211215141949.3512719-2-berrange@redhat.com> Message-Id: <20220105135009.1584676-2-alex.bennee@linaro.org> --- ui/clipboard.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ui/clipboard.c b/ui/clipboard.c index 82572ea116..5f15cf853d 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -62,13 +62,11 @@ void qemu_clipboard_update(QemuClipboardInfo *info) .type = QEMU_CLIPBOARD_UPDATE_INFO, .info = info, }; - g_autoptr(QemuClipboardInfo) old = NULL; - assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT); notifier_list_notify(&clipboard_notifiers, ¬ify); - old = cbinfo[info->selection]; + qemu_clipboard_info_unref(cbinfo[info->selection]); cbinfo[info->selection] = qemu_clipboard_info_ref(info); }