All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	qemu-devel@nongnu.org, "Willian Rampazzo" <willianr@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH 2/6] ui/clipboard: Don't use g_autoptr just to free a variable
Date: Wed, 3 Nov 2021 14:58:49 +0000	[thread overview]
Message-ID: <YYKjqVGr4QxB6wax@redhat.com> (raw)
In-Reply-To: <20211103144844.1285634-3-jsnow@redhat.com>

On Wed, Nov 03, 2021 at 10:48:40AM -0400, John Snow wrote:
> Clang doesn't recognize that the variable is being "used" and will emit
> a warning:
> 
>   ../ui/clipboard.c:47:34: error: variable 'old' set but not used [-Werror,-Wunused-but-set-variable]
>       g_autoptr(QemuClipboardInfo) old = NULL;
>                                  ^
>   1 error generated.
> 
> OK, fine. Just do things the old way.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  ui/clipboard.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/ui/clipboard.c b/ui/clipboard.c
> index d7b008d62a..d53576b0f6 100644
> --- a/ui/clipboard.c
> +++ b/ui/clipboard.c
> @@ -44,13 +44,14 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *peer,
>  
>  void qemu_clipboard_update(QemuClipboardInfo *info)
>  {
> -    g_autoptr(QemuClipboardInfo) old = NULL;
> +    QemuClipboardInfo *old = NULL;
>      assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT);
>  
>      notifier_list_notify(&clipboard_notifiers, info);
>  
>      old = cbinfo[info->selection];
>      cbinfo[info->selection] = qemu_clipboard_info_ref(info);
> +    g_free(old);
>  }

Surely the right answer here is to get rid of the variable
entirely as it isn't adding value

   g_free(cbinfo[info->selection]);


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  parent reply	other threads:[~2021-11-03 15:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 14:48 [PATCH 0/6] tests/docker: Update Fedora containers John Snow
2021-11-03 14:48 ` [PATCH 1/6] spice: Update QXLInterface for spice >= 0.15.0 John Snow
2021-11-04  6:47   ` Gerd Hoffmann
2021-11-03 14:48 ` [PATCH 2/6] ui/clipboard: Don't use g_autoptr just to free a variable John Snow
2021-11-03 14:57   ` Marc-André Lureau
2021-11-03 14:58   ` Daniel P. Berrangé [this message]
2021-11-03 15:30     ` John Snow
2021-11-03 14:48 ` [PATCH 3/6] docker: update fedora container to Fedora 34 John Snow
2021-11-03 14:52   ` Philippe Mathieu-Daudé
2021-11-03 16:55   ` Willian Rampazzo
2021-11-03 14:48 ` [PATCH 4/6] docker: update Fedora-based cross-compiler containers " John Snow
2021-11-03 14:52   ` Philippe Mathieu-Daudé
2021-11-03 16:56   ` Willian Rampazzo
2021-11-03 14:48 ` [PATCH 5/6] docker: update 'python' dockerfile to use Fedora registry John Snow
2021-11-03 14:55   ` Philippe Mathieu-Daudé
2021-11-03 16:57   ` Willian Rampazzo
2021-11-03 14:48 ` [PATCH 6/6] docker: Add Fedora 35 container John Snow
2021-11-03 16:59   ` Daniel P. Berrangé
2021-11-03 17:51     ` John Snow
2021-11-03 18:53       ` Philippe Mathieu-Daudé
2021-11-24 12:19 ` [PATCH 0/6] tests/docker: Update Fedora containers Daniel P. Berrangé
2021-11-24 12:34   ` Philippe Mathieu-Daudé
2021-11-24 12:51     ` Alex Bennée
2021-11-24 12:59       ` 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=YYKjqVGr4QxB6wax@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=f4bug@amsat.org \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    --cc=willianr@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.