From nobody Tue Feb 10 07:41:31 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=1613152582; cv=none; d=zohomail.com; s=zohoarc; b=PkQfckYfVQmmV7TVph0dZBz9SDSjHMZgTUqyLViTMtax6d3kLuSALvvOHruku9cFpuENZJpw3SS+8UfTleVsbf828L7bfeRl6lzvX5dI3bJbIziqAjRpBXoXdXqVDJWf/bm8AM459dmNBMyPp8k97p3W2MhebVjPXUrbrVH8WFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613152582; 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=S/UOm1ueGbXM1f9eRhYNC8Ah8eupDwCLTRfT0FNqgvU=; b=SwppE/YBa2WfwXk2KfvLSZ0ZQv0X/IejgopRWGqpDzqzsHz35ail2LfHmMdbwhPb6SQ1cyuS+MoI9Zs46gBOu01eGqnfUsMmz5g0Gy+6QXshRnVclPfEr/86jnAkj27unKQOKA8y9y90xK2JglfMk2VvKEDM/zv1oMBuRpBI6XM= 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 1613152581601717.1223217170369; Fri, 12 Feb 2021 09:56:21 -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-94-Vkej7Ly5O_Cqrhd6lrpkqg-1; Fri, 12 Feb 2021 12:56:14 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 017C8BBEE2; Fri, 12 Feb 2021 17:56:09 +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 D0062757F9; Fri, 12 Feb 2021 17:56:08 +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 95AEF1809C91; Fri, 12 Feb 2021 17:56:08 +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 11CHtq7P010568 for ; Fri, 12 Feb 2021 12:55:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id BE5C167CD0; Fri, 12 Feb 2021 17:55:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2279367CC5 for ; Fri, 12 Feb 2021 17:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613152577; 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=S/UOm1ueGbXM1f9eRhYNC8Ah8eupDwCLTRfT0FNqgvU=; b=OlHhrTxxNtyvBHO+fmcOshjfbneNpIAslYbwDDNWOeTe93cVhy+NmTVNp1NCXg9m5o1/EW 3wmc9nXftzL+EJtF5Ce2OgroIpW8rdmAWDFMAMa8fO7xAPDjvGZ27QR3fz49WdZFA8FQvG xSzSBTauSMVIqUUbuleRjtWoqhOpUo0= X-MC-Unique: Vkej7Ly5O_Cqrhd6lrpkqg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/25] virLogHandlerPreExecRestart: Refactor memory cleanup Date: Fri, 12 Feb 2021 18:55:16 +0100 Message-Id: <726fefce944a5bb90a5f44cf09738462b8d02f68.1613152441.git.pkrempa@redhat.com> 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.11 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/logging/log_handler.c | 42 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index a77c1e0250..cacf9584cd 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -608,56 +608,48 @@ virLogHandlerDomainAppendLogFile(virLogHandlerPtr han= dler, virJSONValuePtr virLogHandlerPreExecRestart(virLogHandlerPtr handler) { - virJSONValuePtr ret =3D virJSONValueNewObject(); - virJSONValuePtr files; + g_autoptr(virJSONValue) ret =3D virJSONValueNewObject(); + g_autoptr(virJSONValue) files =3D virJSONValueNewArray(); size_t i; char domuuid[VIR_UUID_STRING_BUFLEN]; - files =3D virJSONValueNewArray(); - - if (virJSONValueObjectAppend(ret, "files", files) < 0) { - virJSONValueFree(files); - goto error; - } - for (i =3D 0; i < handler->nfiles; i++) { - virJSONValuePtr file =3D virJSONValueNewObject(); - - if (virJSONValueArrayAppend(files, file) < 0) { - virJSONValueFree(file); - goto error; - } + g_autoptr(virJSONValue) file =3D virJSONValueNewObject(); if (virJSONValueObjectAppendNumberInt(file, "pipefd", handler->files[i]->pipefd) <= 0) - goto error; + return NULL; if (virJSONValueObjectAppendString(file, "path", virRotatingFileWriterGetPath(ha= ndler->files[i]->file)) < 0) - goto error; + return NULL; if (virJSONValueObjectAppendString(file, "driver", handler->files[i]->driver) < 0) - goto error; + return NULL; if (virJSONValueObjectAppendString(file, "domname", handler->files[i]->domname) < 0) - goto error; + return NULL; virUUIDFormat(handler->files[i]->domuuid, domuuid); if (virJSONValueObjectAppendString(file, "domuuid", domuuid) < 0) - goto error; + return NULL; if (virSetInherit(handler->files[i]->pipefd, true) < 0) { virReportSystemError(errno, "%s", _("Cannot disable close-on-exec flag")); - goto error; + return NULL; } + + if (virJSONValueArrayAppend(files, file) < 0) + return NULL; + file =3D NULL; } - return ret; + if (virJSONValueObjectAppend(ret, "files", files) < 0) + return NULL; + files =3D NULL; - error: - virJSONValueFree(ret); - return NULL; + return g_steal_pointer(&ret); } --=20 2.29.2