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

[libvirt] [PATCH] conf: remove redundant ()



I almost copied-and-pasted some redundant () into my new code,
and figured a general cleanup prereq patch would be better instead.

* src/conf/domain_conf.c (virDomainLeaseDefParseXML)
(virDomainDiskDefParseXML, virDomainFSDefParseXML)
(virDomainActualNetDefParseXML, virDomainNetDefParseXML)
(virDomainGraphicsDefParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevFind)
(virDomainControllerInsertPreAlloced, virDomainDefParseXML)
(virDomainObjParseXML, virDomainCpuSetFormat)
(virDomainCpuSetParse, virDomainDiskDefFormat)
(virDomainActualNetDefFormat, virDomainNetDefFormat)
(virDomainTimerDefFormat, virDomainGraphicsListenDefFormat)
(virDomainDefFormatInternal, virDomainNetGetActualHostdev)
(virDomainNetGetActualBandwidth, virDomainGraphicsGetListen):
Reduce extra (), per coding styles.
---

This touches enough lines that I won't claim it to be trivial, but
it should have no semantic impact.

 src/conf/domain_conf.c |  210 +++++++++++++++++++++++------------------------
 1 files changed, 103 insertions(+), 107 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8f352ea..0d87970 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3233,14 +3233,13 @@ virDomainLeaseDefParseXML(xmlNodePtr node)
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
-            if ((key == NULL) &&
-                (xmlStrEqual(cur->name, BAD_CAST "key"))) {
+            if (!key && xmlStrEqual(cur->name, BAD_CAST "key")) {
                 key = (char *)xmlNodeGetContent(cur);
-            } else if ((lockspace == NULL) &&
-                (xmlStrEqual(cur->name, BAD_CAST "lockspace"))) {
+            } else if (!lockspace &&
+                       xmlStrEqual(cur->name, BAD_CAST "lockspace")) {
                 lockspace = (char *)xmlNodeGetContent(cur);
-            } else if ((path == NULL) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "target"))) {
+            } else if (!path &&
+                       xmlStrEqual(cur->name, BAD_CAST "target")) {
                 path = virXMLPropString(cur, "path");
                 offset = virXMLPropString(cur, "offset");
             }
@@ -3355,8 +3354,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
-            if ((source == NULL && hosts == NULL) &&
-                (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+            if (!source && !hosts &&
+                xmlStrEqual(cur->name, BAD_CAST "source")) {

                 sourceNode = cur;

@@ -3433,8 +3432,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                    those broken apps */
                 if (source && STREQ(source, ""))
                     VIR_FREE(source);
-            } else if ((target == NULL) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "target"))) {
+            } else if (!target &&
+                       xmlStrEqual(cur->name, BAD_CAST "target")) {
                 target = virXMLPropString(cur, "dev");
                 bus = virXMLPropString(cur, "bus");
                 tray = virXMLPropString(cur, "tray");
@@ -3444,8 +3443,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                 if (target &&
                     STRPREFIX(target, "ioemu:"))
                     memmove(target, target+6, strlen(target)-5);
-            } else if ((driverName == NULL) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "driver"))) {
+            } else if (!driverName &&
+                       xmlStrEqual(cur->name, BAD_CAST "driver")) {
                 driverName = virXMLPropString(cur, "name");
                 driverType = virXMLPropString(cur, "type");
                 cachetag = virXMLPropString(cur, "cache");
@@ -3579,8 +3578,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                                                            cur);
                 if (encryption == NULL)
                     goto error;
-            } else if ((serial == NULL) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "serial"))) {
+            } else if (!serial &&
+                       xmlStrEqual(cur->name, BAD_CAST "serial")) {
                 serial = (char *)xmlNodeGetContent(cur);
             } else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
                 /* boot is parsed as part of virDomainDeviceInfoParseXML */
