From nobody Mon Feb 9 09:08:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1639052560; cv=none; d=zohomail.com; s=zohoarc; b=g6ooOu7xdYU5410KAVpEnJVwSnud4FRYnG84DVFSTSzO8bhAVKHEiUhltA/W2vrfc65hof7bAZGZ/OUYxoJBBxPxzRWrfy0q+5P7nkA6PNZsdVlZo/UcWfBkdJJIZowC88u72jhynz3O/HbE+UKxDkZLHF75Zw3mw6Og4+sRcDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052560; 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=l1jGP92NdtscAddJ87h455Zeay1o1A5t3cilH0DzG94=; b=Aof1YG608ADPbrKPJxy/DHuNUhxYm2DVp94JoVwqR2BAUtE42v1efrTBfv27xA7XU35fl/6lBEIl8tprPVo5IDdY9ezKks655kDan9P6i/SE7xh4QTE7+8hcn433rmG/CqEog+3MCdnyyVBnOEl4EusA1VMPDqb3QvWbNEqbiDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1639052560448948.9214376119278; Thu, 9 Dec 2021 04:22:40 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-215-DqJVPvivPoKVWghRRYMgUA-1; Thu, 09 Dec 2021 07:22:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC74D100C68D; Thu, 9 Dec 2021 12:22:30 +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 A8FB65D6CF; Thu, 9 Dec 2021 12:22: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 771574A707; Thu, 9 Dec 2021 12:22:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9CMSxj015692 for ; Thu, 9 Dec 2021 07:22:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id A74BD17CD9; Thu, 9 Dec 2021 12:22:28 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A4B75E24E for ; Thu, 9 Dec 2021 12:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052559; 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=l1jGP92NdtscAddJ87h455Zeay1o1A5t3cilH0DzG94=; b=ax0w/7yGpypKddl2tJLugP1t+JOC5f0/KH7wekgbhZNZzOtRTmGC2BbFadxAfSRSNym3CR QyIWpevHulVdzruWOvg/6jp/KEFvHwucKW8JvnI6pg1meY3oBhETcEbxFj8HAO9xvFTc+V bc1gW9+2H6IeeD73fc4LVUpSIr4WdUk= X-MC-Unique: DqJVPvivPoKVWghRRYMgUA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/36] lxcSetCpusetTune: Refactor memory clearing Date: Thu, 9 Dec 2021 13:18:34 +0100 Message-Id: <23b9d134f4d718b2be44b5f977132775314caf98.1639052248.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.15 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) X-ZM-MESSAGEID: 1639052561672100001 Content-Type: text/plain; charset="utf-8" Use automatic memory clearing for virBitmap and remove a reuse of a temporary string. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/lxc/lxc_native.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 972e9cdc15..e9b58cbd1a 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -926,32 +926,28 @@ lxcSetCpuTune(virDomainDef *def, virConf *properties) static int lxcSetCpusetTune(virDomainDef *def, virConf *properties) { - g_autofree char *value =3D NULL; - virBitmap *nodeset =3D NULL; + g_autofree char *cpus =3D NULL; + g_autofree char *mems =3D NULL; + g_autoptr(virBitmap) nodeset =3D NULL; if (virConfGetValueString(properties, "lxc.cgroup.cpuset.cpus", - &value) > 0) { - if (virBitmapParse(value, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) <= 0) + &cpus) > 0) { + if (virBitmapParse(cpus, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < = 0) return -1; def->placement_mode =3D VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC; - g_free(value); - value =3D NULL; } if (virConfGetValueString(properties, "lxc.cgroup.cpuset.mems", - &value) > 0) { - if (virBitmapParse(value, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) + &mems) > 0) { + if (virBitmapParse(mems, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) return -1; if (virDomainNumatuneSet(def->numa, def->placement_mode =3D=3D VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC, VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC, VIR_DOMAIN_NUMATUNE_MEM_STRICT, - nodeset) < 0) { - virBitmapFree(nodeset); + nodeset) < 0) return -1; - } - virBitmapFree(nodeset); } return 0; --=20 2.31.1