In order to match the existing virStringParse*() and virStrTo*() functions, input arguments should come before output arguments. Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- 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 long *version) uname(&ver); - 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; } - 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 *url, return -1; } - 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 *url, return -1; } - 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, unsigned long *version) if (virConnectGetVersionEnsureACL(conn) < 0) return -1; - 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/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_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) } /* 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 = 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 *retversion) if ((tmp = STRSKIP(tmp, "vzctl version ")) == NULL) return -1; - if (virStringParseVersion(&version, tmp, true) < 0) + if (virStringParseVersion(tmp, true, &version) < 0) return -1; 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) virSkipToDigit(&p); - if (virStringParseVersion(&version, p, true) < 0) + if (virStringParseVersion(p, true, &version) < 0) goto error; 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); - 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 *result) /** * 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 = 0, micro = 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; -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) gVBoxAPI.UPFN.Utf16ToUtf8(vbox_driver->pFuncs, versionUtf16, &vboxVersion); - if (virStringParseVersion(&vbox_driver->version, vboxVersion, false) >= 0) + if (virStringParseVersion(vboxVersion, false, &vbox_driver->version) >= 0) ret = 0; 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, unsigned long *version) return -1; } - 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) } tmp[0] = '\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; - 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; for (i = 0; i < G_N_ELEMENTS(versions); ++i) { - result = virStringParseVersion(&version, versions[i].string, - versions[i].allowMissing); + result = virStringParseVersion(versions[i].string, + versions[i].allowMissing, &version); if (result != 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-common.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); } - if (virStringParseVersion(&thisversion, uts.release, true) < 0) { + if (virStringParseVersion(uts.release, true, &thisversion) < 0) { virHostMsgFail(level, "%s", hint); return VIR_HOST_VALIDATE_FAILURE(level); } -- 2.34.1