]> xenbits.xensource.com Git - libvirt.git/commitdiff
maint: remove redundant tests after virStrToLong
authorEric Blake <eblake@redhat.com>
Tue, 30 Mar 2010 21:07:24 +0000 (15:07 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 31 Mar 2010 14:58:46 +0000 (08:58 -0600)
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
src/qemu/qemu_conf.c
src/qemu/qemu_monitor_text.c

index 663c5600cced9352a44535a8a32d848555246ac9..20376e926d022f7b52d5f727547f322ba5769e02 100644 (file)
@@ -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;
     }
 
index 8f6f7ecc6ead2b37763833f912d3c32b08955b86..5d0b211f805e9157937bdf213c945f65c41b1d02 100644 (file)
@@ -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;
index 1596e59327e0619b8da92f79bd476c681a5f89cb..a199de7659fb826769e650c8ddd4584e05c365f0 100644 (file)
@@ -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;