From nobody Mon Feb 9 03:46:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1591628809; cv=none; d=zohomail.com; s=zohoarc; b=XtepOgJU0PCCnOB0Sk2kcHYPt085mCtfkLaPJx+pD86cdSEsu2pxTvADA0Edce/rG5liF56r5bqj9uJmhyRBK9OpL/pWgzcusbnY6K3h2cNFrT60J3IuwylAX0HlfiYPs/l/2HIjh1/g76AnMcfcwTxgsYz12Ti78q6KJ7y6QPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591628809; 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=G0+m7Ys5uoKrL97UpPP3emGftcU+m4LMHHlBCz3C31I=; b=MBzGwL+9Qisc5FcISRFeMgb/wX6JccueS/jKVl9uhJgNz1WLHUMeQOPvqFZ0gyV16nptIK1pdMntqgTzGa6YBDdJDs+wd+Pgk3XreXnBeEJGNqKGz+rkVDOyICyVdsC8dj1briGuIrayqeBInpwKFb4vIchrCHB5O7cWYmqgWXw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591628809308987.5636205164604; Mon, 8 Jun 2020 08:06:49 -0700 (PDT) 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-330-fv9EMG4LN9iRM7lWp1tXbA-1; Mon, 08 Jun 2020 11:06:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41BA4835B44; Mon, 8 Jun 2020 15:06:35 +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 231C35C1C5; Mon, 8 Jun 2020 15:06:35 +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 E8A1C1809557; Mon, 8 Jun 2020 15:06:34 +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 058F6Qul004814 for ; Mon, 8 Jun 2020 11:06:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54B1310013D4; Mon, 8 Jun 2020 15:06:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8BAB10013C1 for ; Mon, 8 Jun 2020 15:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591628808; 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=G0+m7Ys5uoKrL97UpPP3emGftcU+m4LMHHlBCz3C31I=; b=B1jhM6S7dMUYF1jp4lPLJTEZGPtdM9+3t6Zs33v3lOBp6DyMcleEGSpKl+a9+x+rdcs69Y zPhMYZW31gR+LppF3pFBoGw4bM0vhyxYrzUu9WspSWAOqNZob7Aop/965onj5/u3DGTisb RC5zyvJmnlyQPqMPLiqpXF1ZD43L6ns= X-MC-Unique: fv9EMG4LN9iRM7lWp1tXbA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/7] virSysinfoReadDMI: Use more g_auto*() Date: Mon, 8 Jun 2020 17:06:15 +0200 Message-Id: <5dda83a06f9060b7028f482a10b38e07cc0533b7.1591628594.git.mprivozn@redhat.com> In-Reply-To: References: 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.16 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" Virtually every variable defined in the function can be freed automatically when going out of scope. Signed-off-by: Michal Privoznik --- src/util/virsysinfo.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 41f4d1cff9..296a2e2cc1 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1119,10 +1119,10 @@ virSysinfoParseX86Memory(const char *base, virSysin= foDefPtr ret) virSysinfoDefPtr virSysinfoReadDMI(void) { - char *path; - virSysinfoDefPtr ret =3D NULL; - char *outbuf =3D NULL; - virCommandPtr cmd; + g_autofree char *path =3D NULL; + g_auto(virSysinfoDefPtr) ret =3D NULL; + g_autofree char *outbuf =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; =20 path =3D virFindFileInPath(SYSINFO_SMBIOS_DECODER); if (path =3D=3D NULL) { @@ -1133,48 +1133,38 @@ virSysinfoReadDMI(void) } =20 cmd =3D virCommandNewArgList(path, "-q", "-t", "0,1,2,3,4,17", NULL); - VIR_FREE(path); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return NULL; =20 if (VIR_ALLOC(ret) < 0) - goto error; + return NULL; =20 ret->type =3D VIR_SYSINFO_SMBIOS; =20 if (virSysinfoParseBIOS(outbuf, &ret->bios) < 0) - goto error; + return NULL; =20 if (virSysinfoParseX86System(outbuf, &ret->system) < 0) - goto error; + return NULL; =20 if (virSysinfoParseX86BaseBoard(outbuf, &ret->baseBoard, &ret->nbaseBo= ard) < 0) - goto error; + return NULL; =20 if (virSysinfoParseX86Chassis(outbuf, &ret->chassis) < 0) - goto error; + return NULL; =20 ret->nprocessor =3D 0; ret->processor =3D NULL; if (virSysinfoParseX86Processor(outbuf, ret) < 0) - goto error; + return NULL; =20 ret->nmemory =3D 0; ret->memory =3D NULL; if (virSysinfoParseX86Memory(outbuf, ret) < 0) - goto error; + return NULL; =20 - cleanup: - VIR_FREE(outbuf); - virCommandFree(cmd); - - return ret; - - error: - virSysinfoDefFree(ret); - ret =3D NULL; - goto cleanup; + return g_steal_pointer(&ret); } =20 =20 --=20 2.26.2