From: Linus Torvalds Date: Wed, 3 Apr 2002 06:00:03 +0000 (-0800) Subject: strtok -> strsep fixes X-Git-Tag: v2.5.8-pre1^2~11 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=c4dbf1de5b4663febe6bbd0443240a6e5dc3b947;p=history.git strtok -> strsep fixes --- diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index ce8f545fb8a5..231bc91cd79d 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -66,9 +66,9 @@ static int devpts_parse_options(char *options, struct devpts_sb_info *sbi) char *this_char, *value; this_char = NULL; - if ( options ) - this_char = strtok(options,","); - for ( ; this_char; this_char = strtok(NULL,",")) { + while ((this_char = strsep(&options, ",")) != NULL) { + if (!*this_char) + continue; if ((value = strchr(this_char,'=')) != NULL) *value++ = 0; if (!strcmp(this_char,"uid")) { diff --git a/fs/ext2/super.c b/fs/ext2/super.c index e3f8ec62c1cb..d4fcb94cac45 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -221,9 +221,9 @@ static int parse_options (char * options, unsigned long * sb_block, if (!options) return 1; - for (this_char = strtok (options, ","); - this_char != NULL; - this_char = strtok (NULL, ",")) { + while ((this_char = strsep (&options, ",")) != NULL) { + if (!*this_char) + continue; if ((value = strchr (this_char, '=')) != NULL) *value++ = 0; if (!strcmp (this_char, "bsddf")) diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 7b5d96290685..8f1f16623b0a 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -554,9 +554,9 @@ static int parse_options (char * options, unsigned long * sb_block, if (!options) return 1; - for (this_char = strtok (options, ","); - this_char != NULL; - this_char = strtok (NULL, ",")) { + while ((this_char = strsep (&options, ",")) != NULL) { + if (!*this_char) + continue; if ((value = strchr (this_char, '=')) != NULL) *value++ = 0; if (!strcmp (this_char, "bsddf")) diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 35b98b7343ce..b5f9f4227395 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -224,8 +224,9 @@ static int parse_options(char *options, int *debug, 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; diff --git a/fs/intermezzo/super.c b/fs/intermezzo/super.c index de9d181359dc..4a9358f82c07 100644 --- a/fs/intermezzo/super.c +++ b/fs/intermezzo/super.c @@ -120,12 +120,12 @@ static char *presto_options(char *options, char *cache_data, store_opt(prestodev, NULL, PRESTO_PSDEV_NAME "0"); CDEBUG(D_SUPER, "parsing options\n"); - for (this_char = strtok (options, ","); - this_char != NULL; - this_char = strtok (NULL, ",")) { + while ((this_char = strsep (&options, ",")) != NULL) { char *opt; CDEBUG(D_SUPER, "this_char %s\n", this_char); + if (!*this_char) + continue; if ( (opt = read_opt("fileset", this_char)) ) { store_opt(fileset, opt, NULL); continue; diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index 5541efe6ee2a..0bd4a72ed9b6 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c @@ -202,8 +202,9 @@ static void __init root_nfs_parse(char *name, char *buf) if ((options = strchr(name, ','))) { *options++ = 0; - cp = strtok(options, ","); - while (cp) { + while ((cp = strsep(&options, ",")) != NULL) { + if (!*cp) + continue; if ((val = strchr(cp, '='))) { struct nfs_int_opts *opts = root_int_opts; *val++ = '\0'; @@ -220,7 +221,6 @@ static void __init root_nfs_parse(char *name, char *buf) nfs_data.flags |= opts->or_mask; } } - cp = strtok(NULL, ","); } } if (name[0] && strcmp(name, "default")) { diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 4ae60bfb88fb..638d218a7f15 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -133,8 +133,11 @@ static int parse_options(char *options,uid_t *uid,gid_t *gid) *uid = current->uid; *gid = current->gid; - if (!options) return 1; - for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) { + if (!options) + return 1; + while ((this_char = strsep(&options,",")) != NULL) { + if (!*this_char) + continue; if ((value = strchr(this_char,'=')) != NULL) *value++ = 0; if (!strcmp(this_char,"uid")) { diff --git a/fs/udf/super.c b/fs/udf/super.c index 2edd4015fb61..dd5c7177a131 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -286,8 +286,9 @@ udf_parse_options(char *options, struct udf_options *uopt) if (!options) return 1; - for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) - { + while ((opt = strsep(&options, ",") != NULL) { + if (!*opt) + continue; /* Make "opt=val" into two strings */ val = strchr(opt, '='); if (val) diff --git a/fs/ufs/super.c b/fs/ufs/super.c index c2cd329064b3..e13ce227d0bf 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -257,11 +257,10 @@ static int ufs_parse_options (char * options, unsigned * mount_options) if (!options) return 1; - - for (this_char = strtok (options, ","); - this_char != NULL; - this_char = strtok (NULL, ",")) { - + + while ((this_char = strsep (&options, ",")) != NULL) { + if (!*this_char) + continue; if ((value = strchr (this_char, '=')) != NULL) *value++ = 0; if (!strcmp (this_char, "ufstype")) { diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index e44b87116be1..c71cf4971f46 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c @@ -115,7 +115,9 @@ static int parse_options(char *options, struct fat_mount_options *opts) save = 0; savep = NULL; ret = 1; - 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;