From nobody Tue Feb 10 04:13:42 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=1613152565; cv=none; d=zohomail.com; s=zohoarc; b=Ocfqw6cqM+nJnSPLe4lqY3LmafmPxPsZwUQV6jdkPnNlpqhlZNlCp70NEw8OOhaa5uCJza6GFN1mowrs/Ln448ujnYGK9aBxKyOfkonBuo2kZydinAQuEjvmOBm8waRT7XjWDIJFRQ75CcU6e7gFgg6h1zvpDb3wmXfdeD/ytEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613152565; 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=MnKqzMoDKrivtVk+8LrMtozufb4zpAkuuDqOCOB/PpY=; b=gFAqTElmY2VBZNFe5fnJpMhdZsGz8S5n0CgPIDsVPRZlVK+SmgCZeKThlRTBpM+e5uPi+dTaw4sxwGdmENjUF8PJoMtV/6M5I0DwB2ACMabR4wMUApREYJaZebijbAGCbAywT90XtXsl/DzIwkdXAuq0Zx8Woa82FmHXwl6jbK8= 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 1613152565675917.4902800123353; Fri, 12 Feb 2021 09:56: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-455-Cfetn3P_NGyGIVmb4255XQ-1; Fri, 12 Feb 2021 12:56:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBA0FBBEE6; Fri, 12 Feb 2021 17:55:52 +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 937C110021AA; Fri, 12 Feb 2021 17:55:52 +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 4F06F4E58E; Fri, 12 Feb 2021 17:55:52 +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 11CHto90010549 for ; Fri, 12 Feb 2021 12:55:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7C65E67CC5; Fri, 12 Feb 2021 17:55:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDE71679FB for ; Fri, 12 Feb 2021 17:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613152563; 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=MnKqzMoDKrivtVk+8LrMtozufb4zpAkuuDqOCOB/PpY=; b=QyKFi9A5Sb10KgXomzL++4rXcqY9AOOc37fZRo78+/H01+FcNCSgNwFBAnExq7sdgeVsnd N4JNFudOXWCPsGbgE3xfwKfj2XbOqMJk5Gr6WTA3qpl28hej7ZpGSadZnUbKGQBqk9laou du7t4ItlRwdsS3DWhCesFkfMI+3iP1M= X-MC-Unique: Cfetn3P_NGyGIVmb4255XQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/25] virLogDaemonPreExecRestart: Refactor memory cleanup Date: Fri, 12 Feb 2021 18:55:15 +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.84 on 10.5.11.22 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_daemon.c | 54 +++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 770f6dd273..ceffa6a368 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -505,62 +505,54 @@ virLogDaemonPreExecRestart(const char *state_file, virNetDaemonPtr dmn, char **argv) { - virJSONValuePtr child; - char *state =3D NULL; - virJSONValuePtr object =3D virJSONValueNewObject(); - char *magic =3D NULL; + g_autoptr(virJSONValue) object =3D virJSONValueNewObject(); + g_autoptr(virJSONValue) daemon =3D NULL; + g_autoptr(virJSONValue) handler =3D NULL; + g_autofree char *state =3D NULL; + g_autofree char *magic =3D NULL; VIR_DEBUG("Running pre-restart exec"); - if (!(child =3D virNetDaemonPreExecRestart(dmn))) - goto cleanup; + if (!(daemon =3D virNetDaemonPreExecRestart(dmn))) + return -1; - if (virJSONValueObjectAppend(object, "daemon", child) < 0) { - virJSONValueFree(child); - goto cleanup; - } + if (virJSONValueObjectAppend(object, "daemon", daemon) < 0) + return -1; + daemon =3D NULL; if (!(magic =3D virLogDaemonGetExecRestartMagic())) - goto cleanup; + return -1; if (virJSONValueObjectAppendString(object, "magic", magic) < 0) - goto cleanup; - - if (!(child =3D virLogHandlerPreExecRestart(logDaemon->handler))) - goto cleanup; + return -1; - if (virJSONValueObjectAppend(object, "handler", child) < 0) { - virJSONValueFree(child); - goto cleanup; - } + if (!(handler =3D virLogHandlerPreExecRestart(logDaemon->handler))) + return -1; + if (virJSONValueObjectAppend(object, "handler", handler) < 0) + return -1; + handler =3D NULL; if (!(state =3D virJSONValueToString(object, true))) - goto cleanup; + return -1; VIR_DEBUG("Saving state %s", state); - if (virFileWriteStr(state_file, - state, 0700) < 0) { + if (virFileWriteStr(state_file, state, 0700) < 0) { virReportSystemError(errno, - _("Unable to save state file %s"), - state_file); - goto cleanup; + _("Unable to save state file %s"), state_file= ); + return -1; } if (execvp(argv[0], argv) < 0) { virReportSystemError(errno, "%s", _("Unable to restart self")); - goto cleanup; + return -1; } abort(); /* This should be impossible to reach */ - cleanup: - VIR_FREE(magic); - VIR_FREE(state); - virJSONValueFree(object); - return -1; + return 0; } --=20 2.29.2