]> xenbits.xensource.com Git - libvirt.git/commitdiff
avoid using STREQLEN with a literal; use STRPREFIX instead
authorJim Meyering <meyering@redhat.com>
Thu, 15 May 2008 14:21:34 +0000 (14:21 +0000)
committerJim Meyering <meyering@redhat.com>
Thu, 15 May 2008 14:21:34 +0000 (14:21 +0000)
Likewise for STRNEQLEN -> !STRPREFIX.
* src/nodeinfo.c (linuxNodeInfoCPUPopulate):
* src/qemu_conf.c (qemudNetworkIfaceConnect):
(qemudParseInterfaceXML):
* src/qemu_driver.c (qemudDomainBlockStats):
* src/remote_internal.c (call):
* src/stats_linux.c (xenLinuxDomainDeviceID):
* src/xend_internal.c (xend_parse_sexp_desc):
(xend_get, sexpr_to_xend_topology):
* src/xm_internal.c (xenXMConfigCacheRefresh)
(xenXMDomainFormatXML):

ChangeLog
src/nodeinfo.c
src/qemu_conf.c
src/qemu_driver.c
src/remote_internal.c
src/stats_linux.c
src/xend_internal.c
src/xm_internal.c

index abec731547ec87758252ca7b03b6802fbb2c8416..f7ed3ca36272ff5d8daa3973a2fbb3125eaa625b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 Thu May 15 09:12:08 CEST 2008 Jim Meyering <meyering@redhat.com>
 
+       Avoid using STREQLEN with a literal; use STRPREFIX instead
+       Likewise for STRNEQLEN -> !STRPREFIX.
+       * src/nodeinfo.c (linuxNodeInfoCPUPopulate):
+       * src/qemu_conf.c (qemudNetworkIfaceConnect):
+       (qemudParseInterfaceXML):
+       * src/qemu_driver.c (qemudDomainBlockStats):
+       * src/remote_internal.c (call):
+       * src/stats_linux.c (xenLinuxDomainDeviceID):
+       * src/xend_internal.c (xend_parse_sexp_desc):
+       (xend_get, sexpr_to_xend_topology):
+       * src/xm_internal.c (xenXMConfigCacheRefresh)
+       (xenXMDomainFormatXML):
+
        * Makefile.maint (sc_prohibit_strcmp): Also prohibit strncmp.
 
 Thu May 15 15:07:49 JST 2008 Atsushi SAKAI <sakaia@jp.fujitsu.com>
