qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Daniel P. Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH 1/2] ui: avoid compiler warnings from unused clipboard info variable
Date: Tue, 23 Nov 2021 14:50:57 +0100	[thread overview]
Message-ID: <06d7e1c4-d267-04c7-35ca-18f677d1ac3c@linaro.org> (raw)
In-Reply-To: <20211123134302.45741-2-berrange@redhat.com>

On 11/23/21 2:43 PM, Daniel P. Berrangé wrote:
> 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.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   ui/clipboard.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

> 
> diff --git a/ui/clipboard.c b/ui/clipboard.c
> index d7b008d62a..7672058e84 100644
> --- a/ui/clipboard.c
> +++ b/ui/clipboard.c
> @@ -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);
>   }
>   
> 



  reply	other threads:[~2021-11-23 13:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 13:43 [PATCH 0/2 for 6.2] Fix compiler warnings on Fedora 35 / CLang Daniel P. Berrangé
2021-11-23 13:43 ` [PATCH 1/2] ui: avoid compiler warnings from unused clipboard info variable Daniel P. Berrangé
2021-11-23 13:50   ` Richard Henderson [this message]
2021-11-23 13:59   ` Philippe Mathieu-Daudé
2021-11-24 13:04   ` Philippe Mathieu-Daudé
2021-11-23 13:43 ` [PATCH 2/2] spice: Update QXLInterface for spice >= 0.15.0 Daniel P. Berrangé
2021-11-23 13:49   ` Richard Henderson
2021-11-24 13:07   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06d7e1c4-d267-04c7-35ca-18f677d1ac3c@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).