public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch][2.5.4-dj4] cleanup to use strsep for fs/fat/inode.c
@ 2002-02-10  1:48 Alex Scheele
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Scheele @ 2002-02-10  1:48 UTC (permalink / raw)
  To: chaffee; +Cc: Dave Jones, Lkml

Hi,

This patch changes all use of strtok() 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/fs/fat/inode.c linux/fs/fat/inode.c
--- linux-2.5.3-dj4/fs/fat/inode.c      Sat Feb  9 21:57:39 2002
+++ linux/fs/fat/inode.c        Sun Feb 10 03:47:48 2002
@@ -223,8 +223,9 @@
                goto out;
        save = 0;
        savep = NULL;
-       for (this_char = strtok(options,","); this_char;
-            this_char = strtok(NULL,",")) {
+       while ((this_char = strsep(&options,",")) != NULL) {
+               if (!*this_char)
+                       continue;
                if ((value = strchr(this_char,'=')) != NULL) {
                        save = *value;
                        savep = value;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch][2.5.4-dj4] cleanup to use strsep for fs/fat/inode.c
@ 2002-02-10 13:19 René Scharfe
  2002-02-10 14:27 ` Alex Scheele
  0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2002-02-10 13:19 UTC (permalink / raw)
  To: Alex Scheele; +Cc: Linux Kernel Mailing List

Hi,

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

OK, but ...

> -       for (this_char = strtok(options,","); this_char;
> -            this_char = strtok(NULL,",")) {

This _does not_ change the value of 'options'.

> +       while ((this_char = strsep(&options,",")) != NULL) {

This _does_ change the value of 'options'. Problem is, it's
used later. Same is true for your patch to fs/vfat/namei.c.

René

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [patch][2.5.4-dj4] cleanup to use strsep for fs/fat/inode.c
  2002-02-10 13:19 [patch][2.5.4-dj4] cleanup to use strsep for fs/fat/inode.c René Scharfe
@ 2002-02-10 14:27 ` Alex Scheele
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Scheele @ 2002-02-10 14:27 UTC (permalink / raw)
  To: l.s.r; +Cc: Dave Jones, Lkml

> > This patch changes all use of strtok() to strsep().
> > Strtok() isn't SMP/thread safe. strsep is considered safer.
> 
> OK, but ...
> 
> > -       for (this_char = strtok(options,","); this_char;
> > -            this_char = strtok(NULL,",")) {
> 
> This _does not_ change the value of 'options'.
> 
> > +       while ((this_char = strsep(&options,",")) != NULL) {
> 
> This _does_ change the value of 'options'. Problem is, it's
> used later. Same is true for your patch to fs/vfat/namei.c.

Ok, sorry seems i overlooked that. Patches, for both files, below 
should fix it.

Cheers,
--
	Alex (alex@packetstorm.nu)


diff -uN linux-2.5.3-dj4/fs/vfat/namei.c linux/fs/vfat/namei.c
--- linux-2.5.3-dj4/fs/vfat/namei.c     Mon Jan 28 22:20:44 2002
+++ linux/fs/vfat/namei.c       Sun Feb 10 15:28:26 2002
@@ -97,6 +97,7 @@
 static int parse_options(char *options,        struct fat_mount_options *opts)
 {
        char *this_char,*value,save,*savep;
+       char *optptr = options;
        int ret, val;

        opts->unicode_xlate = opts->posixfs = 0;
@@ -114,7 +115,9 @@
        save = 0;
        savep = NULL;
        ret = 1;
-       for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
+       while ((this_char = strsep(&optptr,",")) != NULL) {
+               if (!*this_char)
+                       continue;
                if ((value = strchr(this_char,'=')) != NULL) {
                        save = *value;
                        savep = value;
diff -uN linux-2.5.3-dj4/fs/fat/inode.c linux/fs/fat/inode.c
--- linux-2.5.3-dj4/fs/fat/inode.c      Sat Feb  9 21:57:39 2002
+++ linux/fs/fat/inode.c        Sun Feb 10 15:51:42 2002
@@ -203,7 +203,7 @@
                         char *cvf_format, char *cvf_options)
 {
        char *this_char,*value,save,*savep;
-       char *p;
+       char *p, *optptr = options;
        int ret = 1, len;

        opts->name_check = 'n';
@@ -223,8 +223,9 @@
                goto out;
        save = 0;
        savep = NULL;
-       for (this_char = strtok(options,","); this_char;
-            this_char = strtok(NULL,",")) {
+       while ((this_char = strsep(&optptr,",")) != NULL) {
+               if (!*this_char)
+                       continue;
                if ((value = strchr(this_char,'=')) != NULL) {
                        save = *value;
                        savep = value;




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-02-10 14:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-10 13:19 [patch][2.5.4-dj4] cleanup to use strsep for fs/fat/inode.c René Scharfe
2002-02-10 14:27 ` Alex Scheele
  -- strict thread matches above, loose matches on Subject: below --
2002-02-10  1:48 Alex Scheele

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