virStrToLong* guarantees (via strtol) that the end pointer will be set
to the point at which parsing stopped (even on failure, this point is
the start of the input string).
* src/esx/esx_driver.c (esxGetVersion): Remove pointless
conditional.
* src/qemu/qemu_conf.c (qemuParseCommandLinePCI)
(qemuParseCommandLineUSB, qemuParseCommandLineSmp): Likewise.
* src/qemu/qemu_monitor_text.c
(qemuMonitorTextGetMigrationStatus): Likewise.
---
src/esx/esx_driver.c | 6 ++----
src/qemu/qemu_conf.c | 14 ++++++--------
src/qemu/qemu_monitor_text.c | 6 +++---
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index bbe8a51..f07493e 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -690,13 +690,11 @@ esxGetVersion(virConnectPtr conn, unsigned long *version)
temp = (char *)priv->host->service->about->version;
/* Expecting 'major.minor.release' format */
- if (virStrToLong_ui(temp, &temp, 10, &major) < 0 || temp == NULL ||
- *temp != '.') {
+ if (virStrToLong_ui(temp, &temp, 10, &major) < 0 || *temp != '.')
{
goto failure;
}
- if (virStrToLong_ui(temp + 1, &temp, 10, &minor) < 0 || temp == NULL ||
- *temp != '.') {
+ if (virStrToLong_ui(temp + 1, &temp, 10, &minor) < 0 || *temp !=
'.') {
goto failure;
}
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 8f6f7ec..5d0b211 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -5217,14 +5217,14 @@ qemuParseCommandLinePCI(const char *val)
}
start = val + strlen("host=");
- if (virStrToLong_i(start, &end, 16, &bus) < 0 || !end || *end !=
':') {
+ if (virStrToLong_i(start, &end, 16, &bus) < 0 || *end != ':') {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot extract PCI device bus '%s'"), val);
VIR_FREE(def);
goto cleanup;
}
start = end + 1;
- if (virStrToLong_i(start, &end, 16, &slot) < 0 || !end || *end !=
'.') {
+ if (virStrToLong_i(start, &end, 16, &slot) < 0 || *end != '.') {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot extract PCI device slot '%s'"),
val);
VIR_FREE(def);
@@ -5275,7 +5275,7 @@ qemuParseCommandLineUSB(const char *val)
start = val + strlen("host:");
if (strchr(start, ':')) {
- if (virStrToLong_i(start, &end, 16, &first) < 0 || !end || *end !=
':') {
+ if (virStrToLong_i(start, &end, 16, &first) < 0 || *end !=
':') {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot extract USB device vendor '%s'"),
val);
VIR_FREE(def);
@@ -5289,7 +5289,7 @@ qemuParseCommandLineUSB(const char *val)
goto cleanup;
}
} else {
- if (virStrToLong_i(start, &end, 10, &first) < 0 || !end || *end !=
'.') {
+ if (virStrToLong_i(start, &end, 10, &first) < 0 || *end !=
'.') {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot extract USB device bus '%s'"),
val);
VIR_FREE(def);
@@ -5573,13 +5573,11 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
for (i = 0; i < nkws; i++) {
if (vals[i] == NULL) {
if (i > 0 ||
- virStrToLong_i(kws[i], &end, 10, &n) < 0 ||
- !end || *end != '\0')
+ virStrToLong_i(kws[i], &end, 10, &n) < 0 || *end !=
'\0')
goto syntax;
dom->vcpus = n;
} else {
- if (virStrToLong_i(vals[i], &end, 10, &n) < 0 ||
- !end || *end != '\0')
+ if (virStrToLong_i(vals[i], &end, 10, &n) < 0 || *end !=
'\0')
goto syntax;
if (STREQ(kws[i], "sockets"))
sockets = n;
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 1596e59..a199de7 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1075,7 +1075,7 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
goto done;
tmp += strlen(MIGRATION_TRANSFER_PREFIX);
- if (virStrToLong_ull(tmp, &end, 10, transferred) < 0 || !end) {
+ if (virStrToLong_ull(tmp, &end, 10, transferred) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data transferred statistic
%s"), tmp);
goto cleanup;
@@ -1087,7 +1087,7 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
goto done;
tmp += strlen(MIGRATION_REMAINING_PREFIX);
- if (virStrToLong_ull(tmp, &end, 10, remaining) < 0 || !end) {
+ if (virStrToLong_ull(tmp, &end, 10, remaining) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data remaining statistic
%s"), tmp);
goto cleanup;
@@ -1098,7 +1098,7 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
goto done;
tmp += strlen(MIGRATION_TOTAL_PREFIX);
- if (virStrToLong_ull(tmp, &end, 10, total) < 0 || !end) {
+ if (virStrToLong_ull(tmp, &end, 10, total) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data total statistic
%s"), tmp);
goto cleanup;
--
1.6.6.1