From nobody Sun Feb 8 20:35:13 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=1643895556; cv=none; d=zohomail.com; s=zohoarc; b=OtqeL1PoDDLTXF1yA2zx3fkGof9dV+STCcimbwpq3muue4syJhEYHXfaLtGzMeDgqwfssf+vN0FvGqxethhBa8McUqqmSoggEAlYKaBQLyKAcKq7Rq9kGv9GAX9Qd+KSm37cMMqt6kPm9aF8LU5TmY8cQGyMRDJAlrejTb5i/2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643895556; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=5vEZLi45fUQ2cxk0H1dAtjvPnCFqJ/wYhsrtR3+nZ6c=; b=ZUBAKRfvRWW886GUTK5CKLHdCGkCj9pqeIT0BICuJ7cm+S7U+DxxBuGdh+/LtD5SvyQmsuAPAnGtYH2fnGqToM8V6YpqI5uMExWIFPcytRwFViducRfmioafDgFWyO8eG9BO4g0wYeDAMmY7MsBSCiwLf+JrCoXKl3wAesXxPto= 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 16438955569591011.872195087369; Thu, 3 Feb 2022 05:39:16 -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-106-MlUbVFiLOZalx_6idrmeGg-1; Thu, 03 Feb 2022 08:39:14 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29A4C14759; Thu, 3 Feb 2022 13:39:09 +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 55B8D7D736; Thu, 3 Feb 2022 13:39:07 +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 721501809CB9; Thu, 3 Feb 2022 13:39:05 +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 213Dd4v6023865 for ; Thu, 3 Feb 2022 08:39:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9ED4578AB9; Thu, 3 Feb 2022 13:39:04 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.195.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D398E78AB7 for ; Thu, 3 Feb 2022 13:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643895556; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5vEZLi45fUQ2cxk0H1dAtjvPnCFqJ/wYhsrtR3+nZ6c=; b=hJfSmD9wGSRq8Dt2Fod6DbUfy2bpvkEPLJuEgbi5rnDWosGHmC7zYPtcWj9yPVz0+pWOLA 7OdnL22QQgjKTSBJ7fJyva7zHirVPohiPdA/Agm91nf7J8se0R+5xX7Vu9gp4yXIO0GsnC KNPcWvrsYZwJD6TN1JlNOKeAg0HTg80= X-MC-Unique: MlUbVFiLOZalx_6idrmeGg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH] util: Reorder virStringParseVersion() arguments Date: Thu, 3 Feb 2022 14:38:49 +0100 Message-Id: <20220203133849.381405-1-abologna@redhat.com> 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.13 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: 1643895559420100001 Content-Type: text/plain; charset="utf-8" In order to match the existing virStringParse*() and virStrTo*() functions, input arguments should come before output arguments. Signed-off-by: Andrea Bolognani Reviewed-by: Peter Krempa --- src/bhyve/bhyve_driver.c | 2 +- src/ch/ch_conf.c | 2 +- src/esx/esx_vi.c | 8 ++++---- src/lxc/lxc_driver.c | 2 +- src/nwfilter/nwfilter_ebiptables_driver.c | 4 ++-- src/openvz/openvz_conf.c | 2 +- src/util/virdnsmasq.c | 2 +- src/util/virfirewalld.c | 2 +- src/util/virstring.c | 10 +++++----- src/util/virstring.h | 6 +++--- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_conf.c | 2 +- src/vz/vz_utils.c | 2 +- tests/testutilsqemu.c | 2 +- tests/utiltest.c | 4 ++-- tools/virt-host-validate-common.c | 2 +- 16 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 578fcfe1d2..1cf0b2abce 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -267,7 +267,7 @@ bhyveConnectGetVersion(virConnectPtr conn, unsigned lon= g *version) =20 uname(&ver); =20 - if (virStringParseVersion(version, ver.release, true) < 0) { + if (virStringParseVersion(ver.release, true, version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown release: %s"), ver.release); return -1; diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index 88a23a59cd..41d753fd21 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -204,7 +204,7 @@ chExtractVersion(virCHDriver *driver) return -1; } =20 - if (virStringParseVersion(&version, tmp, true) < 0) { + if (virStringParseVersion(tmp, true, &version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse cloud-hypervisor version: %s"), = tmp); return -1; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 36e9dc1d2c..1ea81a649c 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -868,8 +868,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, return -1; } =20 - if (virStringParseVersion(&ctx->apiVersion, - ctx->service->about->apiVersion, true) < 0) { + if (virStringParseVersion(ctx->service->about->apiVersion, true, + &ctx->apiVersion) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse VI API version '%s'"), ctx->service->about->apiVersion); @@ -883,8 +883,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, return -1; } =20 - if (virStringParseVersion(&ctx->productVersion, - ctx->service->about->version, true) < 0) { + if (virStringParseVersion(ctx->service->about->version, true, + &ctx->productVersion) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse product version '%s'"), ctx->service->about->version); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 3d17b87e8c..51596a820c 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1656,7 +1656,7 @@ static int lxcConnectGetVersion(virConnectPtr conn, u= nsigned long *version) if (virConnectGetVersionEnsureACL(conn) < 0) return -1; =20 - if (virStringParseVersion(version, ver.release, true) < 0) { + if (virStringParseVersion(ver.release, true, version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown release: %s"), v= er.release); return -1; } diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index 54065a0f75..7798dc47b0 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -3655,7 +3655,7 @@ ebiptablesDriverProbeCtdir(void) } =20 /* following Linux lxr, the logic was inverted in 2.6.39 */ - if (virStringParseVersion(&thisversion, utsname.release, true) < 0) { + if (virStringParseVersion(utsname.release, true, &thisversion) < 0) { VIR_ERROR(_("Could not determine kernel version from string %s"), utsname.release); return; @@ -3688,7 +3688,7 @@ ebiptablesDriverProbeStateMatchQuery(virFirewall *fw = G_GNUC_UNUSED, * 'iptables v1.4.16' */ if (!(tmp =3D strchr(lines[0], 'v')) || - virStringParseVersion(version, tmp + 1, true) < 0) { + virStringParseVersion(tmp + 1, true, version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot parse version string '%s'"), lines[0]); diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 191c79e1e2..c85829be86 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -85,7 +85,7 @@ openvzExtractVersionInfo(const char *cmdstr, int *retvers= ion) if ((tmp =3D STRSKIP(tmp, "vzctl version ")) =3D=3D NULL) return -1; =20 - if (virStringParseVersion(&version, tmp, true) < 0) + if (virStringParseVersion(tmp, true, &version) < 0) return -1; =20 if (retversion) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index fd4efa802c..3467d8e4e0 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -614,7 +614,7 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char = *buf) =20 virSkipToDigit(&p); =20 - if (virStringParseVersion(&version, p, true) < 0) + if (virStringParseVersion(p, true, &version) < 0) goto error; =20 if (version < DNSMASQ_MIN_MAJOR * 1000000 + DNSMASQ_MIN_MINOR * 1000) { diff --git a/src/util/virfirewalld.c b/src/util/virfirewalld.c index c909901833..05a8f4e714 100644 --- a/src/util/virfirewalld.c +++ b/src/util/virfirewalld.c @@ -107,7 +107,7 @@ virFirewallDGetVersion(unsigned long *version) g_variant_get(reply, "(v)", &gvar); g_variant_get(gvar, "&s", &versionStr); =20 - if (virStringParseVersion(version, versionStr, false) < 0) { + if (virStringParseVersion(versionStr, false, version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to parse firewalld version '%s'"), versionStr); diff --git a/src/util/virstring.c b/src/util/virstring.c index ad0b158ad4..ee0fe7fc9e 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -1023,10 +1023,10 @@ int virStringParseYesNo(const char *str, bool *resu= lt) =20 /** * virStringParseVersion: - * @version: unsigned long pointer to output the version number * @str: const char pointer to the version string * @allowMissing: true to treat 3 like 3.0.0, false to error out on - * missing minor or micro + * missing minor or micro + * @version: unsigned long pointer to output the version number * * Parse an unsigned version number from a version string. Expecting * 'major.minor.micro' format, ignoring an optional suffix. @@ -1038,9 +1038,9 @@ int virStringParseYesNo(const char *str, bool *result) * Returns the 0 for success, -1 for error. */ int -virStringParseVersion(unsigned long *version, - const char *str, - bool allowMissing) +virStringParseVersion(const char *str, + bool allowMissing, + unsigned long *version) { unsigned int major, minor =3D 0, micro =3D 0; char *tmp; diff --git a/src/util/virstring.h b/src/util/virstring.h index ec8ceb0022..6334c4f177 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -136,6 +136,6 @@ int virStringParseYesNo(const char *str, bool *result) G_GNUC_WARN_UNUSED_RESULT; =20 -int virStringParseVersion(unsigned long *version, - const char *str, - bool allowMissing); +int virStringParseVersion(const char *str, + bool allowMissing, + unsigned long *version); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index eec47a02fc..ccb719c69d 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -170,7 +170,7 @@ vboxExtractVersion(void) =20 gVBoxAPI.UPFN.Utf16ToUtf8(vbox_driver->pFuncs, versionUtf16, &vboxVers= ion); =20 - if (virStringParseVersion(&vbox_driver->version, vboxVersion, false) >= =3D 0) + if (virStringParseVersion(vboxVersion, false, &vbox_driver->version) >= =3D 0) ret =3D 0; =20 gVBoxAPI.UPFN.Utf8Free(vbox_driver->pFuncs, vboxVersion); diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index ebba435cc4..e449d7dcc7 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -229,7 +229,7 @@ vmwareParseVersionStr(int type, const char *verbuf, uns= igned long *version) return -1; } =20 - if (virStringParseVersion(version, tmp, false) < 0) { + if (virStringParseVersion(tmp, false, version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("version parsing error")); return -1; diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index fcf6d363a9..c4edf9f673 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -182,7 +182,7 @@ vzInitVersion(struct _vzDriver *driver) } =20 tmp[0] =3D '\0'; - if (virStringParseVersion(&(driver->vzVersion), sVer, true) < 0) { + if (virStringParseVersion(sVer, true, &(driver->vzVersion)) < 0) { vzParseError(); goto cleanup; } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 646ef415d1..59044bd915 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -695,7 +695,7 @@ testQemuGetLatestCapsForArch(const char *arch, if (!virStringStripSuffix(tmp, fullsuffix)) continue; =20 - if (virStringParseVersion(&ver, tmp, false) < 0) { + if (virStringParseVersion(tmp, false, &ver) < 0) { VIR_TEST_DEBUG("skipping caps file '%s'", ent->d_name); continue; } diff --git a/tests/utiltest.c b/tests/utiltest.c index 419dfea913..59f87f7cf2 100644 --- a/tests/utiltest.c +++ b/tests/utiltest.c @@ -151,8 +151,8 @@ testParseVersionString(const void *data G_GNUC_UNUSED) unsigned long version; =20 for (i =3D 0; i < G_N_ELEMENTS(versions); ++i) { - result =3D virStringParseVersion(&version, versions[i].string, - versions[i].allowMissing); + result =3D virStringParseVersion(versions[i].string, + versions[i].allowMissing, &version); =20 if (result !=3D versions[i].result) { VIR_TEST_DEBUG("\nVersion string [%s]", versions[i].string); diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 2ac96d1e19..7c2cb8b908 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -267,7 +267,7 @@ int virHostValidateLinuxKernel(const char *hvname, return VIR_HOST_VALIDATE_FAILURE(level); } =20 - if (virStringParseVersion(&thisversion, uts.release, true) < 0) { + if (virStringParseVersion(uts.release, true, &thisversion) < 0) { virHostMsgFail(level, "%s", hint); return VIR_HOST_VALIDATE_FAILURE(level); } --=20 2.34.1