index e227c69e9de6fe2a1959b5b79ad74a7625cc8f0f..b2ef6ee66ed0feac77c4f45934593ff203db1dbd 100644 (file)
@@ -57,7 +57,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
     /* XXX hyperthreads */
     while (fgets(line, sizeof(line), cpuinfo) != NULL) {
         char *buf = line;
-        if (STREQLEN(buf, "processor", 9)) { /* aka a single logical CPU */
+        if (STRPREFIX(buf, "processor")) { /* aka a single logical CPU */
             buf += 9;
             while (*buf && c_isspace(*buf))
                 buf++;
@@ -68,7 +68,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
                 return -1;
             }
             nodeinfo->cpus++;
-        } else if (STREQLEN(buf, "cpu MHz", 7)) {
+        } else if (STRPREFIX(buf, "cpu MHz")) {
             char *p;
             unsigned int ui;
             buf += 9;
@@ -84,7 +84,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
                 /* Accept trailing fractional part.  */
                 && (*p == '\0' || *p == '.' || c_isspace(*p)))
                 nodeinfo->mhz = ui;
-        } else if (STREQLEN(buf, "cpu cores", 9)) { /* aka cores */
+        } else if (STRPREFIX(buf, "cpu cores")) { /* aka cores */
             char *p;
             unsigned int id;
             buf += 9;
index f31b33a69e30b0b56391a2ea4748b1dede93bde5..8ae0960cd0122b21040bb98b8ee3557118a3be20 100644 (file)
@@ -816,7 +816,7 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
                         (net->type == QEMUD_NET_BRIDGE)) &&
                        xmlStrEqual(cur->name, BAD_CAST "target")) {
                 ifname = xmlGetProp(cur, BAD_CAST "dev");
-                if (STREQLEN("vnet", (const char*)ifname, 4)) {
+                if (STRPREFIX((const char*)ifname, "vnet")) {
                     /* An auto-generated target name, blank it out */
                     xmlFree(ifname);
                     ifname = NULL;
@@ -2130,7 +2130,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
         }
         brname = network->bridge;
         if (net->dst.network.ifname[0] == '\0' ||
-            STREQLEN(net->dst.network.ifname, "vnet", 4) ||
+            STRPREFIX(net->dst.network.ifname, "vnet") ||
             strchr(net->dst.network.ifname, '%')) {
             strcpy(net->dst.network.ifname, "vnet%d");
         }
@@ -2138,7 +2138,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
     } else if (net->type == QEMUD_NET_BRIDGE) {
         brname = net->dst.bridge.brname;
         if (net->dst.bridge.ifname[0] == '\0' ||
-            STREQLEN(net->dst.bridge.ifname, "vnet", 4) ||
+            STRPREFIX(net->dst.bridge.ifname, "vnet") ||
             strchr(net->dst.bridge.ifname, '%')) {
             strcpy(net->dst.bridge.ifname, "vnet%d");
         }
index 7d527982425d61e0e872735ad40557b94fa8b10e..6ba617909c941fd2141de8756e5033a39607efef 100644 (file)
@@ -2650,12 +2650,12 @@ qemudDomainBlockStats (virDomainPtr dom,
      *   cdrom    to  ide1-cd0
      *   fd[a-]   to  floppy[0-]
      */
-    if (STREQLEN (path, "hd", 2) && path[2] >= 'a' && path[2] <= 'z')
+    if (STRPREFIX (path, "hd") && path[2] >= 'a' && path[2] <= 'z')
         snprintf (qemu_dev_name, sizeof (qemu_dev_name),
                   "ide0-hd%d", path[2] - 'a');
     else if (STREQ (path, "cdrom"))
         strcpy (qemu_dev_name, "ide1-cd0");
-    else if (STREQLEN (path, "fd", 2) && path[2] >= 'a' && path[2] <= 'z')
+    else if (STRPREFIX (path, "fd") && path[2] >= 'a' && path[2] <= 'z')
         snprintf (qemu_dev_name, sizeof (qemu_dev_name),
                   "floppy%d", path[2] - 'a');
     else {
@@ -2679,7 +2679,7 @@ qemudDomainBlockStats (virDomainPtr dom,
      * unlikely to be the name of a block device, we can use this
      * to detect if qemu supports the command.
      */
-    if (STREQLEN (info, "info ", 5)) {
+    if (STRPREFIX (info, "info ")) {
         free (info);
         qemudReportError (dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
                           "%s",
@@ -2711,19 +2711,19 @@ qemudDomainBlockStats (virDomainPtr dom,
             p += len+2;         /* Skip to first label. */
 
             while (*p) {
-                if (STREQLEN (p, "rd_bytes=", 9)) {
+                if (STRPREFIX (p, "rd_bytes=")) {
                     p += 9;
                     if (virStrToLong_ll (p, &dummy, 10, &stats->rd_bytes) == -1)
                         DEBUG ("error reading rd_bytes: %s", p);
-                } else if (STREQLEN (p, "wr_bytes=", 9)) {
+                } else if (STRPREFIX (p, "wr_bytes=")) {
                     p += 9;
                     if (virStrToLong_ll (p, &dummy, 10, &stats->wr_bytes) == -1)
                         DEBUG ("error reading wr_bytes: %s", p);
-                } else if (STREQLEN (p, "rd_operations=", 14)) {
+                } else if (STRPREFIX (p, "rd_operations=")) {
                     p += 14;
                     if (virStrToLong_ll (p, &dummy, 10, &stats->rd_req) == -1)
                         DEBUG ("error reading rd_req: %s", p);
-                } else if (STREQLEN (p, "wr_operations=", 14)) {
+                } else if (STRPREFIX (p, "wr_operations=")) {
                     p += 14;
                     if (virStrToLong_ll (p, &dummy, 10, &stats->wr_req) == -1)
                         DEBUG ("error reading wr_req: %s", p);
index 1b6e9d3aa3f8fddb2d59f51907f8d7e3cd9e7e3e..51e8eb77e92b3a7150821f11c1bc458fa0466aa4 100644 (file)
@@ -4339,7 +4339,7 @@ call (virConnectPtr conn, struct private_data *priv,
             rerror.domain == VIR_FROM_REMOTE &&
             rerror.code == VIR_ERR_RPC &&
             rerror.level == VIR_ERR_ERROR &&
-            STREQLEN(*rerror.message, "unknown procedure", 17)) {
+            STRPREFIX(*rerror.message, "unknown procedure")) {
             return -2;
         }
         server_error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, &rerror);
index cb647feb0925c74c8abad695c717930f4c7828e2..30a4990fb98a3c2b9a3d9b239488c736a7449d43 100644 (file)
@@ -230,7 +230,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
 
     /* Strip leading path if any */
     if (strlen(path) > 5 &&
-        STREQLEN(path, "/dev/", 5))
+        STRPREFIX(path, "/dev/"))
         path += 5;
 
     /*
@@ -251,7 +251,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
      */
 
     if (strlen (path) >= 4 &&
-        STREQLEN (path, "xvd", 3)) {
+        STRPREFIX (path, "xvd")) {
         /* Xen paravirt device handling */
         disk = (path[3] - 'a');
         if (disk < 0 || disk > 15) {
@@ -274,7 +274,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
 
         return (XENVBD_MAJOR * 256) + (disk * 16) + part;
     } else if (strlen (path) >= 3 &&
-               STREQLEN (path, "sd", 2)) {
+               STRPREFIX (path, "sd")) {
         /* SCSI device handling */
         int majors[] = { SCSI_DISK0_MAJOR, SCSI_DISK1_MAJOR, SCSI_DISK2_MAJOR,
                          SCSI_DISK3_MAJOR, SCSI_DISK4_MAJOR, SCSI_DISK5_MAJOR,
@@ -318,7 +318,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
 
         return (majors[disk/16] * 256) + ((disk%16) * 16) + part;
     } else if (strlen (path) >= 3 &&
-               STREQLEN (path, "hd", 2)) {
+               STRPREFIX (path, "hd")) {
         /* IDE device handling */
         int majors[] = { IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR,
                          IDE4_MAJOR, IDE5_MAJOR, IDE6_MAJOR, IDE7_MAJOR,
index 6aecfdd557bde4dca04dec1036f21fb3dadcfaf6..590fabeede49de8559379f7ed2d18d482cf0eee2 100644 (file)
@@ -487,7 +487,7 @@ xend_get(virConnectPtr xend, const char *path,
     close(s);
 
     if (((ret < 0) || (ret >= 300)) &&
-        ((ret != 404) || (STRNEQLEN(path, "/xend/domain/", 13)))) {
+        ((ret != 404) || (!STRPREFIX(path, "/xend/domain/")))) {
         virXendError(xend, VIR_ERR_GET_FAILED, content);
     }
 
@@ -1943,7 +1943,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
                 }
             }
 
-            if (STREQLEN(dst, "ioemu:", 6))
+            if (STRPREFIX(dst, "ioemu:"))
                 dst += 6;
 
             /* New style disk config from Xen >= 3.0.3 */
@@ -2399,7 +2399,7 @@ sexpr_to_xend_topology(virConnectPtr conn,
             goto parse_error;
         cur++;
         virSkipSpaces(&cur);
-        if (STREQLEN(cur, "no cpus", 7)) {
+        if (STRPREFIX(cur, "no cpus")) {
             nb_cpus = 0;
             for (cpu = 0; cpu < numCpus; cpu++)
                 cpuset[cpu] = 0;
index 393700c1c1d1cdb3d53a99ef3e7036975a7d869a..97311256f7d8e4b1b8ccfc24ba6130a47a1e4c42 100644 (file)
@@ -353,19 +353,19 @@ static int xenXMConfigCacheRefresh (virConnectPtr conn) {
          */
 
         /* Like 'dot' files... */
-        if (STREQLEN(ent->d_name, ".", 1))
+        if (STRPREFIX(ent->d_name, "."))
             continue;
         /* ...and the XenD server config file */
-        if (STREQLEN(ent->d_name, XEND_CONFIG_FILE, strlen(XEND_CONFIG_FILE)))
+        if (STRPREFIX(ent->d_name, XEND_CONFIG_FILE))
             continue;
         /* ...and random PCI config cruft */
-        if (STREQLEN(ent->d_name, XEND_PCI_CONFIG_PREFIX, strlen(XEND_PCI_CONFIG_PREFIX)))
+        if (STRPREFIX(ent->d_name, XEND_PCI_CONFIG_PREFIX))
             continue;
         /* ...and the example domain configs */
-        if (STREQLEN(ent->d_name, XM_EXAMPLE_PREFIX, strlen(XM_EXAMPLE_PREFIX)))
+        if (STRPREFIX(ent->d_name, XM_EXAMPLE_PREFIX))
             continue;
         /* ...and the QEMU networking script */
-        if (STREQLEN(ent->d_name, QEMU_IF_SCRIPT, strlen(QEMU_IF_SCRIPT)))
+        if (STRPREFIX(ent->d_name, QEMU_IF_SCRIPT))
             continue;
 
         /* ...and editor backups */
@@ -778,7 +778,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
             }
 
             /* And the source driver sub-type */
-            if (STREQLEN(drvName, "tap", 3)) {
+            if (STRPREFIX(drvName, "tap")) {
                 if (!(tmp1 = strchr(tmp+1, ':')) || !tmp1[0])
                     goto skipdisk;
                 strncpy(drvType, tmp+1, (tmp1-(tmp+1)));
@@ -795,7 +795,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
             }
 
             /* Remove legacy ioemu: junk */
-            if (STREQLEN(dev, "ioemu:", 6)) {
+            if (STRPREFIX(dev, "ioemu:")) {
                 memmove(dev, dev+6, strlen(dev)-5);
             }