From nobody Mon Feb 9 10:28:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533714282395823.8998143012998; Wed, 8 Aug 2018 00:44:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 884134DAFB; Wed, 8 Aug 2018 07:44:40 +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 4F0C73001A66; Wed, 8 Aug 2018 07:44:40 +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 04D601800B77; Wed, 8 Aug 2018 07:44:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w787iW5q006105 for ; Wed, 8 Aug 2018 03:44:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE50B6252C; Wed, 8 Aug 2018 07:44:32 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 727B665F4E for ; Wed, 8 Aug 2018 07:44:14 +0000 (UTC) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA0DC308A95E for ; Wed, 8 Aug 2018 07:44:13 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id r5-v6so703350pgv.0 for ; Wed, 08 Aug 2018 00:44:13 -0700 (PDT) Received: from centos.localdomain ([42.106.0.165]) by smtp.gmail.com with ESMTPSA id 9-v6sm9617719pfv.53.2018.08.08.00.44.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=d9eP3AHWBICD/LhyVW1QbWjzy4RXsM6/pPWqulwVjBw=; b=DSKOKduCHITfyYuuxPC2KBvx2DhJtj+rI6S8Wb9nciNwm27sq6FZICPy7yUz/c5fO7 j15ZJMdhYxzYdTnZWdJDp5hrl+WMNsskhbWYs6NZM9I1o3gDof1ExfeVCUilsDs20u56 j7zH3pF2IbMD82k/B0Nemsk0UO7myv7H6c5WhOwhKfd46JmdWp6B1+/wyF06KPJfbEjx t5G8b/I/Lx1M9EyEBPMiR4WvOPNkCCvsFYotJIQlxiF4KoV/uVRl1P2sada3VnLW96ue D4W7U8pN6lpfNwtychf7zSy9hnZ7fDRXAqTKNmcG8EFNUO9hFntn/VwXf5WCZxBffLHG 37Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=d9eP3AHWBICD/LhyVW1QbWjzy4RXsM6/pPWqulwVjBw=; b=i6RClM9IwTy1bM0Vujo8WZf6JyxqssIWFhmLiKiJOuLZjv41yUJpmTqKWA/hwEKMA9 vlrZMx/vOFC2Ciupk5khejPvhhjtpaCblHzg5xKFBbJXoKnszi9Yy2u6W9Jjfk1BDy+u qnVI2wqmDg0AU0cfuvgSIPL2cRUB8YRsYBrSHkCO0Twoq/M1YbvpKXuTE+d2eiBchJXA nYf0oUxtUejo5dEx9G6kxoAEAaJvO9oadG3mAgLqJA6smq5a4e09mLLJy3Tn35Ych+5R 2r0cUJPqCBrKhq0RR8ynN47iF9OW9iFeQV5SY7cj8UYsJs22pSJRShB5NUKUSOkK5hE6 bbAg== X-Gm-Message-State: AOUpUlHMZNqInQTgPTaQMmMO3xk5v+3ZqshCeFE2qOgLoEsaESO6/Bw4 ik6dBpWG9Cokuu8Wr9AVFTeJ2DCe X-Google-Smtp-Source: AA+uWPz2kDjOvhzXtRFgDaSqu9Lj75EmtpeWb1W2i2hvixm++/L1CSb+Jw+iMiu6yb5ZTAeI3t2+Sg== X-Received: by 2002:a62:6eca:: with SMTP id j193-v6mr1721784pfc.256.1533714252890; Wed, 08 Aug 2018 00:44:12 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:57 +0530 Message-Id: <1533501842-24503-31-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1533501842-24503-1-git-send-email-skrtbhtngr@gmail.com> References: <1533501842-24503-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 08 Aug 2018 07:44:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 08 Aug 2018 07:44:13 +0000 (UTC) for IP:'209.85.215.172' DOMAIN:'mail-pg1-f172.google.com' HELO:'mail-pg1-f172.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.215.172 mail-pg1-f172.google.com 209.85.215.172 mail-pg1-f172.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 30/35] util: perf: use VIR_AUTOFREE instead of VIR_FREE for scalar types 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 08 Aug 2018 07:44:41 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virperf.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/util/virperf.c b/src/util/virperf.c index 4537cd0..23f7703 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -175,12 +175,12 @@ typedef struct virPerfEventAttr *virPerfEventAttrPtr; static int virPerfRdtAttrInit(void) { - char *buf =3D NULL; char *tmp =3D NULL; unsigned int attr_type =3D 0; + VIR_AUTOFREE(char *) buf =3D NULL; =20 if (virFileReadAllQuiet("/sys/devices/intel_cqm/type", 10, &buf) < 0) - goto error; + return -1; =20 if ((tmp =3D strchr(buf, '\n'))) *tmp =3D '\0'; @@ -188,19 +188,14 @@ virPerfRdtAttrInit(void) if (virStrToLong_ui(buf, NULL, 10, &attr_type) < 0) { virReportSystemError(errno, "%s", _("failed to get rdt event type")); - goto error; + return -1; } - VIR_FREE(buf); =20 attrs[VIR_PERF_EVENT_CMT].attrType =3D attr_type; attrs[VIR_PERF_EVENT_MBMT].attrType =3D attr_type; attrs[VIR_PERF_EVENT_MBML].attrType =3D attr_type; =20 return 0; - - error: - VIR_FREE(buf); - return -1; } =20 =20 @@ -209,7 +204,6 @@ virPerfEventEnable(virPerfPtr perf, virPerfEventType type, pid_t pid) { - char *buf =3D NULL; struct perf_event_attr attr; virPerfEventPtr event =3D &(perf->events[type]); virPerfEventAttrPtr event_attr =3D &attrs[type]; @@ -227,6 +221,8 @@ virPerfEventEnable(virPerfPtr perf, } =20 if (type =3D=3D VIR_PERF_EVENT_CMT) { + VIR_AUTOFREE(char *) buf =3D NULL; + if (virFileReadAll("/sys/devices/intel_cqm/events/llc_occupancy.sc= ale", 10, &buf) < 0) goto error; @@ -236,8 +232,6 @@ virPerfEventEnable(virPerfPtr perf, _("failed to get cmt scaling factor")); goto error; } - - VIR_FREE(buf); } =20 memset(&attr, 0, sizeof(attr)); @@ -268,7 +262,6 @@ virPerfEventEnable(virPerfPtr perf, =20 error: VIR_FORCE_CLOSE(event->fd); - VIR_FREE(buf); return -1; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list