From nobody Mon Feb 9 20:35:09 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=1612600440; cv=none; d=zohomail.com; s=zohoarc; b=KEckALuQCZql85Pq1UNQMcWaHlgAavnGrknp6jar9FAZ6NjoyqJQm1kv88ke1NXRNxXU1IpQNrwKZYxrxXd5xs7uDWWsuVbNFb1lLBxZ+/ZM/klZjG/UUNpUZbE0+fTAa8dXRLhSHJ+Xf+vG1WsZ7bz8OETVuja3rA77maqa1CA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612600440; 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=rtCHeDIR0hd+3n0XXjAc0LfOxe19CouVaaKWHHH89+o=; b=aFY0pwi3ABEQDLHF+1Q5CiC1M6EqtgMbSBHKqZTr8l6GShOB5MVMTZm/B6cHRbXy/y2kW9gsFqT/XbtVso2aRpl4LSwC5G0w1oX/nHnB7agYdZAfHss7AcdiHqfpjQWTcpFzyNCwCsDafyVueS1odbUsHgjhByLUyJytrKiTqo8= 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 1612600440707948.1925803367697; Sat, 6 Feb 2021 00:34:00 -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-441-_xXT7wrwPCa8GJk2XLQCZQ-1; Sat, 06 Feb 2021 03:33:57 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B887D100CCCC; Sat, 6 Feb 2021 08:33:51 +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 9691919C47; Sat, 6 Feb 2021 08:33:51 +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 5FD725808B; Sat, 6 Feb 2021 08:33:51 +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 1168XnvB004989 for ; Sat, 6 Feb 2021 03:33:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id E234160C77; Sat, 6 Feb 2021 08:33:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05C5B60C76 for ; Sat, 6 Feb 2021 08:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612600439; 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=rtCHeDIR0hd+3n0XXjAc0LfOxe19CouVaaKWHHH89+o=; b=JG0HF1f0vfg7jRpfFVCFD4CQ6k5xGlEkuBsAiP+g3kiczA73E6MUmMT5f+1XzgzD7GBrys B3Dzv+jtiKO/6yGjedsJkQNzJ3VaFqZNS6vtQggNvjZ8MSvRxLM6uaevjwU3IIW4C9pVsS rxMQd3V8EM6puuLGRUth80Mvgwfm8jA= X-MC-Unique: _xXT7wrwPCa8GJk2XLQCZQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/40] virfirewalltest: Shuffle the code around to remove a loop Date: Sat, 6 Feb 2021 09:32:40 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.23 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" We are already looping over the arguments to construct the list, so we can add them to fwBuf right away rather than in an extra loop if we move some of the 'fwBuf' parts earlier and merge the two loops. Signed-off-by: Peter Krempa --- tests/virfirewalltest.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index 9f95520859..e14a34d7d2 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -108,12 +108,20 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, char *item =3D NULL; bool isAdd =3D false; bool doError =3D false; - size_t i; g_variant_get(params, "(&sas)", &type, &iter); nargs =3D g_variant_iter_n_children(iter); + if (fwBuf) { + if (STREQ(type, "ipv4")) + virBufferAddLit(fwBuf, IPTABLES_PATH); + else if (STREQ(type, "ipv6")) + virBufferAddLit(fwBuf, IP6TABLES_PATH); + else + virBufferAddLit(fwBuf, EBTABLES_PATH); + } + while (g_variant_iter_loop(iter, "s", &item)) { /* Fake failure on the command with this IP addr */ if (STREQ(item, "-A")) { @@ -123,21 +131,10 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, } virStringListAdd(&args, item); - } - - if (fwBuf) { - if (STREQ(type, "ipv4")) - virBufferAddLit(fwBuf, IPTABLES_PATH); - else if (STREQ(type, "ipv6")) - virBufferAddLit(fwBuf, IP6TABLES_PATH); - else - virBufferAddLit(fwBuf, EBTABLES_PATH); - } - for (i =3D 0; i < nargs; i++) { if (fwBuf) { virBufferAddLit(fwBuf, " "); - virBufferEscapeShell(fwBuf, args[i]); + virBufferEscapeShell(fwBuf, item); } } --=20 2.29.2