Skip to contentSkip to conversation

cleanup, use strsep in aic7xxx_linux.c and aic7xxx_old.c

PATCH New Alex Scheele 1 participant 1 message Feb 10, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cleanup, use strsep in aic7xxx_linux.c and aic7xxx_old.c

Hi,

This patch changes strtok() use to strsep(). Strtok() isn't SMP/thread safe. strsep is considered safer.

--
Alex ([email protected])

-------------------------- cut here -------------------------

drivers/scsi/aic7xxx/aic7xxx_linux.c Sat Feb 9 22:43:10 2002 renamed from drivers/scsi/aic7xxx/aic7xxx_linux.c Thu Jan 17 22:59:33 2002 +6 -5
diff -uN linux-2.5.3-dj4/drivers/scsi/aic7xxx/aic7xxx_linux.c linux/drivers/scsi/aic7xxx/aic7xxx_linux.c
@@ -445,7 +445,7 @@
                                                      struct ahc_linux_device*);
 static void ahc_linux_run_device_queue(struct ahc_softc*,
                                       struct ahc_linux_device*);
-static void ahc_linux_setup_tag_info(char *p, char *end);
+static void ahc_linux_setup_tag_info(char *p, char *end, char *s);
 static int ahc_linux_next_unit(void);
 static int ahc_linux_halt(struct notifier_block *nb, u_long event, void *buf);
 
@@ -906,7 +906,7 @@
 }
 
 static void
-ahc_linux_setup_tag_info(char *p, char *end)
+ahc_linux_setup_tag_info(char *p, char *end, char *s)
 {
        char    *base;
        char    *tok;
@@ -986,7 +986,7 @@
                }
        }
        while ((p != base) && (p != NULL))
-               p = strtok(NULL, ",.");
+               p = strsep(&s, ",.");
 }
 
 /*
@@ -1018,7 +1018,8 @@
 
        end = strchr(s, '\0');
 
-       for (p = strtok(s, ",."); p; p = strtok(NULL, ",.")) {
+       while ((p = strsep(&s, ",.")) != NULL) {
+               if (!*p) continue;
                for (i = 0; i < NUM_ELEMENTS(options); i++) {
                        n = strlen(options[i].name);
 
@@ -1026,7 +1027,7 @@
                                continue;
 
                        if (strncmp(p, "tag_info", n) == 0) {
-                               ahc_linux_setup_tag_info(p + n, end);
+                               ahc_linux_setup_tag_info(p + n, end, s);
                        } else if (p[n] == ':') {
                                *(options[i].flag) =
                                    simple_strtoul(p + n + 1, NULL, 0);
drivers/scsi/aic7xxx_old.c Sat Feb 9 21:03:01 2002 +2 -2
diff -Nru a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
@@ -1443,7 +1443,7 @@
 
   end = strchr(s, '\0');
 
-  for (p = strtok(s, ",."); p; p = strtok(NULL, ",."))
+  while ((p = strsep(&s, ",.")) != NULL)
   {
     for (i = 0; i < NUMBER(options); i++)
     {
@@ -1525,7 +1525,7 @@
               }
             }
             while((p != base) && (p != NULL))
-              p = strtok(NULL, ",.");
+              p = strsep(&s, ",.");
           }
         }
         else if (p[n] == ':')