Patch to get rid of index(3) and rindex(3)

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

 



According to index(3):

[index and rindex appeared in] 4.3BSD; marked as LEGACY in POSIX.1-2001.

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
? src/libvirt_la-xml.loT
Index: qemud/driver.c
===================================================================
RCS file: /data/cvs/libvirt/qemud/driver.c,v
retrieving revision 1.20
diff -u -r1.20 driver.c
--- qemud/driver.c	15 Apr 2007 19:58:44 -0000	1.20
+++ qemud/driver.c	15 Jun 2007 13:26:53 -0000
@@ -158,7 +158,7 @@
         if (!strncmp(line, "processor\t", 10)) { /* aka a single logical CPU */
             (*cpus)++;
         } else if (!strncmp(line, "cpu MHz\t", 8)) {
-            char *offset = index(line, ':');
+            char *offset = strchr(line, ':');
             if (!offset)
                 continue;
             offset++;
@@ -167,7 +167,7 @@
             *mhz = (unsigned int)strtol(offset, NULL, 10);
         } else if (!strncmp(line, "physical id\t", 12)) { /* aka socket */
             unsigned int id;
-            char *offset = index(line, ':');
+            char *offset = strchr(line, ':');
             if (!offset)
                 continue;
             offset++;
@@ -178,7 +178,7 @@
                 *sockets = (id + 1);
         } else if (!strncmp(line, "cpu cores\t", 9)) { /* aka cores */
             unsigned int id;
-            char *offset = index(line, ':');
+            char *offset = strchr(line, ':');
             if (!offset)
                 continue;
             offset++;
Index: src/test.c
===================================================================
RCS file: /data/cvs/libvirt/src/test.c,v
retrieving revision 1.31
diff -u -r1.31 test.c
--- src/test.c	5 Jun 2007 12:06:08 -0000	1.31
+++ src/test.c	15 Jun 2007 13:26:54 -0000
@@ -504,7 +504,7 @@
     if (filename[0] == '/')
         return strdup(filename);
 
-    offset = rindex(relativeTo, '/');
+    offset = strrchr(relativeTo, '/');
     if ((baseLen = (offset-relativeTo+1))) {
         char *absFile = malloc(baseLen + strlen(filename) + 1);
         strncpy(absFile, relativeTo, baseLen);
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.82
diff -u -r1.82 virsh.c
--- src/virsh.c	15 Jun 2007 08:18:55 -0000	1.82
+++ src/virsh.c	15 Jun 2007 13:26:56 -0000
@@ -1576,7 +1576,7 @@
             virDomainFree(dom);
             return FALSE;
         }
-        cpulist = index(cpulist, ',');
+        cpulist = strchr(cpulist, ',');
         if (cpulist)
             cpulist++;
     } while (cpulist);
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.117
diff -u -r1.117 xend_internal.c
--- src/xend_internal.c	7 Jun 2007 13:50:18 -0000	1.117
+++ src/xend_internal.c	15 Jun 2007 13:26:58 -0000
@@ -1571,7 +1571,7 @@
 
             /* New style disk config from Xen >= 3.0.3 */
             if (xendConfigVersion > 1) {
-                offset = rindex(dst, ':');
+                offset = strrchr(dst, ':');
                 if (offset) {
                     if (!strcmp(offset, ":cdrom")) {
                         cdrom = 1;
Index: src/xm_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.29
diff -u -r1.29 xm_internal.c
--- src/xm_internal.c	7 Jun 2007 18:21:58 -0000	1.29
+++ src/xm_internal.c	15 Jun 2007 13:27:00 -0000
@@ -734,7 +734,7 @@
              */
 
             /* Extract the source */
-            if (!(offset = index(head, ',')) || offset[0] == '\0')
+            if (!(offset = strchr(head, ',')) || offset[0] == '\0')
                 goto skipdisk;
             if ((offset - head) >= (PATH_MAX-1))
                 goto skipdisk;
@@ -743,7 +743,7 @@
             head = offset + 1;
 
             /* Extract the dest */
-            if (!(offset = index(head, ',')) || offset[0] == '\0')
+            if (!(offset = strchr(head, ',')) || offset[0] == '\0')
                 goto skipdisk;
             if ((offset - head) >= (PATH_MAX-1))
                 goto skipdisk;
@@ -753,14 +753,14 @@
 
 
             /* Extract source driver type */
-            if (!(tmp = index(src, ':')) || !tmp[0])
+            if (!(tmp = strchr(src, ':')) || !tmp[0])
                 goto skipdisk;
             strncpy(drvName, src, (tmp-src));
             drvName[tmp-src] = '\0';
 
             /* And the source driver sub-type */
             if (!strncmp(drvName, "tap", 3)) {
-                if (!(tmp1 = index(tmp+1, ':')) || !tmp1[0])
+                if (!(tmp1 = strchr(tmp+1, ':')) || !tmp1[0])
                     goto skipdisk;
                 strncpy(drvType, tmp+1, (tmp1-(tmp+1)));
                 memmove(src, src+(tmp1-src)+1, strlen(src)-(tmp1-src));
@@ -780,7 +780,7 @@
             }
 
             /* Check for a :cdrom/:disk postfix */
-            if ((tmp = index(dev, ':')) != NULL) {
+            if ((tmp = strchr(dev, ':')) != NULL) {
                 if (!strcmp(tmp, ":cdrom"))
                     cdrom = 1;
                 tmp[0] = '\0';
@@ -838,9 +838,9 @@
             key = list->str;
             while (key) {
                 char *data;
-                char *nextkey = index(key, ',');
+                char *nextkey = strchr(key, ',');
 
-                if (!(data = index(key, '=')) || (data[0] == '\0'))
+                if (!(data = strchr(key, '=')) || (data[0] == '\0'))
                     goto skipnic;
                 data++;
 
@@ -928,14 +928,14 @@
 
             while (key) {
                 char *data;
-                char *nextkey = index(key, ',');
+                char *nextkey = strchr(key, ',');
                 char *end = nextkey;
                 if (nextkey) {
                     *end = '\0';
                     nextkey++;
                 }
 
-                if (!(data = index(key, '=')) || (data[0] == '\0'))
+                if (!(data = strchr(key, '=')) || (data[0] == '\0'))
                     break;
                 data++;
 

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]