lkml.org 
[lkml]   [2002]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[patch][2.5.4-dj4] cleanup, use strsep in aic7xxx_linux.c and aic7xxx_old.c
Date
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] == ':')

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:24    [W:0.071 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site