From nobody Mon Feb 9 03:52:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1628177708; cv=none; d=zohomail.com; s=zohoarc; b=LGi9ekmXO1QVf80GYnYaYNiNa4NS3CUVqS5lB21EiciejeLjwHXuRAhcOnwvU7TtUA+Nr4g6UGVbQU/oHB+wcE4P3wETsG7DtTaCq39kvrMT2IiGQzcM3ct+DqHVNQCI2VA7GS0fEE3byy3LuPQo5if05yrz+PvweRhA1GZXFNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177708; 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=UsKWnRjcLpMQjSyB61vQuIS1xiSS+ifjebEQICVCGgM=; b=nH66WSfPGWtxIB7l/KbbNOVtmg62RDtQVOqseXAaLFt6qWJAMeSqMtlqWM/97X7LIbX7f4ntOKoK2aobDEgljn1TADHQ4gaFu7qvPfJCNvLZDLc3jy2kBQZm3EzOR6AMXLCUbOHLhFg7MsHeZCgXIKmYfOcDwm2b1Lp9HUg37ks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1628177708051317.44155085331784; Thu, 5 Aug 2021 08:35:08 -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-118-cUIIM-yJM9yzy__cem-rtA-1; Thu, 05 Aug 2021 11:35:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCBBE1018F72; Thu, 5 Aug 2021 15:34:57 +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 B6A9B60CA1; Thu, 5 Aug 2021 15:34:57 +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 81D9B181A3F4; Thu, 5 Aug 2021 15:34:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 175FYuO4027733 for ; Thu, 5 Aug 2021 11:34:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12A6D18401; Thu, 5 Aug 2021 15:34:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 714245D6B1 for ; Thu, 5 Aug 2021 15:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177707; 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=UsKWnRjcLpMQjSyB61vQuIS1xiSS+ifjebEQICVCGgM=; b=Yhpl1X++WZzsGmAr9AkIfwHxVfmr2P5ejmkwObf2xtwHU/vd2JX2KZ5FfxYAAkT3aG9M+O tnKkJrqbSitSgrvm3lmDP7xGv/Zn6JwDclCV33ddD6acQrZveeslSO63/EKFe2J9T1j19p L+uafT5+zVsOuVJP3wDoM+olZHYrwY0= X-MC-Unique: cUIIM-yJM9yzy__cem-rtA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/13] qemuNamespacePrepareOneItem: Restructure code to avoid temporary variables Date: Thu, 5 Aug 2021 17:34:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.12 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: 1628177708496100001 Content-Type: text/plain; charset="utf-8" The value of 'next' is copied into 'item.file' so we can move the update to the 'next' pointer earlier and move the VIR_APPEND_ELEMENT call to where we figure out that we need to append the value. Signed-off-by: Peter Krempa --- src/qemu/qemu_namespace.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index ca59b5d95b..01a5edc585 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1197,7 +1197,6 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData *d= ata, while (1) { g_auto(qemuNamespaceMknodItem) item =3D { 0 }; bool isLink; - bool addToData =3D false; int rc; rc =3D qemuNamespaceMknodItemInit(&item, cfg, vm, next); @@ -1210,25 +1209,21 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData = *data, } isLink =3D S_ISLNK(item.sb.st_mode); + g_free(next); + next =3D g_strdup(item.target); - if (STRPREFIX(next, QEMU_DEVPREFIX)) { + if (STRPREFIX(item.file, QEMU_DEVPREFIX)) { for (i =3D 0; i < ndevMountsPath; i++) { if (STREQ(devMountsPath[i], "/dev")) continue; - if (STRPREFIX(next, devMountsPath[i])) + if (STRPREFIX(item.file, devMountsPath[i])) break; } if (i =3D=3D ndevMountsPath) - addToData =3D true; + VIR_APPEND_ELEMENT(data->items, data->nitems, item); } - g_free(next); - next =3D g_strdup(item.target); - - if (addToData) - VIR_APPEND_ELEMENT(data->items, data->nitems, item); - if (!isLink) break; --=20 2.31.1