From nobody Mon Feb 9 17:24:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612600573; cv=none; d=zohomail.com; s=zohoarc; b=XpYUGUV3F2m9ezqeN9A0fkhI0Sf58mc4u+6lsPgALa/3oSPMV8y+W9X7ViuN1f8jWznPWiOF9WuNNKG+BwRlQMeUg/jB60m6GEpCihmJJgAj4L2CkLrIaQO24RYDJMwF9vNwt9g3z3ONNnZ23o4mGIuWV7x9dA3DikuB76Ys5Ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612600573; 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=Ib+6hiVcy1Ppm5y44mP/Ldc2SvgXogS/X2GY3y3oimE=; b=hn3eD7MjF+WA5albuENM5o0Lo5il+dIgcGMndtrD+PP9gPQH2eveTvkJYcP40vLTqpKKd4F1C1kU/5A/m1EXxLGK481ie1f4qegkUeMr8GcikTT1bFT7eJx/Mj/pEG1aKURubBkplAmmmQLPkZFEbg+Xy0ucyn+6LJdzlu6LouM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612600573613797.5980737305451; Sat, 6 Feb 2021 00:36:13 -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-109-TX-EOaB5OaKB8SISD5YdzQ-1; Sat, 06 Feb 2021 03:34:49 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D619E1DDE2; Sat, 6 Feb 2021 08:34:43 +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 B1F4F72FAB; Sat, 6 Feb 2021 08:34:43 +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 7A04F18089D1; Sat, 6 Feb 2021 08:34:43 +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 1168YgdP005461 for ; Sat, 6 Feb 2021 03:34:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 57EC960C8F; Sat, 6 Feb 2021 08:34:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB7D860C79 for ; Sat, 6 Feb 2021 08:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612600572; 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=Ib+6hiVcy1Ppm5y44mP/Ldc2SvgXogS/X2GY3y3oimE=; b=b65uWZL3nXn3wi3QPF59/VKYe3nRiO21Tn5saDUHRnww8Ygst6zILy29H+szgHk24mQIEA Xjpu/KlcNrbeWLbdew7DPsVlpQxfuZO++y2GI5SbUv2986vBNVCDv/z7YXlRscU0HgyyJv qKXGZYdhvPRY1VB54RlaMjeBxDrqC+w= X-MC-Unique: TX-EOaB5OaKB8SISD5YdzQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/40] Replace virStringListLength where actual lenght is not needed Date: Sat, 6 Feb 2021 09:32:53 +0100 Message-Id: <98ad6657f01013763177136d9e96caf232667bcd.1612599659.git.pkrempa@redhat.com> 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.79 on 10.5.11.11 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" Some callers don't need to know the actual lenght of the list but only care whether the required element is present or the list is non-empty. Don't calculate the list length in those cases. Signed-off-by: Peter Krempa --- src/lxc/lxc_native.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/storage/storage_backend_sheepdog.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index e68977dd99..4229a9ca7a 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -568,7 +568,7 @@ lxcNetworkParseDataIPs(const char *name, family =3D AF_INET6; ipparts =3D virStringSplit(value->str, "/", 2); - if (virStringListLength((const char * const *)ipparts) !=3D 2 || + if (!ipparts || !ipparts[0] || !ipparts[1] || virSocketAddrParse(&ip->address, ipparts[0], family) < 0 || virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c34af6b7d1..80bd27696b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17737,7 +17737,7 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, return -1; } - if (virStringListLength((const char * const *)features) =3D=3D 0) + if (!features || !*features) return 0; for (i =3D 0; i < dom->def->nresctrls; i++) { diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index 178cfbae11..2db2384e67 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -157,8 +157,7 @@ virStorageBackendSheepdogRefreshAllVol(virStoragePoolOb= jPtr pool) cells =3D virStringSplit(lines[i], " ", 0); - if (cells !=3D NULL && - virStringListLength((const char * const *)cells) > 2) { + if (cells !=3D NULL && cells[0] && cells[1]) { if (virStorageBackendSheepdogAddVolume(pool, cells[1]) < 0) return -1; } --=20 2.29.2