ui: avoid compiler warnings from unused clipboard info variable

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 <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
[AJB: fix merge conflict]
Signed-off-by: Alex Bennée <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
This commit is contained in:
Daniel P. Berrangé authored and Alex Bennée committed 2022-01-18 16:42:41 +00:00
1 parent 6621441db5
commit 70a54b0169
1 file changed
+1 -3
+1 -3
View File
@@ -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, &notify);
old = cbinfo[info->selection];
qemu_clipboard_info_unref(cbinfo[info->selection]);
cbinfo[info->selection] = qemu_clipboard_info_ref(info);
}