From nobody Mon Feb 9 08:55:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613167685; cv=none; d=zohomail.com; s=zohoarc; b=hX3BPTEwOLQDUZKMR2t6Z1TW2P+r4azz2xpPKFYGnqIqBl6ZdXnNMUC3shJTGKTnE0q7PrABgU0YEyGCNr+++WDFjvW10cik8h/3oQIlDxjohiQlkrceFkPHOSjn5YcUlxD3G+cwEEKi+F1j4cf8rj+q3FqPcUlKrwBIE7c16vc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167685; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=T5yKy7PyP13MeE4GJx0FHXMKKm5JIth1MSbeDg1Yyn4=; b=VTZzvhyRX/09B4lhLw/GNyQKkyf6VSTz+IYeND377ywMCYSJEO9w1AMxzuiEsrSj/esnhFho8pYHIosMhyGKIgg41gJp6mVrU4rF/UlWMMwK2xIUtmswDa3+tdeL5Ng95ex87s0zjCVnxpAML4u/dBN4PM1eEFC1GkV9QVpQdeQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613167685181317.8639866825238; Fri, 12 Feb 2021 14:08:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-RZkj-Yc7OEy2RDvVSvbUpA-1; Fri, 12 Feb 2021 17:07:50 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 146B580197A; Fri, 12 Feb 2021 22:07:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E76AD60BE5; Fri, 12 Feb 2021 22:07:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B26501809C92; Fri, 12 Feb 2021 22:07:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11CM7N6G006162 for ; Fri, 12 Feb 2021 17:07:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id D12471002388; Fri, 12 Feb 2021 22:07:23 +0000 (UTC) Received: from vhost2.router.laine.org (ovpn-112-48.phx2.redhat.com [10.3.112.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 987101001E73 for ; Fri, 12 Feb 2021 22:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167681; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=T5yKy7PyP13MeE4GJx0FHXMKKm5JIth1MSbeDg1Yyn4=; b=fDxvYPTtAUAugXRKz4ZoQoRriKkzv5sn2pGtR1yCXkv7JUSUQIcAuLuUYiZHNZthTkCXba a5PGpgYI8ghv11Bj0/pfKNwERqARRB2DFB2UYNDkVhnsH2Vq3CjSH9i3OQuZ5jJSLsm1p7 qrmUT8CZbNNv7tv1nI1ZS+QyivzQjuc= X-MC-Unique: RZkj-Yc7OEy2RDvVSvbUpA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 6/9] esx: reorder code to avoid need to VIR_FREE mimeType Date: Fri, 12 Feb 2021 17:07:14 -0500 Message-Id: <20210212220717.910294-7-laine@redhat.com> In-Reply-To: <20210212220717.910294-1-laine@redhat.com> References: <20210212220717.910294-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" mimeType is initialized to NULL, and then only set in one place, just before a check (not involving mimeType) that then VIR_FREEs mimeType if it fails. If we just reorder the code to do the check prior to setting mimeType, then there won't be any need to VIR_FREE(mimeType) on failure (because it will already be empty/NULL). Signed-off-by: Laine Stump --- src/esx/esx_driver.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 47873c0d54..2d010096a5 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2374,12 +2374,10 @@ esxDomainScreenshot(virDomainPtr domain, virStreamP= tr stream, =20 url =3D virBufferContentAndReset(&buffer); =20 - mimeType =3D g_strdup("image/png"); - - if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0) { - VIR_FREE(mimeType); + if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0) goto cleanup; - } + + mimeType =3D g_strdup("image/png"); =20 cleanup: =20 --=20 2.29.2