[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] maint: avoid comparisons to bool constants



HACKING already mentions that comparisons against literal 'true'
are unsafe; for consistency, also shorten comparisons against 'false'.

* src/conf/domain_conf.c (virDomainNetDefParseXML): Simplify.
* src/nwfilter/nwfilter_gentech_driver.c
(virNWFilterDomainFWUpdateCB): Likewise.
* tools/virsh.c (cmdVolDownload, vshCommandRun, vshPrintExtra):
Likewise.
---
 src/conf/domain_conf.c                 |    2 +-
 src/nwfilter/nwfilter_gentech_driver.c |    2 +-
 tools/virsh.c                          |    8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 70ea350..a936ea4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2581,7 +2581,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
                        xmlStrEqual(cur->name, BAD_CAST "source")) {
                 dev  = virXMLPropString(cur, "dev");
                 mode = virXMLPropString(cur, "mode");
-            } else if ((virtPortParsed == false) &&
+            } else if (!virtPortParsed &&
                        (def->type == VIR_DOMAIN_NET_TYPE_DIRECT) &&
                        xmlStrEqual(cur->name, BAD_CAST "virtualport")) {
                 if (virVirtualPortProfileParamsParseXML(cur, &virtPort))
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index f89fb79..3e8961d 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -1032,7 +1032,7 @@ virNWFilterDomainFWUpdateCB(void *payload,
                     cb->err = virNWFilterUpdateInstantiateFilter(cb->conn,
                                                                  net,
                                                                  &skipIface);
-                    if (cb->err == 0 && skipIface == true) {
+                    if (cb->err == 0 && skipIface) {
                         /* filter tree unchanged -- no update needed */
                         cb->err = virHashAddEntry(cb->skipInterfaces,
                                                   net->ifname,
diff --git a/tools/virsh.c b/tools/virsh.c
index e32680c..2b16714 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7318,7 +7318,7 @@ cmdVolDownload (vshControl *ctl, const vshCmd *cmd)

 cleanup:
     VIR_FORCE_CLOSE(fd);
-    if (ret == false && created)
+    if (!ret && created)
         unlink(file);
     if (vol)
         virStorageVolFree(vol);
@@ -11697,11 +11697,11 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
         if (enable_timing)
             GETTIMEOFDAY(&after);

-        if (ret == false)
+        if (!ret)
             virshReportError(ctl);

         /* try to automatically catch disconnections */
-        if ((ret == false) &&
+        if (!ret &&
             ((disconnected != 0) ||
              ((last_error != NULL) &&
               (((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
@@ -12105,7 +12105,7 @@ vshPrintExtra(vshControl *ctl, const char *format, ...)
     va_list ap;
     char *str;

-    if (ctl && ctl->quiet == true)
+    if (ctl && ctl->quiet)
         return;

     va_start(ap, format);
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]