From nobody Mon Feb 9 01:48:27 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=1623752872; cv=none; d=zohomail.com; s=zohoarc; b=gIv3pwzcLk5tTlpYnFy5bjMtDcCgF0CRBymyLxLFk6u8LMiqTH24IPNKq/xVlQGQral388TzNfMffDTGSYz6hQcxRxwDASMMHsLD3R7wqADRYpBGRYiMogbdykjQOhQeFqryf8szEdl7cghwcXNWG6DdMtWc2UXzJZvIT32XFoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623752872; 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=NqMb4GGEIkFvrU8zQ32RZYByf8UMDuwnTKDU/aAdEIM=; b=oEEuLeoQusQNRvrQ8q24LqO67mFdd954XCDXB338+p5E3JILmpJpGbZ17+gnPPXzCScOemyKvq+7rKdWjvr4O/1mx94R7p3f+jReRCQYsy9kbTIahsEpvLY9wr/bG7Hn+4os02+lTt56TldMEsAC4JwSFNsGHQRkgArckYrmUSU= 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) 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 1623752872761233.19219977616638; Tue, 15 Jun 2021 03:27:52 -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-361-43WJbTmUPKa7ammYbdyHwA-1; Tue, 15 Jun 2021 06:27:49 -0400 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 B00AC100C625; Tue, 15 Jun 2021 10:27:44 +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 9211C189BB; Tue, 15 Jun 2021 10:27:44 +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 5023946F62; Tue, 15 Jun 2021 10:27:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15FARfRQ019704 for ; Tue, 15 Jun 2021 06:27:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id C48C9189BB; Tue, 15 Jun 2021 10:27:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2729018F0A for ; Tue, 15 Jun 2021 10:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623752871; 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=NqMb4GGEIkFvrU8zQ32RZYByf8UMDuwnTKDU/aAdEIM=; b=Z2NTgIH4mqZHdBgLTADhgtYSvTlsUca9Jri2Ra0ef5aONKEGYSXIlOL5W72JWGnlM4o4bH S0ffEqk7xJ33vxzIjJVDCfkzj88thbBmsV1BwLiARDKu1VSS8HhSQ4NCq3wm+EvZJ29ded 4C+WltzqaS3zThk7vkQ1jvubkErOP0E= X-MC-Unique: 43WJbTmUPKa7ammYbdyHwA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/13] virQEMUCapsProcessStringFlags: Don't require 'nvalues' Date: Tue, 15 Jun 2021 12:27:23 +0200 Message-Id: <516e4fb120554d4365ad421cfb4c1fcec8155067.1623752803.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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" All callers pass in NULL-terminated string lists. Remove the 'nvalues' argument and fix all callers. Signed-off-by: Peter Krempa --- src/qemu/qemu_capabilities.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 18a682f2a6..576fb6429b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1779,16 +1779,17 @@ static void virQEMUCapsProcessStringFlags(virQEMUCaps *qemuCaps, size_t nflags, struct virQEMUCapsStringFlags *flags, - size_t nvalues, - char *const*values) + char **values) { - size_t i, j; + size_t i; + char **value; + for (i =3D 0; i < nflags; i++) { if (virQEMUCapsGet(qemuCaps, flags[i].flag)) continue; - for (j =3D 0; j < nvalues; j++) { - if (STREQ(values[j], flags[i].value)) { + for (value =3D values; *value; value++) { + if (STREQ(*value, flags[i].value)) { virQEMUCapsSet(qemuCaps, flags[i].flag); break; } @@ -2565,15 +2566,14 @@ virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps, qemuMonitor *mon) { g_auto(GStrv) commands =3D NULL; - int ncommands; - if ((ncommands =3D qemuMonitorGetCommands(mon, &commands)) < 0) + if (qemuMonitorGetCommands(mon, &commands) < 0) return -1; virQEMUCapsProcessStringFlags(qemuCaps, G_N_ELEMENTS(virQEMUCapsCommands), virQEMUCapsCommands, - ncommands, commands); + commands); return 0; } @@ -2584,14 +2584,13 @@ virQEMUCapsProbeQMPObjectTypes(virQEMUCaps *qemuCap= s, qemuMonitor *mon) { g_auto(GStrv) values =3D NULL; - int nvalues; - if ((nvalues =3D qemuMonitorGetObjectTypes(mon, &values)) < 0) + if (qemuMonitorGetObjectTypes(mon, &values) < 0) return -1; virQEMUCapsProcessStringFlags(qemuCaps, G_N_ELEMENTS(virQEMUCapsObjectTypes), virQEMUCapsObjectTypes, - nvalues, values); + values); return 0; } @@ -2645,19 +2644,18 @@ virQEMUCapsProbeQMPObjectProperties(virQEMUCaps *qe= muCaps, for (i =3D 0; i < G_N_ELEMENTS(virQEMUCapsObjectProps); i++) { virQEMUCapsObjectTypeProps *props =3D virQEMUCapsObjectProps + i; g_auto(GStrv) values =3D NULL; - int nvalues; if (props->capsCondition >=3D 0 && !virQEMUCapsGet(qemuCaps, props->capsCondition)) continue; - if ((nvalues =3D qemuMonitorGetObjectProps(mon, props->type, &valu= es)) < 0) + if (qemuMonitorGetObjectProps(mon, props->type, &values) < 0) return -1; virQEMUCapsProcessStringFlags(qemuCaps, props->nprops, props->props, - nvalues, values); + values); } return 0; @@ -2871,7 +2869,6 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps, const char *canon =3D virQEMUCapsGetCanonicalMachine(qemuCaps, vir= tType, props.type); g_autofree char *type =3D NULL; g_auto(GStrv) values =3D NULL; - int nvalues; if (STRNEQ(canon, "none") && !virQEMUCapsIsMachineSupported(qemuCaps, virtType, canon)) { @@ -2882,13 +2879,13 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCa= ps, * followed by the -machine suffix */ type =3D g_strdup_printf("%s-machine", canon); - if ((nvalues =3D qemuMonitorGetObjectProps(mon, type, &values)) < = 0) + if (qemuMonitorGetObjectProps(mon, type, &values) < 0) return -1; virQEMUCapsProcessStringFlags(qemuCaps, props.nprops, props.props, - nvalues, values); + values); } return 0; @@ -3306,15 +3303,14 @@ virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCap= s *qemuCaps, qemuMonitor *mon) { g_auto(GStrv) caps =3D NULL; - int ncaps; - if ((ncaps =3D qemuMonitorGetMigrationCapabilities(mon, &caps)) < 0) + if (qemuMonitorGetMigrationCapabilities(mon, &caps) < 0) return -1; virQEMUCapsProcessStringFlags(qemuCaps, G_N_ELEMENTS(virQEMUCapsMigration), virQEMUCapsMigration, - ncaps, caps); + caps); return 0; } --=20 2.31.1