From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7D8AC433EF for ; Wed, 3 Nov 2021 15:33:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49DE360FC2 for ; Wed, 3 Nov 2021 15:33:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49DE360FC2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:43746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miIGi-00044x-CF for qemu-devel@archiver.kernel.org; Wed, 03 Nov 2021 11:33:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miIDZ-0005lG-4f for qemu-devel@nongnu.org; Wed, 03 Nov 2021 11:30:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miIDW-0003Ed-Lx for qemu-devel@nongnu.org; Wed, 03 Nov 2021 11:30:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635953422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wYprP1yN5UMPkW+SR9gZo4iIeTUi7AxA3GWMYynjxi0=; b=EgOWFWoty8C/t/n7p/tXgW628DssnbWwEI+RkJDYQFZZY60gXvsnokahFvSLBciJg1VEl1 Mml6FMNp+KomTOfBsiOh0qaD5wFn0FV74f1j/N2veJV8s3Jk7uUm/Dvv58xMLC01ogBZej 3WNTy1qdmD3lSRMuxMIm9t9V4hLAK8U= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-66-4NLEniFJPPKmwjuJp1u8qQ-1; Wed, 03 Nov 2021 11:30:20 -0400 X-MC-Unique: 4NLEniFJPPKmwjuJp1u8qQ-1 Received: by mail-vk1-f197.google.com with SMTP id p144-20020a1fbf96000000b002eb82e0e8cfso1058544vkf.18 for ; Wed, 03 Nov 2021 08:30:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wYprP1yN5UMPkW+SR9gZo4iIeTUi7AxA3GWMYynjxi0=; b=pU3x3U6jbsMH6X6MAxa8dJV1tWRreke08JE6VO/ZQ9+UvkkP2BJ+xkMSW0TUJC75yW MQ111t06OLfZnPZuHTSl7qitxAzhMq34UJbYJWAWBNfKWMqSnxDBK65NrQQJGq18+wTk VI66c0rfPEpXU3coFW/PC5kZ64dyTB5T0APCMJhWr35hifzgLjEialamuWcWNwHs9L3X vMHZa5psHL9tyG7Mp1ItXsbb3zdpnDhEQB1tGtB+F9/ZGjDgo1M+guXsGDSnl8d5S6NL FYwj+wR3INtwPCJtelctZCaYU3aLWAlHr7PkQXP0uGylwUH126rbI+zjp/87eHl/mX4G 2XEQ== X-Gm-Message-State: AOAM530MHo8W4mQwxl2lNKrCBUpp/YxPJRxCfSpF5J646VhBHFMKMzyI No75xnRRKV0IWPGfpkz8tPVOeSNq1PDr0mYfoz9/CyI9koxjw6mM6dwW6xytr7bNwsNRn9jLo6c U5rgumfLMYup+hZFu5JcGLqC5eqO7sv0= X-Received: by 2002:a05:6102:e0d:: with SMTP id o13mr35103817vst.13.1635953420183; Wed, 03 Nov 2021 08:30:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3nWrk9TCgJdcVYaMcBVDAADz/5DHJM+WifNADHF4+dEGZdbr2RD0fxqWpHQwA4Wuwp/jilMnos/YC3GCbshc= X-Received: by 2002:a05:6102:e0d:: with SMTP id o13mr35103792vst.13.1635953420047; Wed, 03 Nov 2021 08:30:20 -0700 (PDT) MIME-Version: 1.0 References: <20211103144844.1285634-1-jsnow@redhat.com> <20211103144844.1285634-3-jsnow@redhat.com> In-Reply-To: From: John Snow Date: Wed, 3 Nov 2021 11:30:09 -0400 Message-ID: Subject: Re: [PATCH 2/6] ui/clipboard: Don't use g_autoptr just to free a variable To: =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="00000000000078ad5105cfe4167a" Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , Wainer dos Santos Moschetta , qemu-devel , Willian Rampazzo , Gerd Hoffmann , =?UTF-8?B?QWxleCBCZW5uw6ll?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000078ad5105cfe4167a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Nov 3, 2021 at 10:59 AM Daniel P. Berrang=C3=A9 wrote: > 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 =3D NULL; > > ^ > > 1 error generated. > > > > OK, fine. Just do things the old way. > > > > Signed-off-by: John Snow > > --- > > 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 =3D NULL; > > + QemuClipboardInfo *old =3D NULL; > > assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT); > > > > notifier_list_notify(&clipboard_notifiers, info); > > > > old =3D cbinfo[info->selection]; > > cbinfo[info->selection] =3D 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]); > Alrighty, I'll clean it up. Respin pending comments on 1/6 and 6/6. --js --00000000000078ad5105cfe4167a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Nov 3, 2021 at 10:59 AM Danie= l P. Berrang=C3=A9 <berrange@redh= at.com> wrote:
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:
>
>=C2=A0 =C2=A0../ui/clipboard.c:47:34: error: variable 'old' set= but not used [-Werror,-Wunused-but-set-variable]
>=C2=A0 =C2=A0 =C2=A0 =C2=A0g_autoptr(QemuClipboardInfo) old =3D NULL; >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
>=C2=A0 =C2=A01 error generated.
>
> OK, fine. Just do things the old way.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>=C2=A0 ui/clipboard.c | 3 ++-
>=C2=A0 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,
>=C2=A0
>=C2=A0 void qemu_clipboard_update(QemuClipboardInfo *info)
>=C2=A0 {
> -=C2=A0 =C2=A0 g_autoptr(QemuClipboardInfo) old =3D NULL;
> +=C2=A0 =C2=A0 QemuClipboardInfo *old =3D NULL;
>=C2=A0 =C2=A0 =C2=A0 assert(info->selection < QEMU_CLIPBOARD_SELE= CTION__COUNT);
>=C2=A0
>=C2=A0 =C2=A0 =C2=A0 notifier_list_notify(&clipboard_notifiers, inf= o);
>=C2=A0
>=C2=A0 =C2=A0 =C2=A0 old =3D cbinfo[info->selection];
>=C2=A0 =C2=A0 =C2=A0 cbinfo[info->selection] =3D qemu_clipboard_info= _ref(info);
> +=C2=A0 =C2=A0 g_free(old);
>=C2=A0 }

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

=C2=A0 =C2=A0g_free(cbinfo[info->selection]);

<= /div>
Alrighty, I'll clean it up.

Respin p= ending comments on 1/6 and 6/6.

--js
--00000000000078ad5105cfe4167a--