public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch][2.5.4-dj4] cleanup, use strsep in aic7xxx_linux.c and aic7xxx_old.c
@ 2002-02-10 12:35 Alex Scheele
  0 siblings, 0 replies; only message in thread
From: Alex Scheele @ 2002-02-10 12:35 UTC (permalink / raw)
  To: dledford; +Cc: Dave Jones, Lkml

Hi,

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


--
	Alex (alex@packetstorm.nu)


-------------------------- cut here -------------------------
diff -uN linux-2.5.3-dj4/drivers/scsi/aic7xxx/aic7xxx_linux.c linux/drivers/scsi/aic7xxx/aic7xxx_linux.c
--- linux-2.5.3-dj4/drivers/scsi/aic7xxx/aic7xxx_linux.c        Thu Jan 17 22:59:33 2002
+++ linux/drivers/scsi/aic7xxx/aic7xxx_linux.c  Sat Feb  9 22:43:10 2002
@@ -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);
diff -Nru a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
--- a/drivers/scsi/aic7xxx_old.c        Sat Feb  9 21:03:01 2002
+++ b/drivers/scsi/aic7xxx_old.c        Sat Feb  9 21:03:01 2002
@@ -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] == ':')



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-02-10 12:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-10 12:35 [patch][2.5.4-dj4] cleanup, use strsep in aic7xxx_linux.c and aic7xxx_old.c Alex Scheele

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox