Skip to contentSkip to conversation

strtok --> strsep in filesystem drivers (part 2)

PATCH New René Scharfe 1 participant 1 message Nov 16, 2001

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 strtok --> strsep in filesystem drivers (part 2)

Hi,

this part finishes off the rest of the strtok() calls in filesystem drivers. In some of them (FAT, VFAT, NTFS) we need to declare our own char pointer to preserve the value of the original pointer. Apart from that it's just a plain strtok() replacement. Please, apply.

René

fs/fat/inode.c +4 -2
diff -Nur linux-2.4.15-pre5/fs/fat/inode.c linux-2.4.15-pre5-rs/fs/fat/inode.c
@@ -211,6 +211,7 @@
 {
 	char *this_char,*value,save,*savep;
 	char *p;
+	char *params = options;
 	int ret = 1, len;
 
 	opts->name_check = 'n';
@@ -230,8 +231,9 @@
 		goto out;
 	save = 0;
 	savep = NULL;
-	for (this_char = strtok(options,","); this_char;
-	     this_char = strtok(NULL,",")) {
+	while ((this_char = strsep(&params)) != NULL) {
+		if (!*this_char)
+			continue;
 		if ((value = strchr(this_char,'=')) != NULL) {
 			save = *value;
 			savep = value;
fs/nfs/nfsroot.c +3 -3
diff -Nur linux-2.4.15-pre5/fs/nfs/nfsroot.c linux-2.4.15-pre5-rs/fs/nfs/nfsroot.c
@@ -202,8 +202,9 @@
 
 	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 @@
 					nfs_data.flags |= opts->or_mask;
 				}
 			}
-			cp = strtok(NULL, ",");
 		}
 	}
 	if (name[0] && strcmp(name, "default")) {
fs/ntfs/fs.c +4 -1
diff -Nur linux-2.4.15-pre5/fs/ntfs/fs.c linux-2.4.15-pre5-rs/fs/ntfs/fs.c
@@ -365,10 +365,13 @@
 	int use_utf8 = -1;	/* If no NLS specified and loading the default
 				   NLS failed use utf8. */
 	int mft_zone_mul = -1;	/* 1 */
+	char *options = opt;
 
 	if (!opt)
 		goto done;
-	for (opt = strtok(opt, ","); opt; opt = strtok(NULL, ",")) {
+	while ((opt = strsep(&options, ",")) != NULL) {
+		if (!*opt)
+			continue;
 		if ((value = strchr(opt, '=')) != NULL)
 			*value ++= '\0';
 		if (strcmp(opt, "uid") == 0) {
fs/vfat/namei.c +4 -1
diff -Nur linux-2.4.15-pre5/fs/vfat/namei.c linux-2.4.15-pre5-rs/fs/vfat/namei.c
@@ -103,6 +103,7 @@
 static int parse_options(char *options,	struct fat_mount_options *opts)
 {
 	char *this_char,*value,save,*savep;
+	char *params = options;
 	int ret, val;
 
 	opts->unicode_xlate = opts->posixfs = 0;
@@ -120,7 +121,9 @@
 	save = 0;
 	savep = NULL;
 	ret = 1;
-	for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
+	while ((this_char = strsep(&params,",")) != NULL) {
+		if (!*this_char)
+			continue;
 		if ((value = strchr(this_char,'=')) != NULL) {
 			save = *value;
 			savep = value;
mm/shmem.c +3 -4
diff -Nur linux-2.4.15-pre5/mm/shmem.c linux-2.4.15-pre5-rs/mm/shmem.c
@@ -1195,10 +1195,9 @@
 {
 	char *this_char, *value, *rest;
 
-	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;
 		} else {