public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Alex Scheele" <alex@packetstorm.nu>
To: <dledford@redhat.com>
Cc: "Dave Jones" <davej@suse.de>, "Lkml" <linux-kernel@vger.kernel.org>
Subject: [patch][2.5.4-dj4] cleanup, use strsep in aic7xxx_linux.c and aic7xxx_old.c
Date: Sun, 10 Feb 2002 13:35:18 +0100	[thread overview]
Message-ID: <IOEMLDKDBECBHMIOCKODMEMOCJAA.alex@packetstorm.nu> (raw)

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] == ':')



                 reply	other threads:[~2002-02-10 12:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=IOEMLDKDBECBHMIOCKODMEMOCJAA.alex@packetstorm.nu \
    --to=alex@packetstorm.nu \
    --cc=davej@suse.de \
    --cc=dledford@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox