From nobody Tue Feb 10 15:46:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1613152627; cv=none; d=zohomail.com; s=zohoarc; b=UOZMZzn4F/LrOjsez/ta9fbty7HmxwD0DjqyGRzLTuDzBewJlkiF12Q1TqSpQuuzE119FrKRTeAU4Zegcm8LX8Xey7NOl0RPdhoY1JBPlyW+1e5yNlgMiXC6TPDT4nW/pGYZGO4HJCY/v7lHmFBmBjuRRWA2udbN02/n69PU4Cw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613152627; 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=SnbwDTb9JS5dqjUjUFae4lQR7ROWDr10IpjFgvGIgRY=; b=FzXfGT1wQvqzLiS9BrVZjeGieZvJratXaUcPu61v9HPgWpcSRFYzoC8I2+cluPLu/65s0SDKc3MJ+syqPjhXXXWHLYGTwz9nZXqJCEoLH9n27N3WQ1l1R1qq7MOhnoP9HVAKxUndCX87uAc02t94FoPsL72L44fYPyqOKPQGIXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613152626853962.4292708551344; Fri, 12 Feb 2021 09:57:06 -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-443-LOqDuZZmML-rEvGPsmhb9g-1; Fri, 12 Feb 2021 12:56:57 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EFF3109EC22; Fri, 12 Feb 2021 17:56:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE6F45D9DB; Fri, 12 Feb 2021 17:56:30 +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 A3B3F57DF9; Fri, 12 Feb 2021 17:56:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11CHuTv7010798 for ; Fri, 12 Feb 2021 12:56:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id DADED68D2F; Fri, 12 Feb 2021 17:56:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F96268D54 for ; Fri, 12 Feb 2021 17:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613152620; 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=SnbwDTb9JS5dqjUjUFae4lQR7ROWDr10IpjFgvGIgRY=; b=VxOnOtY5hFFMCmlBRjwLDLf3K6s6/pWAyQF2Q4/cp+q5Ok05djnUc+qywcTfv4aR52Yixx yeFoYYjE+yVgYjMaHFePOJVINNlt67/Au4RF9GD8+guNKF2bnBDo/z3hCk89Zp0DzAjAOJ KPRYY1N31OkyUid5gO79MUlH2iM2DBg= X-MC-Unique: LOqDuZZmML-rEvGPsmhb9g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/25] virNetServerClientPreExecRestart: Refactor memory cleanup Date: Fri, 12 Feb 2021 18:55:19 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.14 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" Switch to using the 'g_auto*' helpers. Signed-off-by: Peter Krempa --- src/rpc/virnetserverclient.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 4d01e87e21..0789ad9154 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -585,15 +585,14 @@ virNetServerClientPtr virNetServerClientNewPostExecRe= start(virNetServerPtr srv, virJSONValuePtr virNetServerClientPreExecRestart(virNetServerClientPtr cli= ent) { - virJSONValuePtr object =3D virJSONValueNewObject(); - virJSONValuePtr child; + g_autoptr(virJSONValue) object =3D virJSONValueNewObject(); + g_autoptr(virJSONValue) sock =3D NULL; + g_autoptr(virJSONValue) priv =3D NULL; virObjectLock(client); - if (virJSONValueObjectAppendNumberUlong(object, "id", - client->id) < 0) + if (virJSONValueObjectAppendNumberUlong(object, "id", client->id) < 0) goto error; - if (virJSONValueObjectAppendNumberInt(object, "auth", client->auth) < = 0) goto error; if (virJSONValueObjectAppendBoolean(object, "auth_pending", client->au= th_pending) < 0) @@ -608,28 +607,25 @@ virJSONValuePtr virNetServerClientPreExecRestart(virN= etServerClientPtr client) client->conn_time) < 0) goto error; - if (!(child =3D virNetSocketPreExecRestart(client->sock))) + if (!(sock =3D virNetSocketPreExecRestart(client->sock))) goto error; - if (virJSONValueObjectAppend(object, "sock", child) < 0) { - virJSONValueFree(child); + if (virJSONValueObjectAppend(object, "sock", sock) < 0) goto error; - } + sock =3D NULL; - if (!(child =3D client->privateDataPreExecRestart(client, client->priv= ateData))) + if (!(priv =3D client->privateDataPreExecRestart(client, client->priva= teData))) goto error; - if (virJSONValueObjectAppend(object, "privateData", child) < 0) { - virJSONValueFree(child); + if (virJSONValueObjectAppend(object, "privateData", priv) < 0) goto error; - } + priv =3D NULL; virObjectUnlock(client); - return object; + return g_steal_pointer(&object); error: virObjectUnlock(client); - virJSONValueFree(object); return NULL; } --=20 2.29.2