@@ -4099,8 +4098,8 @@ virDomainFSDefParseXML(xmlNodePtr node,
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
-            if ((source == NULL) &&
-                (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+            if (!source &&
+                xmlStrEqual(cur->name, BAD_CAST "source")) {

                 if (def->type == VIR_DOMAIN_FS_TYPE_MOUNT)
                     source = virXMLPropString(cur, "dir");
@@ -4110,12 +4109,12 @@ virDomainFSDefParseXML(xmlNodePtr node,
                     source = virXMLPropString(cur, "dev");
                 else if (def->type == VIR_DOMAIN_FS_TYPE_TEMPLATE)
                     source = virXMLPropString(cur, "name");
-            } else if ((target == NULL) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "target"))) {
+            } else if (!target &&
+                       xmlStrEqual(cur->name, BAD_CAST "target")) {
                 target = virXMLPropString(cur, "dir");
             } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
                 def->readonly = 1;
-            } else if ((fsdriver == NULL) && (xmlStrEqual(cur->name, BAD_CAST "driver"))) {
+            } else if (!fsdriver && xmlStrEqual(cur->name, BAD_CAST "driver")) {
                 fsdriver = virXMLPropString(cur, "type");
                 wrpolicy = virXMLPropString(cur, "wrpolicy");
             }
@@ -4261,8 +4260,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
          */
         addrtype = virXPathString("string(./source/address/@type)", ctxt);
         /* if not explicitly stated, source/vendor implies usb device */
-        if ((!addrtype) && virXPathNode("./source/vendor", ctxt) &&
-            ((addrtype = strdup("usb")) == NULL)) {
+        if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
+            (addrtype = strdup("usb")) == NULL) {
             virReportOOMError();
             goto error;
         }
@@ -4361,61 +4360,60 @@ virDomainNetDefParseXML(virCapsPtr caps,
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
-            if ((macaddr == NULL) &&
-                (xmlStrEqual(cur->name, BAD_CAST "mac"))) {
+            if (!macaddr && xmlStrEqual(cur->name, BAD_CAST "mac")) {
                 macaddr = virXMLPropString(cur, "address");
-            } else if ((network == NULL) &&
-                       (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+            } else if (!network &&
+                       def->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
+                       xmlStrEqual(cur->name, BAD_CAST "source")) {
                 network = virXMLPropString(cur, "network");
                 portgroup = virXMLPropString(cur, "portgroup");
-            } else if ((internal == NULL) &&
-                       (def->type == VIR_DOMAIN_NET_TYPE_INTERNAL) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+            } else if (!internal &&
+                       def->type == VIR_DOMAIN_NET_TYPE_INTERNAL &&
+                       xmlStrEqual(cur->name, BAD_CAST "source")) {
                 internal = virXMLPropString(cur, "name");
-            } else if ((network == NULL) &&
-                       (def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+            } else if (!network &&
+                       def->type == VIR_DOMAIN_NET_TYPE_BRIDGE &&
+                       xmlStrEqual(cur->name, BAD_CAST "source")) {
                 bridge = virXMLPropString(cur, "bridge");
-            } else if ((dev == NULL) &&
+            } else if (!dev &&
                        (def->type == VIR_DOMAIN_NET_TYPE_ETHERNET ||
                         def->type == VIR_DOMAIN_NET_TYPE_DIRECT) &&
                        xmlStrEqual(cur->name, BAD_CAST "source")) {
                 dev  = virXMLPropString(cur, "dev");
                 mode = virXMLPropString(cur, "mode");
-            } else if ((virtPort == NULL) &&
-                       ((def->type == VIR_DOMAIN_NET_TYPE_DIRECT) ||
-                        (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) ||
-                        (def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) ||
-                        (def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) &&
+            } else if (!virtPort &&
+                       (def->type == VIR_DOMAIN_NET_TYPE_DIRECT ||
+                        def->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
+                        def->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+                        def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) &&
                        xmlStrEqual(cur->name, BAD_CAST "virtualport")) {
                 if (!(virtPort = virNetDevVPortProfileParse(cur)))
                     goto error;
-            } else if ((network == NULL) &&
-                       ((def->type == VIR_DOMAIN_NET_TYPE_SERVER) ||
-                        (def->type == VIR_DOMAIN_NET_TYPE_CLIENT) ||
-                        (def->type == VIR_DOMAIN_NET_TYPE_MCAST)) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "source"))) {
+            } else if (!network &&
+                       (def->type == VIR_DOMAIN_NET_TYPE_SERVER ||
+                        def->type == VIR_DOMAIN_NET_TYPE_CLIENT ||
+                        def->type == VIR_DOMAIN_NET_TYPE_MCAST) &&
+                       xmlStrEqual(cur->name, BAD_CAST "source")) {
                 address = virXMLPropString(cur, "address");
                 port = virXMLPropString(cur, "port");
-            } else if ((address == NULL) &&
+            } else if (!address &&
                        (def->type == VIR_DOMAIN_NET_TYPE_ETHERNET ||
                         def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
-                       (xmlStrEqual(cur->name, BAD_CAST "ip"))) {
+                       xmlStrEqual(cur->name, BAD_CAST "ip")) {
                 address = virXMLPropString(cur, "address");
-            } else if ((ifname == NULL) &&
+            } else if (!ifname &&
                        xmlStrEqual(cur->name, BAD_CAST "target")) {
                 ifname = virXMLPropString(cur, "dev");
-                if ((ifname != NULL) &&
-                    ((flags & VIR_DOMAIN_XML_INACTIVE) &&
-                      (STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX)))) {
+                if (ifname &&
+                    (flags & VIR_DOMAIN_XML_INACTIVE) &&
+                    STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX)) {
                     /* An auto-generated target name, blank it out */
                     VIR_FREE(ifname);
                 }
-            } else if ((linkstate == NULL) &&
+            } else if (!linkstate &&
                        xmlStrEqual(cur->name, BAD_CAST "link")) {
                 linkstate = virXMLPropString(cur, "state");
-            } else if ((script == NULL) &&
+            } else if (!script &&
                        xmlStrEqual(cur->name, BAD_CAST "script")) {
                 script = virXMLPropString(cur, "path");
             } else if (xmlStrEqual (cur->name, BAD_CAST "model")) {
@@ -4435,9 +4433,9 @@ virDomainNetDefParseXML(virCapsPtr caps,
                 devaddr = virXMLPropString(cur, "devaddr");
             } else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
                 /* boot is parsed as part of virDomainDeviceInfoParseXML */
-            } else if ((actual == NULL) &&
+            } else if (!actual &&
                        (flags & VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET) &&
-                       (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
+                       def->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
                        xmlStrEqual(cur->name, BAD_CAST "actual")) {
                 if (virDomainActualNetDefParseXML(cur, ctxt, def,
                                                   &actual, flags) < 0) {
@@ -4598,7 +4596,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
         def->data.direct.linkdev = dev;
         dev = NULL;

-        if ((flags & VIR_DOMAIN_XML_INACTIVE))
+        if (flags & VIR_DOMAIN_XML_INACTIVE)
             VIR_FREE(ifname);

         break;
@@ -4614,7 +4612,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
          */
         addrtype = virXPathString("string(./source/address/@type)", ctxt);
         /* if not explicitly stated, source/vendor implies usb device */
-        if ((!addrtype) && virXPathNode("./source/vendor", ctxt) &&
+        if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
             ((addrtype = strdup("usb")) == NULL)) {
             virReportOOMError();
             goto error;
@@ -4660,8 +4658,8 @@ virDomainNetDefParseXML(virCapsPtr caps,
     if (def->model && STREQ(def->model, "virtio")) {
         if (backend != NULL) {
             int name;
-            if (((name = virDomainNetBackendTypeFromString(backend)) < 0) ||
-                (name == VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT)) {
+            if ((name = virDomainNetBackendTypeFromString(backend)) < 0 ||
+                name == VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT) {
                 virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                      _("Unknown interface <driver name='%s'> "
                                        "has been specified"),
@@ -4672,8 +4670,8 @@ virDomainNetDefParseXML(virCapsPtr caps,
         }
         if (txmode != NULL) {
             int m;
-            if (((m = virDomainNetVirtioTxModeTypeFromString(txmode)) < 0) ||
-                (m == VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT)) {
+            if ((m = virDomainNetVirtioTxModeTypeFromString(txmode)) < 0 ||
+                m == VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT) {
                 virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                      _("Unknown interface <driver txmode='%s'> "
                                        "has been specified"),
@@ -5772,8 +5770,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
      * type='network' and we're looking at live XML (i.e. *not*
      * inactive). It is otherwise ignored. */
     if (address && address[0] &&
-        ((def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) ||
-         ((def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) &&
+        (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
+         (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
           !(flags & VIR_DOMAIN_XML_INACTIVE)))) {
         def->address = address;
         address = NULL;
@@ -5836,9 +5834,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
         goto error;
     }

-    if ((def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) ||
-        (def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) ||
-        (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE)) {
+    if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+        def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
+        def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {

         /* parse the <listen> subelements for graphics types that support it */
         nListens = virXPathNodeSet("./listen", ctxt, &listenNodes);
@@ -6548,7 +6546,7 @@ virDomainVideoAccelDefParseXML(const xmlNodePtr node) {
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
-            if ((support3d == NULL) && (support2d == NULL) &&
+            if (!support3d && !support2d &&
                 xmlStrEqual(cur->name, BAD_CAST "acceleration")) {
                 support3d = virXMLPropString(cur, "accel3d");
                 support2d = virXMLPropString(cur, "accel2d");
@@ -6557,7 +6555,7 @@ virDomainVideoAccelDefParseXML(const xmlNodePtr node) {
         cur = cur->next;
     }

-    if ((support3d == NULL) && (support2d == NULL))
+    if (!support3d && !support2d)
         return NULL;

     if (VIR_ALLOC(def) < 0) {
@@ -6603,7 +6601,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
-            if ((type == NULL) && (vram == NULL) && (heads == NULL) &&
+            if (!type && !vram && !heads &&
                 xmlStrEqual(cur->name, BAD_CAST "model")) {
                 type = virXMLPropString(cur, "type");
                 vram = virXMLPropString(cur, "vram");
@@ -6990,32 +6988,32 @@ virDomainHostdevFind(virDomainDefPtr def,
         virDomainHostdevDefPtr compare = def->hostdevs[i];
         virDomainHostdevSubsysPtr c_subsys = &compare->source.subsys;

-        if ((compare->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) ||
-            (c_subsys->type != m_subsys->type)) {
+        if (compare->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+            c_subsys->type != m_subsys->type) {
             continue;
         }

         switch (m_subsys->type)
         {
         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
-            if ((c_subsys->u.pci.domain   == m_subsys->u.pci.domain) &&
-                (c_subsys->u.pci.bus      == m_subsys->u.pci.bus) &&
-                (c_subsys->u.pci.slot     == m_subsys->u.pci.slot) &&
-                (c_subsys->u.pci.function == m_subsys->u.pci.function)) {
+            if (c_subsys->u.pci.domain == m_subsys->u.pci.domain &&
+                c_subsys->u.pci.bus == m_subsys->u.pci.bus &&
+                c_subsys->u.pci.slot == m_subsys->u.pci.slot &&
+                c_subsys->u.pci.function == m_subsys->u.pci.function) {
                 *found = compare;
             }
                 break;
         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
             if (m_subsys->u.usb.bus && m_subsys->u.usb.device) {
                 /* specified by bus location on host */
-                if ((c_subsys->u.usb.bus    == m_subsys->u.usb.bus) &&
-                    (c_subsys->u.usb.device == m_subsys->u.usb.device)) {
+                if (c_subsys->u.usb.bus == m_subsys->u.usb.bus &&
+                    c_subsys->u.usb.device == m_subsys->u.usb.device) {
                     *found = compare;
                 }
             } else {
                 /* specified by product & vendor id */
-                if ((c_subsys->u.usb.product == m_subsys->u.usb.product) &&
-                    (c_subsys->u.usb.vendor  == m_subsys->u.usb.vendor)) {
+                if (c_subsys->u.usb.product == m_subsys->u.usb.product &&
+                    c_subsys->u.usb.vendor == m_subsys->u.usb.vendor) {
                     *found = compare;
                 }
             }
@@ -7249,8 +7247,8 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
     for (i = (def->ncontrollers - 1) ; i >= 0 ; i--) {
         /* If bus matches and current controller is after
          * new controller, then new controller should go here */
-        if ((def->controllers[i]->type == controller->type) &&
-            (def->controllers[i]->idx > controller->idx)) {
+        if (def->controllers[i]->type == controller->type &&
+            def->controllers[i]->idx > controller->idx) {
             insertAt = i;
         } else if (def->controllers[i]->type == controller->type &&
                    insertAt == -1) {
@@ -7673,7 +7671,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
     }

     if (!(flags & VIR_DOMAIN_XML_INACTIVE))
-        if ((virXPathLong("string(./@id)", ctxt, &id)) < 0)
+        if (virXPathLong("string(./@id)", ctxt, &id) < 0)
             id = -1;
     def->id = (int)id;

@@ -7988,7 +7986,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         cur = nodes[0]->children;
         while (cur != NULL) {
             if (cur->type == XML_ELEMENT_NODE) {
-                if ((xmlStrEqual(cur->name, BAD_CAST "memory"))) {
+                if (xmlStrEqual(cur->name, BAD_CAST "memory")) {
                     tmp = virXMLPropString(cur, "nodeset");

                     if (tmp) {
@@ -8397,9 +8395,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         def->nets[def->nnets++] = net;

         /* <interface type='hostdev'> must also be in the hostdevs array */
-        if ((net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) &&
-            (virDomainHostdevInsert(def, &net->data.hostdev.def) < 0)) {
-                goto no_memory;
+        if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
+            virDomainHostdevInsert(def, &net->data.hostdev.def) < 0) {
+            goto no_memory;
         }
     }
     VIR_FREE(nodes);
@@ -8985,7 +8983,7 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps,

     virDomainObjSetState(obj, state, reason);

-    if ((virXPathLong("string(./@pid)", ctxt, &val)) < 0) {
+    if (virXPathLong("string(./@pid)", ctxt, &val) < 0) {
         virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                              "%s", _("invalid pid"));
         goto error;
@@ -10275,7 +10273,7 @@ virDomainCpuSetFormat(char *cpuset, int maxcpu)
     int start, cur;
     int first = 1;

-    if ((cpuset == NULL) || (maxcpu <= 0) || (maxcpu > 100000))
+    if (!cpuset || maxcpu <= 0 || maxcpu > 100000)
         return NULL;

     cur = 0;
@@ -10339,8 +10337,7 @@ virDomainCpuSetParse(const char *str, char sep,
     int i, start, last;
     int neg = 0;

-    if ((str == NULL) || (cpuset == NULL) || (maxcpu <= 0) ||
-        (maxcpu > 100000))
+    if (!str || !cpuset || maxcpu <= 0 || maxcpu > 100000)
         return -1;

     cur = str;
@@ -10353,7 +10350,7 @@ virDomainCpuSetParse(const char *str, char sep,
         cpuset[i] = 0;
     ret = 0;

-    while ((*cur != 0) && (*cur != sep)) {
+    while (*cur != 0 && *cur != sep) {
         /*
          * 3 constructs are allowed:
          *     - N   : a single CPU number
@@ -10371,7 +10368,7 @@ virDomainCpuSetParse(const char *str, char sep,
         if (start < 0)
             goto parse_error;
         virSkipSpaces(&cur);
-        if ((*cur == ',') || (*cur == 0) || (*cur == sep)) {
+        if (*cur == ',' || *cur == 0 || *cur == sep) {
             if (neg) {
                 if (cpuset[start] == 1) {
                     cpuset[start] = 0;
@@ -10403,7 +10400,7 @@ virDomainCpuSetParse(const char *str, char sep,
             cur++;
             virSkipSpaces(&cur);
             neg = 0;
-        } else if ((*cur == 0) || (*cur == sep)) {
+        } else if (*cur == 0 || *cur == sep) {
             break;
         } else
             goto parse_error;
@@ -10842,7 +10839,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
                       def->dst, bus);
     if ((def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY ||
          def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
-        (def->tray_status != VIR_DOMAIN_DISK_TRAY_CLOSED))
+        def->tray_status != VIR_DOMAIN_DISK_TRAY_CLOSED)
         virBufferAsprintf(buf, " tray='%s'/>\n",
                           virDomainDiskTrayTypeToString(def->tray_status));
     else
@@ -11138,7 +11135,7 @@ virDomainActualNetDefFormat(virBufferPtr buf,
     }

     virBufferAsprintf(buf, "      <actual type='%s'", type);
-    if ((def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) &&
+    if (def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
         def->data.hostdev.def.managed) {
         virBufferAddLit(buf, " managed='yes'");
     }
@@ -11223,7 +11220,7 @@ virDomainNetDefFormat(virBufferPtr buf,
     }

     virBufferAsprintf(buf, "    <interface type='%s'", type);
-    if ((def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) &&
+    if (def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
         def->data.hostdev.def.managed) {
         virBufferAddLit(buf, " managed='yes'");
     }
@@ -11879,9 +11876,8 @@ virDomainTimerDefFormat(virBufferPtr buf,
         }
     }

-    if ((def->catchup.threshold == 0)
-        && (def->catchup.slew == 0)
-        && (def->catchup.limit == 0)) {
+    if (def->catchup.threshold == 0 && def->catchup.slew == 0 &&
+        def->catchup.limit == 0) {
         virBufferAddLit(buf, "/>\n");
     } else {
         virBufferAddLit(buf, ">\n");
@@ -11941,8 +11937,8 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,
     }

     if (def->address &&
-        ((def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) ||
-         ((def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) &&
+        (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
+         (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
           !(flags & VIR_DOMAIN_XML_INACTIVE)))) {
         /* address may also be set to show current status when type='network',
          * but we don't want to print that if INACTIVE data is requested. */
@@ -12719,8 +12715,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
          * hostdev in a higher-level device (e.g. virDomainNetDef),
          * and will have already been formatted there.
          */
-        if ((def->hostdevs[n]->parent.type == VIR_DOMAIN_DEVICE_NONE) &&
-            (virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0)) {
+        if (def->hostdevs[n]->parent.type == VIR_DOMAIN_DEVICE_NONE &&
+            virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) {
             goto cleanup;
         }
     }
@@ -14615,8 +14611,8 @@ virDomainNetGetActualHostdev(virDomainNetDefPtr iface)
 {
     if (iface->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)
         return &iface->data.hostdev.def;
-    if ((iface->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
-        (iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) {
+    if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
+        iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
         return &iface->data.network.actual->data.hostdev.def;
     }
     return NULL;
@@ -14653,7 +14649,7 @@ virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface)
 virNetDevBandwidthPtr
 virDomainNetGetActualBandwidth(virDomainNetDefPtr iface)
 {
-    if ((iface->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
+    if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
         iface->data.network.actual && iface->data.network.actual->bandwidth) {
         return iface->data.network.actual->bandwidth;
     }
@@ -14668,9 +14664,9 @@ virDomainNetGetActualBandwidth(virDomainNetDefPtr iface)
 static virDomainGraphicsListenDefPtr
 virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t ii, bool force0)
 {
-    if ((def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) ||
-        (def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) ||
-        (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE)) {
+    if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+        def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
+        def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {

         if (!def->listens && (ii == 0) && force0) {
             if (VIR_ALLOC(def->listens) < 0)
-- 
1.7.7.6


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